Esempio n. 1
0
        public void Init(NpcQuestItemDTO questItem, Transform followNode, Action action)
        {
            m_FollowNode.SetFloowNode(followNode);
            gameObject.AddComponent <DelayCallBack>().SetAction(action, 2, true);
            int         state   = questItem.state;
            CampNpcItem npcItem = Global.gApp.gGameData.CampNpcConfig.Get(questItem.npcId);

            if (state == NpcState.None)
            {
                int plotLength = npcItem.NoTask.Length;
                int plotIndex  = UnityEngine.Random.Range(0, plotLength);
                TaskText.text.text = Global.gApp.gGameData.GetTipsInCurLanguage(npcItem.NoTask[plotIndex]);
            }
            else if (state == NpcState.Received)
            {
                int plotLength = npcItem.TaskFinished.Length;
                int plotIndex  = UnityEngine.Random.Range(0, plotLength);
                TaskText.text.text = Global.gApp.gGameData.GetTipsInCurLanguage(npcItem.NoTask[plotIndex]);
            }
            string lgg = Global.gApp.gSystemMgr.GetMiscMgr().Language;

            if (lgg == null || lgg.Equals(GameConstVal.EmepyStr))
            {
                lgg = UiTools.GetLanguage();
            }
            TaskText.text.font = Global.gApp.gGameData.GetFont(lgg);
        }
Esempio n. 2
0
        private void InitNode()
        {
            int notFreshNum = 0;
            int freshNum    = 0;

            //计算可生成npc总数
            foreach (ItemDTO itemDTO in Global.gApp.gSystemMgr.GetNpcMgr().NpcMap.Values)
            {
                ItemItem    itemCfg = Global.gApp.gGameData.ItemData.Get(itemDTO.itemId);
                CampNpcItem npcItem = Global.gApp.gGameData.CampNpcConfig.Get(itemCfg.name);
                if (npcItem.notFresh != 1)
                {
                    notFreshNum += Convert.ToInt32(itemDTO.num);
                }
                else
                {
                    freshNum += Convert.ToInt32(itemDTO.num);
                }
            }

            int campLevel = Global.gApp.gSystemMgr.GetNpcMgr().CalCampLevel();

            string[] maxNpcNum      = Global.gApp.gGameData.GeneralConfigData.Get(GeneralConfigConstVal.CAMP_MAX_NUM).contents;
            string[] levelName      = Global.gApp.gGameData.GeneralConfigData.Get(GeneralConfigConstVal.CAMP_LEVEL_NAME).contents;
            string[] levelNameColor = Global.gApp.gGameData.GeneralConfigData.Get(GeneralConfigConstVal.CAMP_LEVEL_NAME_COLOR).contents;

            LevelText.text.text  = Global.gApp.gGameData.GetTipsInCurLanguage(int.Parse(levelName[campLevel - 1]));
            LevelText.text.color = ColorUtil.GetColor(levelNameColor[campLevel - 1]);

            Cur.text.text = string.Format(Global.gApp.gGameData.GetTipsInCurLanguage(4391), (notFreshNum + freshNum));
            Max.text.text = string.Format(Global.gApp.gGameData.GetTipsInCurLanguage(4392), (int.Parse(maxNpcNum[(campLevel - 1) * 2 + 1]) + Global.gApp.gGameData.NotFreshNpcList.Count));

            DetailItemUI.gameObject.SetActive(false);
            for (int i = maxNpcNum.Length - 1; i >= 0; i -= 2)
            {
                CampDetailUI_DetailItemUI itemUI = DetailItemUI.GetInstance();
                itemUI.gameObject.SetActive(true);
                int unlockNum = i == 1 ? 0 : int.Parse(maxNpcNum[i - 2]) + Global.gApp.gGameData.NotFreshNpcList.Count;
                itemUI.LockText.text.text = string.Format(Global.gApp.gGameData.GetTipsInCurLanguage(4393), unlockNum);
                itemUI.LockText.gameObject.SetActive(campLevel < (i + 1) / 2);
                itemUI.DName.text.text   = Global.gApp.gGameData.GetTipsInCurLanguage(int.Parse(levelName[(i - 1) / 2]));
                itemUI.DName.text.color  = ColorUtil.GetColor(levelNameColor[(i - 1) / 2]);
                itemUI.Icon.image.sprite = Global.gApp.gResMgr.LoadAssets <Sprite>(string.Format(CommonResourceConstVal.CAMP_LEVEL, (i + 1) / 2));
                Color old = itemUI.Icon.image.color;
                if ((i + 1) / 2 > campLevel)
                {
                    old.a = 0.5f;
                    itemUI.Lock.gameObject.SetActive(true);
                }
                else
                {
                    old.a = 1;
                    itemUI.Lock.gameObject.SetActive(false);
                }
                itemUI.Icon.image.color = old;
            }

            CloseBtn.button.onClick.AddListener(TouchClose);
        }
Esempio n. 3
0
        private void InitNode()
        {
            DayTaskItemUI.gameObject.SetActive(false);
            TotalTaskItem.gameObject.SetActive(false);
            List <NpcQuestItemDTO> nqidList = Global.gApp.gSystemMgr.GetNpcMgr().NpcQuestList;

            for (int i = 0; i < nqidList.Count; i++)
            {
                if (nqidList[i].npcQuestId == -1)
                {
                    continue;
                }
                CampNpcItem campNpcItem = Global.gApp.gGameData.CampNpcConfig.Get(nqidList[i].npcId);
                ItemItem    npcItem     = Global.gApp.gGameData.GetItemDataByName(nqidList[i].npcId);
                if (campNpcItem.notFresh == 1)
                {
                    CampTasksItem taskCfg = Global.gApp.gGameData.CampTasksConfig.Get(nqidList[i].npcQuestId);
                    if (taskCfg == null)
                    {
                        continue;
                    }
                    CampTaskDetails_TotalTaskItem itemUI = TotalTaskItem.GetInstance();
                    itemUI.InitNode(nqidList[i], i, this);
                    m_TotalItemList.Add(itemUI);
                }
                else
                {
                    CampTasksItem taskCfg = Global.gApp.gGameData.CampTasksConfig.Get(nqidList[i].npcQuestId);
                    if (taskCfg == null)
                    {
                        continue;
                    }
                    CampTaskDetails_DayTaskItemUI itemUI = DayTaskItemUI.GetInstance();
                    itemUI.InitNode(nqidList[i], i, this);
                    m_ItemList.Add(itemUI);
                }
            }
            m_none.gameObject.SetActive(m_TotalItemList.Count == 0);
            ChangeTotalShowIndex();
            ChangeShowIndex();

            CloseBtn.button.onClick.AddListener(TouchClose);
        }
Esempio n. 4
0
    public override bool AddItem(ItemDTO itemDTO)
    {
        ItemDTO iDTO = mgr.GetNpc(itemDTO.itemId);

        if (iDTO == null)
        {
            iDTO = new ItemDTO(itemDTO.itemId, 0d, 0);
            mgr.GetData().npcMap[itemDTO.itemId.ToString()] = iDTO;
        }
        iDTO.num += itemDTO.num;
        ItemItem    itemCfg = Global.gApp.gGameData.ItemData.Get(itemDTO.itemId);
        CampNpcItem npcCfg  = Global.gApp.gGameData.CampNpcConfig.Get(itemCfg.name);

        if (npcCfg.notFresh == 1 && iDTO.num > 1)
        {
            iDTO.num = 1;
        }
        mgr.SaveData();
        Global.gApp.gMsgDispatcher.Broadcast(MsgIds.UIFresh);
        return(true);
    }
Esempio n. 5
0
        private void CreateNpcImp(Transform bornNode, NpcQuestItemDTO taskItem, int taskIndex, GameObject followNode = null)
        {
            string npcId = taskItem.npcId;

            CampNpcItem campNpcItem = Global.gApp.gGameData.CampNpcConfig.Get(npcId);
            GameObject  npcNode     = Global.gApp.gResMgr.InstantiateObj(campNpcItem.NpcPath);

            npcNode.transform.SetParent(m_NpcNode, false);
            if (taskItem.state != NpcState.None)
            {
                Transform newBornNode = m_TaskNpcBronNode.transform.GetChild(m_TaskNpcBornNodeIndex);
                npcNode.transform.position = newBornNode.position;
                m_TaskNpcBornNodeIndex++;
            }
            else
            {
                Vector3 localScale = bornNode.localScale;
                float   x          = Random.Range(-0.5f, 0.5f);
                float   y          = Random.Range(-0.5f, 0.5f);
                Vector3 posOffset  = new Vector3(localScale.x * x, localScale.y * y, 0);

                Vector3 position = bornNode.transform.position + posOffset;
                position.z = 0;
                npcNode.transform.position = position;
            }
            NpcBehavior npcBehavior = npcNode.GetComponent <NpcBehavior>();

            npcBehavior.Init(taskItem, taskIndex);
            if (followNode != null)
            {
                FollowNode followComp = followNode.GetComponent <FollowNode>();
                followComp.SetFloowNode(npcBehavior.GetTaskUINode());
                npcBehavior.SetForceHasOutlineEffect();
            }
            m_NpcBehav.Add(npcBehavior);
        }
Esempio n. 6
0
        private void FreshNodeInfo()
        {
            string[] curConsume = Global.gApp.gGameData.GeneralConfigData.Get(GeneralConfigConstVal.CAMP_NPC_DAY_COST).contents;
            string   maxDayStr  = Global.gApp.gGameData.GeneralConfigData.Get(GeneralConfigConstVal.CAMP_NPC_MAX_STORE_DAY).content;
            double   maxDayD    = double.Parse(maxDayStr);
            int      curId      = 0;
            SortedDictionary <int, double> maxCousumeCountMap = new SortedDictionary <int, double>();
            Dictionary <string, ItemDTO>   npcMap             = m_NpcMgr.NpcMap;
            double totlaNpcNum         = 0;
            double totalNotFreshNpcNum = 0;

            foreach (KeyValuePair <string, ItemDTO> kvValue in npcMap)
            {
                totlaNpcNum += kvValue.Value.num;
                ItemItem    itemCfg = Global.gApp.gGameData.ItemData.Get(kvValue.Value.itemId);
                CampNpcItem cfg     = Global.gApp.gGameData.CampNpcConfig.Get(itemCfg.name);
                if (cfg.notFresh == 1)
                {
                    totalNotFreshNpcNum += kvValue.Value.num;
                }
            }
            for (int i = 0; i < curConsume.Length; i += 2)
            {
                curId = int.Parse(curConsume[i]);
                double curMat = totlaNpcNum * double.Parse(curConsume[i + 1]) * maxDayD;
                maxCousumeCountMap[curId] = curMat;
            }

            // npc人数
            CurNpcNum.text.text = ((int)totlaNpcNum).ToString();
            string[] maxNpcNum = Global.gApp.gGameData.GeneralConfigData.Get(GeneralConfigConstVal.CAMP_MAX_NUM).contents;

            int campLv = m_NpcMgr.CalCampLevel();

            MaxNpcNum.text.text = (int.Parse(maxNpcNum[2 * campLv - 1]) + Global.gApp.gGameData.NotFreshNpcList.Count).ToString();

            FreshBuild();
            FreshCakeBuild();
            FreshCampLvState();
            FreshRecycleAndResState();
            FreshTaskIconState();
            string[] levelNames = Global.gApp.gGameData.GeneralConfigData.Get(GeneralConfigConstVal.CAMP_LEVELS).contents;
            CampName.text.text = Global.gApp.gGameData.GetTipsInCurLanguage(int.Parse(levelNames[campLv - 1]));



            double totalCount    = 0d;
            double totalMaxCount = 0d;

            ResourceItemUI.gameObject.SetActive(false);
            ClearResourceList();
            foreach (int id in maxCousumeCountMap.Keys)
            {
                double curV = GameItemFactory.GetInstance().GetItem(id);
                double maxV = maxCousumeCountMap[id];
                totalCount    += curV;
                totalMaxCount += maxV;
                ItemItem itemCfg = Global.gApp.gGameData.ItemData.Get(id);

                CampsiteUI_ResourceItemUI itemUI = ResourceItemUI.GetInstance();
                itemUI.gameObject.SetActive(true);
                itemUI.Materials.image.sprite = Global.gApp.gResMgr.LoadAssets <Sprite>(itemCfg.image_grow);
                itemUI.Amount.text.text       = System.Math.Ceiling(curV).ToString("0.##") + "/" + System.Math.Ceiling(maxV).ToString("0.##");
                itemUI.transform.SetSiblingIndex(id);

                m_ResourceItemList.Add(itemUI);
            }

            int index = -1;

            if (totalMaxCount > 0)
            {
                double   rata       = (totalCount / (totalMaxCount)) * 100;
                string[] stateJudge = Global.gApp.gGameData.GeneralConfigData.Get(GeneralConfigConstVal.CAMP_NPC_HEATH_DEFINITION).contents;
                for (int i = 0; i < stateJudge.Length; i++)
                {
                    if (rata <= double.Parse(stateJudge[i]))
                    {
                        index = i;
                        break;
                    }
                }
                if (index < 0)
                {
                    index = stateJudge.Length;
                }
            }
            else
            {
                index = 0;
            }
            string[] stateIds = Global.gApp.gGameData.GeneralConfigData.Get(GeneralConfigConstVal.CAMP_NPC_HEATH_NAME).contents;
            CmpState.text.text = Global.gApp.gGameData.GetTipsInCurLanguage(int.Parse(stateIds[index]));
            if (index == 0)
            {
                CmpState.text.color = new Color(255.0f / 255, 39.0f / 255, 39.0f / 255);
            }
            else if (index == 1)
            {
                CmpState.text.color = new Color(255.0f / 255, 234.0f / 255, 99.0f / 255);
            }
            else if (index == 2)
            {
                CmpState.text.color = new Color(183.0f / 255, 245.0f / 255, 60.0f / 255);
            }
        }