private Toggle isCollectToggle; // 是否采集 #endregion private void Start() { #region 房屋菜单组件获取 houseMenu = GameObject.Find("Canvas").transform.Find("房屋菜单"); headline = houseMenu.Find("标题").GetComponent <Text>(); NPCGetText = houseMenu.Find("NPC人数获取").Find("人数").GetComponent <Text>(); NPCGetInputField = houseMenu.Find("NPC人数获取").Find("InputField").GetComponent <InputField>(); NPCGetButton = houseMenu.Find("NPC人数获取").Find("Button").GetComponent <Button>(); NPCAddText = houseMenu.Find("NPC人数添加").Find("人数").GetComponent <Text>(); NPCAddInputField = houseMenu.Find("NPC人数添加").Find("InputField").GetComponent <InputField>(); NPCAddButton = houseMenu.Find("NPC人数添加").Find("Button").GetComponent <Button>(); collectText = houseMenu.Find("资源获取").Find("资源数量").GetComponent <Text>(); collectInputField = houseMenu.Find("资源获取").Find("InputField").GetComponent <InputField>(); collectButton = houseMenu.Find("资源获取").Find("Button").GetComponent <Button>(); debtorText = houseMenu.Find("未入账").GetComponent <Text>(); closeButton = houseMenu.Find("关闭按钮").GetComponent <Button>(); isCollectToggle = houseMenu.Find("是否采集").GetComponent <Toggle>(); #endregion playerInteraction = PlayerInputManage.single.GetComponent <PlayerInteraction>(); isCollect = true; birthPoint = transform.Find("NPC生成点"); if (warehouse == null) { warehouse = new ItemData() { name = collectType.ToString(), number = 0 } } ; StartCoroutine(Dispatch()); // 生成NPC for (int i = 0; i < NPCNumber; i++) { NPC temp = Instantiate(ResourcePath.Single.NPCList[ Random.Range(0, ResourcePath.Single.NPCList.Count)]).GetComponent <NPC>(); temp.gameObject.SetActive(false); NPCQueue.Enqueue(temp); } houseData = new HouseData() { itemData = warehouse, name = houseName, position = transform.position, rotation = transform.rotation, _NPC = NPCNumber }; GameSave.Single.gameData.houseDatas.Add(houseData); }
/// <summary> /// 字符串转换为枚举类型 /// </summary> /// <param name="code"></param> /// <returns></returns> private CollectType GetCollectType(string code) { code.CheckNotNullOrEmpty("code"); Type type = typeof(CollectType); MemberInfo[] members = type.GetMembers(BindingFlags.Public | BindingFlags.Static); foreach (MemberInfo member in members) { CollectType collectType = member.Name.CastTo <CollectType>(); if (collectType.ToString() == code) { return(collectType); } } throw new NotSupportedException("不支持的收藏类型" + code); }