public void Init(NpcBehavior npcBehavior, Transform followNode, int dropDiamondCount)
 {
     m_NpcBehavior = npcBehavior;
     m_FollowNode.SetFloowNode(followNode);
     m_Count.text.text = "X" + dropDiamondCount.ToString();
     RewardStateBg.button.onClick.AddListener(OpenTaskDetails);
 }
Esempio n. 2
0
        private void CreateNpc()
        {
            NpcQuestItemDTO questItem = m_CurTaskList[m_CreateIndex];
            Transform       bornNode;
            bool            showOldWomanPlot = false;
            bool            IsOldWoman       = false;
            bool            IsBoy            = false;
            GameObject      flolowNode       = null;

            if (questItem.npcId == "Npc_boy")
            {
                bornNode = m_ControllerNode.transform.Find("FightNode/NPCBornNode/BoyBornNode");
                IsBoy    = true;
            }
            else if (questItem.npcId == "Npc_oldwoman")
            {
                if (!Global.gApp.gSystemMgr.GetMiscMgr().GetAndResetHasOpenCampState())
                {
                    showOldWomanPlot = true;
                }
                bornNode   = m_ControllerNode.transform.Find("FightNode/NPCBornNode/OldWomanBornNode");
                flolowNode = OldWamonIcon.gameObject;
                IsOldWoman = true;
            }
            else if (questItem.npcId == "Npc_drstrange")
            {
                bornNode   = m_ControllerNode.transform.Find("FightNode/NPCBornNode/DrStrangeBornNode");
                flolowNode = DrstrangeIcon.gameObject;
            }
            else if (questItem.npcId == "Npc_recycle")
            {
                bornNode   = m_ControllerNode.transform.Find("FightNode/NPCBornNode/RecycleBornNode");
                flolowNode = RecycleIcon.gameObject;
            }
            else
            {
                int index = Random.Range(0, m_NoTaskNpcBornNode.childCount);
                bornNode = m_NoTaskNpcBornNode.GetChild(index);
            }
            CreateNpcImp(bornNode, questItem, m_CreateIndex, flolowNode);
            if (showOldWomanPlot)
            {
                //m_NpcBehav[m_CreateIndex].ShowOldWomanTaskUi(100203);
            }
            if (IsOldWoman)
            {
                m_OldWomanBav = m_NpcBehav[m_CreateIndex];
                m_OldWomanBav.transform.position = bornNode.transform.position;
            }
            else if (IsBoy)
            {
                m_NpcBehav[m_CreateIndex].gameObject.SetActive(m_NpcMgr.GetShowBoyNpcState());
                m_BoyBav = m_NpcBehav[m_CreateIndex];
            }
            m_CreateIndex++;
        }
Esempio n. 3
0
 public void Init(NpcBehavior npcBehavior, Transform followNode, int taskId, int taskState)
 {
     m_NpcBehavior = npcBehavior;
     m_TaskId      = taskId;
     m_TaskState   = taskState;
     m_FollowNode.SetFloowNode(followNode);
     SetTaskState(taskState);
     TaskStateBg.button.onClick.AddListener(OpenTaskDetails);
     RewardStateBg.button.onClick.AddListener(OpenTaskDetails);
 }
Esempio n. 4
0
 public void SetInfo(NpcBehavior npcBehavior, int dropNum)
 {
     m_NpcBehavior = npcBehavior;
     if (m_DropNum == 0)
     {
         RedHeartClick iconBtn = transform.Find(IconBtnName).gameObject.AddComponent <RedHeartClick>();
         iconBtn.RespondClick = RespondClick;
     }
     m_DropNum = dropNum;
 }
Esempio n. 5
0
        public override void Init <T>(string name, UIInfo info, T arg)
        {
            base.Init(name, info, arg);
            m_NpcBehavior = arg as NpcBehavior;
            Canvas        parentCanvas  = GetComponentInParent <Canvas>();
            RectTransform parentRectTsf = parentCanvas.GetComponent <RectTransform>();

            m_AdaptNode.rectTransform.anchoredPosition = UiTools.WorldToRectPos(gameObject, m_NpcBehavior.GetTaskUINode().position, parentRectTsf);
            GenerateRecycleMat();
            InitNode();
            base.ChangeLanguage();
        }
Esempio n. 6
0
        public void FreshAllNpcTaskState()
        {
            m_CurTaskList = m_NpcMgr.NpcQuestList;
            List <NpcPosStruct> npcBehaviorPos = new List <NpcPosStruct>();

            foreach (NpcBehavior npcBehavior in m_NpcBehav)
            {
                npcBehaviorPos.Add(new NpcPosStruct()
                {
                    NPCId = npcBehavior.GetNpcId(),
                    Pos   = npcBehavior.transform.position,
                });
                npcBehavior.DestroyNpc();
            }
            m_NpcBehav.Clear();
            m_CreateIndex = 0;
            int curIndex;

            m_CurGuandTime = -100;
            while (m_CreateIndex < m_CurTaskList.Count)
            {
                curIndex = m_CreateIndex;
                CreateNpc();
                NpcBehavior newNpcBehavior = m_NpcBehav[curIndex];
                string      npcId          = newNpcBehavior.GetNpcId();
                int         index          = 0;
                foreach (NpcPosStruct npcPosStruct in npcBehaviorPos)
                {
                    if (npcId == npcPosStruct.NPCId)
                    {
                        newNpcBehavior.transform.position = npcPosStruct.Pos;
                        break;
                    }
                    else
                    {
                        index++;
                    }
                }
                npcBehaviorPos.RemoveAt(index);
            }
        }
Esempio n. 7
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);
        }