123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- using UnityEngine;
- using UnityEngine.UI;
- using UnityEngine.Events;
- using UnityEngine.EventSystems;
- using System;
- using System.Xml;
- using System.Linq;
- using System.Collections;
- using System.Collections.Generic;
- public class ManaGarden : Regist
- {
- #region 变量
- public static int MyFlower
- {
- get { return _MyFlower; }
- set
- {
- _MyFlower = value;
- ManaReso.SetText("F_FlowerLab", string.Format("{0}", MyFlower));
- ManaReso.SetText("G_CollectLab1", string.Format("{0}/{1}", MyFlower, TotalFlower));
- }
- }
- public static int MyFlowerSpec
- {
- get { return _MyFlowerSpec; }
- set
- {
- _MyFlowerSpec = value;
- MyFlower = _MyFlowerSpec + _MyFlowerRegu;
- }
- }
- public static int MyFlowerRegu
- {
- get { return _MyFlowerRegu; }
- set
- {
- _MyFlowerRegu = value;
- MyFlower = _MyFlowerSpec + _MyFlowerRegu;
- }
- }
- public static int TotalFlower
- {
- get { return _TotalFlower; }
- set { _TotalFlower = value; }
- }
- public static int TotalFlowerSpec
- {
- get { return _TotalFlowerSpec; }
- set
- {
- _TotalFlowerSpec = value;
- TotalFlower = _TotalFlowerSpec + _TotalFlowerRegu;
- }
- }
- public static int TotalFlowerRegu
- {
- get { return _TotalFlowerRegu; }
- set
- {
- _TotalFlowerRegu = value;
- TotalFlower = _TotalFlowerSpec + _TotalFlowerRegu;
- }
- }
- private static int _MyFlower;
- private static int _MyFlowerSpec;
- private static int _MyFlowerRegu;
- private static int _TotalFlower;
- private static int _TotalFlowerSpec;
- private static int _TotalFlowerRegu;
- public static Slot SeleSlot;
- public static FlowerInfo SeleFlowerInfo;
- public static List<Slot> SlotList;
- public static List<Slot> PlantList;
- public static List<FlowerInfo> FlowerInfoList;
- #endregion
- private void Awake()
- {
- ManaReso.Get("Garden", Folder.Object, true, transform, true).AddScript<Garden>();
- #region 生成FlowerItem
- PlantList = new List<Slot>();
- FlowerInfoList = new List<FlowerInfo>();
- List<XmlAttributeCollection> attributesList = Data.GetFlowerConfig();
- for (int i = 0; i < attributesList.Count; i++)
- {
- FlowerInfo flowerInfo = new FlowerInfo(attributesList[i]);
- if (flowerInfo.Special)
- {
- TotalFlowerSpec++;
- }
- else
- {
- TotalFlowerRegu++;
- }
- FlowerInfoList.Add(flowerInfo);
- }
- #endregion
- }
- public override void RegistValueA()
- {
- SlotList = new List<Slot>()
- {
- ManaReso.Get("SlotA1").AddComponent<Slot>(),
- ManaReso.Get("SlotA2").AddComponent<Slot>(),
- ManaReso.Get("SlotA3").AddComponent<Slot>(),
- ManaReso.Get("SlotA4").AddComponent<Slot>(),
- ManaReso.Get("SlotA5").AddComponent<Slot>(),
- ManaReso.Get("SlotA6").AddComponent<Slot>(),
- ManaReso.Get("SlotA7").AddComponent<Slot>(),
- ManaReso.Get("SlotA8").AddComponent<Slot>(),
- ManaReso.Get("SlotA9").AddComponent<Slot>(),
- ManaReso.Get("SlotB1").AddComponent<Slot>(),
- ManaReso.Get("SlotB2").AddComponent<Slot>(),
- ManaReso.Get("SlotB3").AddComponent<Slot>(),
- ManaReso.Get("SlotB4").AddComponent<Slot>(),
- ManaReso.Get("SlotB5").AddComponent<Slot>(),
- ManaReso.Get("SlotB6").AddComponent<Slot>(),
- ManaReso.Get("SlotB7").AddComponent<Slot>(),
- ManaReso.Get("SlotB8").AddComponent<Slot>(),
- ManaReso.Get("SlotB9").AddComponent<Slot>(),
- };
- }
- public static void SetFlowerCard(FlowerInfo flowerInfo)
- {
- SeleFlowerInfo = flowerInfo;
- ManaReso.SetText("H_Lab", flowerInfo.Name);
- Image image = ManaReso.Get<Image>("H_Icon2");
- image.sprite = flowerInfo.Sprite;
- Vector2 newSize = flowerInfo.Sprite.rect.size;
- newSize.x *= 0.65f;
- newSize.y *= 0.65f;
- image.rectTransform.sizeDelta = newSize;
- }
- public static void ShowPlantCard()
- {
- }
- public static void ShowRetrieveCard(FlowerInfo flowerInfo)
- {
- SeleSlot = flowerInfo.Slot;
- SetFlowerCard(flowerInfo);
- ManaReso.SetActive("H_Grid", false);
- ManaReso.SetActive("H_Prev", false);
- ManaReso.SetActive("H_Next", false);
- ManaReso.SetActive("H_Place", false);
- ManaReso.SetActive("H_Icon1", true);
- ManaReso.SetActive("H_Retrieve", true);
- ManaReso.Get("H_FlowerCard").TweenForCG();
- }
- public static void RetriveFlower()
- {
- SeleSlot.Retrieve();
- }
- public static void RetriveFlowerAll()
- {
- for (int i = 0; i < PlantList.Count; i++)
- {
- PlantList[i].Retrieve();
- i--;
- }
- }
- public static void PlantFlower()
- {
- SeleSlot.Plant(SeleFlowerInfo);
- }
- public static void PlantFlower(FlowerInfo flowerInfo)
- {
- if (flowerInfo.Plant)
- {
- ShowRetrieveCard(flowerInfo);
- }
- else
- {
- Slot slot = null;
- for (int i = 0; i < SlotList.Count; i++)
- {
- if (SlotList[i].Available)
- {
- slot = SlotList[i];
- break;
- }
- }
- if (slot == null)
- {
- ManaDebug.Log("已经没有空地了");
- }
- else
- {
- slot.Plant(flowerInfo);
- }
- }
- }
- public static void PlantFlower(int id, string parName)
- {
- Slot slot = ManaReso.Get<Slot>(parName);
- FlowerInfo flowerInfo = FlowerInfoList[id];
- slot.Plant(flowerInfo);
- }
- }
|