Beispiel #1
0
        private void RunTimer()
        {
            Dictionary <int, TaskData> dicTask = A3_TaskModel.getInstance().GetDicTaskData();
            List <int> idx      = new List <int>(dicTask.Keys);
            bool       isTiming = false;

            for (int i = 0; i < idx.Count; i++)
            {
                if (!taskOptElement.ContainsKey(idx[i]))
                {
                    continue;
                }
                TaskOptElement tempElem = taskOptElement[idx[i]];
                float          endTime  = dicTask[idx[i]].lose_tm,
                               curTime  = muNetCleint.instance.CurServerTimeStamp,
                               duration = dicTask[idx[i]].release_tm;
                TaskData task           = dicTask[idx[i]];
                if (taskOptElement.ContainsKey(idx[i]))
                {
                    long timeSpn     = task.lose_tm - muNetCleint.instance.CurServerTimeStamp;
                    bool isCurTiming = TaskTargetType.KILL_MONSTER_GIVEN == task.targetType && !task.isComplete && timeSpn > 0 && task.release_tm > timeSpn;
                    if (isCurTiming)
                    {
                        tempElem.liteMinimapTaskTimer.gameObject.SetActive(true);
                        tempElem.liteMinimapTaskTimer.text = GetSecByTime(task.lose_tm);
                        taskOptElement[tempElem.taskId].Set(isTaskMonsterAlive: true);
                    }
                    else
                    {
                        taskOptElement[tempElem.taskId].Set(isTaskMonsterAlive: false);
                        tempElem.liteMinimapTaskTimer.gameObject.SetActive(false);
                    }
                    isTiming |= isCurTiming;
                }
            }
            if (waitTime < 0)
            {
                CancelInvoke("RunTimer");
                waitTime = 5f;
                return;
            }
            if (!isTiming)
            {
                waitTime--;
            }
        }
Beispiel #2
0
        public override void init()
        {
            Instance     = this;
            tfParentWait = transform.FindChild("wait");
            tfParentWait.gameObject.SetActive(false);
            imgProcess = tfParentWait.FindChild("waitBG").GetComponent <Image>();
            (BtnWait = new BaseButton(tfParentWait.FindChild("waitBG/btnDoWait"))).onClick = OnWaitBtnClick;
            actionImage = tfParentWait.FindChild("waitBG/btnDoWait").GetComponent <Image>();
            winKillMon  = transform.FindChild("killmon").gameObject;
            winKillMon.SetActive(false);
            winKillDragon = transform.FindChild("killDragon").gameObject;
            winKillDragon.SetActive(false);
            tfSubmitItem        = transform.FindChild("submitItem");
            tfSubmitItemMainCon = tfSubmitItem.FindChild("mask/scrollview/rect");
            tfSubmitItemCon     = tfSubmitItem.FindChild("mask/scrollview/rect/con");
            tfFocus             = tfSubmitItem.FindChild("focus");
            tfFocus.gameObject.SetActive(false);
            tfSubmitItem.gameObject.SetActive(false);
            tfBtnStart = winKillMon.transform.FindChild("btnStart");
            Transform tfBtnCancel = winKillMon.transform.FindChild("btnDontStart");

            new BaseButton(tfBtnStart).onClick  = OnStartBtnClick;
            new BaseButton(tfBtnCancel).onClick = OnCancelBtnClick;
            new BaseButton(transform.FindChild("submitItem/closeBtn")).onClick = (btnClose) => tfSubmitItem.gameObject.SetActive(false);
            new BaseButton(transform.FindChild("killmon/closeArea")).onClick   = (go) => go.transform.parent.gameObject.SetActive(false);
            new BaseButton(tfSubmitItem.FindChild("btnOK")).onClick            = (go) =>
            {
                if (submitItemIId != 0 && curTaskId != 0)
                {
                    A3_TaskProxy.getInstance().SendSubmit(curTaskId, submitItemIId);
                }
                tfSubmitItem.gameObject.SetActive(false);
            };
            //transform.SetParent(skillbar.instance.transform);
            A3_TaskProxy.getInstance().addEventListener(A3_TaskProxy.ON_TASK_REFRESH, OnCheck);
            A3_TaskProxy.getInstance().addEventListener(A3_TaskProxy.ON_GET_NEW_TASK, OnCheck);

            taskOptElement = new Dictionary <int, TaskOptElement>();
            Dictionary <int, TaskData> listTask = A3_TaskModel.getInstance().GetDicTaskData();
            List <int> idx = new List <int>(listTask.Keys);

            for (int i = 0; i < idx.Count; i++)
            {
                int taskId = idx[i];
                if (listTask[taskId].release_tm > 0)
                {
                    if (listTask[taskId].lose_tm > muNetCleint.instance.CurServerTimeStamp)
                    {
                        taskOptElement[taskId] =
                            new TaskOptElement(taskId,
                                               isKeepingKillMon: true,
                                               isTaskMonsterAlive: true //,
                                                                        //timeKillTerminal: A3_TaskModel.getInstance().GetTaskDataById(taskId).lose_tm
                                               );
                        taskOptElement[taskId].InitUi(
                            liteMinimapTaskTimer: a3_liteMinimap.instance.GetTaskPage(taskId)?.transform.FindChild("name/timer").GetComponent <Text>()
                            );
                    }
                }
            }
            Instance.name         = "A3_TaskOpt";
            waitThresholdDistance = XMLMgr.instance.GetSXML("task.range").getFloat("action_range") / GameConstant.PIXEL_TRANS_UNITYPOS;
            scaleIcon             = transform.FindChild("submitItem/iconConfig")?.localScale ?? Vector3.zero;
            new BaseButton(winKillDragon.transform.FindChild("btnStart")).onClick = (go) =>
            {
                uint dragonId = A3_SlayDragonModel.getInstance().GetUnlockedDragonId();
                int  diffLv   = A3_SlayDragonModel.getInstance().GetUnlockedDiffLv();
                A3_SlayDragonProxy.getInstance().SendGo();
            };
            new BaseButton(winKillDragon.transform.FindChild("btnNope")).onClick = (go) => winKillDragon.SetActive(false);
            if (!IsInvoking("RunTimer"))
            {
                InvokeRepeating("RunTimer", 0f, 1.0f);
            }



            getComponentByPath <Text>("killmon/bg/desc").text           = ContMgr.getCont("A3_TaskOpt_0");
            getComponentByPath <Text>("killmon/btncreatteam/Text").text = ContMgr.getCont("A3_TaskOpt_1");
            getComponentByPath <Text>("killmon/btnDontStart/Text").text = ContMgr.getCont("A3_TaskOpt_2");
            getComponentByPath <Text>("killmon/btnStart/Text").text     = ContMgr.getCont("A3_TaskOpt_3");
            getComponentByPath <Text>("wait/action_text").text          = ContMgr.getCont("A3_TaskOpt_4");
            getComponentByPath <Text>("submitItem/title/Text").text     = ContMgr.getCont("A3_TaskOpt_5");
            getComponentByPath <Text>("submitItem/btnOK/text").text     = ContMgr.getCont("A3_TaskOpt_6");
            getComponentByPath <Text>("killDragon/bg/desc").text        = ContMgr.getCont("A3_TaskOpt_7");
            getComponentByPath <Text>("killDragon/btnStart/Text").text  = ContMgr.getCont("A3_TaskOpt_8");
            getComponentByPath <Text>("killDragon/btnNope/Text").text   = ContMgr.getCont("A3_TaskOpt_2");
        }