12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- public class Slot : MonoBehaviour
- {
- #region 变量
- public bool Valid
- {
- get { return _Valid; }
- set
- {
- _Valid = value;
- if (_Valid)
- {
- Icon.SetActive(false);
- }
- else
- {
- Icon.SetActive(true);
- }
- }
- }
- private bool _Valid;
- public int Id;
- public bool Available;
- public Flower Flower;
- public FlowerInfo FlowerInfo;
- public GameObject Icon;
- public BoxCollider2D Collider;
- #endregion
- private void Awake()
- {
- Icon = transform.GetChild(0).gameObject;
- Collider = GetComponent<BoxCollider2D>();
- }
- public void Plant(FlowerInfo flowerInfo)
- {
- FlowerInfo = flowerInfo;
- Id = flowerInfo.Id;
- Collider.enabled = false;
- Available = false;
- FlowerInfo.Slot = this;
- FlowerInfo.Plant = true;
- Flower = ManaReso.GetFlower(flowerInfo, this, true);
- ManaGarden.PlantList.Add(this);
- }
- public void Retrieve()
- {
- Collider.enabled = true;
- Available = true;
- FlowerInfo.Plant = false;
- ManaReso.Save(Flower);
- ManaGarden.PlantList.Remove(this);
- }
- }
|