void onNumChange(float rate)
        {
            if (!needEvent)
            {
                needEvent = true;
                return;
            }

            cur_num = (int)Math.Floor(rate * item_data.num);
            if (cur_num == 0)
            {
                cur_num = 1;
            }
            transform.FindChild("info/bodyNum/donum").GetComponent <Text>().text = cur_num.ToString();
            int value;

            if (A3_NPCShopModel.getInstance().all_float.ContainsKey(item_data.tpid))
            {
                value = (int)(A3_NPCShopModel.getInstance().all_float[item_data.tpid] * recycle_price);
                transform.FindChild("info/bodyNum/value").GetComponent <Text>().text = (value * cur_num).ToString();
            }
            else
            {
                transform.FindChild("info/bodyNum/value").GetComponent <Text>().text = (item_data.confdata.value * cur_num).ToString();
            }
        }
        private void onmax(GameObject obj)
        {
            cur_num       = item_data.num;
            num_bar.value = (float)cur_num / item_data.num;
            transform.FindChild("info/bodyNum/donum").GetComponent <Text>().text = cur_num.ToString();
            int value;

            if (A3_NPCShopModel.getInstance().all_float.ContainsKey(item_data.tpid))
            {
                value = (int)(A3_NPCShopModel.getInstance().all_float[item_data.tpid] * recycle_price);
                transform.FindChild("info/bodyNum/value").GetComponent <Text>().text = (value * cur_num).ToString();
            }
            else
            {
                transform.FindChild("info/bodyNum/value").GetComponent <Text>().text = (item_data.confdata.value * cur_num).ToString();
            }
            needEvent = false;
        }
Beispiel #3
0
        private void DealByType(TaskData taskData, bool checkItems)
        {
            A3_TaskOpt.Instance.ResetStat();
            A3_TaskOpt.Instance.Reset(alsoHideGameObject: true, resetCase: 0);
            TaskTargetType taskTargetType = taskData.targetType;
            TaskType       taskType       = taskData.taskT;

            if (A3_TaskOpt.Instance == null)
            {
                //Debug.LogError("请将A3_TaskOpt预制件默认设为Active");
                return;// not init
            }
            if (!A3_TaskOpt.Instance.taskOptElement.ContainsKey(taskData.taskId))
            {
                A3_TaskOpt.Instance.taskOptElement[taskData.taskId] = new TaskOptElement(taskData.taskId);
            }
            A3_TaskOpt.Instance.curTaskId = taskData.taskId;
            if (taskTargetType == TaskTargetType.WAIT_POINT_GIVEN /* || TaskTargetType.MESSAGE_GIVEN_POS == taskTargetType*/)
            {
                Vector3 waitPosition = Vector3.zero;
                var     pointInfo    = A3_TaskModel.getInstance().GetTaskXML().GetNode("Task", "id==" + taskData.taskId);
                //A3_TaskOpt.Instance.IsOnTaskWait = true;
                A3_TaskOpt.Instance.LockStat = false;
                if (A3_TaskOpt.Instance.isWaiting)
                {
                    A3_TaskOpt.Instance.StopCD();
                }
                A3_TaskOpt.Instance.BtnWait.interactable = true;
                A3_TaskOpt.Instance.waitPosition         = new Vector3(pointInfo.getFloat("target_coordinate_x"), 0, pointInfo.getFloat("target_coordinate_y"));
                waitPosition = A3_TaskOpt.Instance.waitPosition;
                A3_TaskOpt.Instance.actionImage.sprite = GAMEAPI.ABUI_LoadSprite("icon_task_action_" + pointInfo.getInt("act_icon"));
                A3_TaskOpt.Instance.transform.FindChild("wait/action_text").GetComponent <Text>().text = pointInfo.getString("act_name");



                #region
                PlayerModel.getInstance().task_monsterIdOnAttack[taskData.taskId] = pointInfo.getInt("target_param2");
                //InterfaceMgr.getInstance().open(InterfaceMgr.TRANSMIT_PANEL, (ArrayList)new TransmitData
                //{
                //    mapId = pointInfo.getInt("tasking_map_id"),
                //    check_beforeShow = true,
                //    handle_customized_afterTransmit = () => SelfRole.WalkToMap(pointInfo.getInt("tasking_map_id"),
                //    waitPosition),
                //    targetPosition = waitPosition
                //});
                int mapId = pointInfo.getInt("tasking_map_id");
                if (MapModel.getInstance().dicMappoint.ContainsKey(mapId))
                {
                    int mapPoint = MapModel.getInstance().dicMappoint[mapId];
                    if (GRMap.instance.m_nCurMapID != mapId && GRMap.instance.m_nCurMapID != mapPoint)
                    {
                        SelfRole.Transmit(mapPoint, () => SelfRole.WalkToMap(mapId, waitPosition, taskmove: true), taskTrans: true);
                    }
                    else
                    {
                        SelfRole.WalkToMap(mapId, waitPosition, taskmove: true);
                    }
                }
            } // endif wait given point
            else if (taskTargetType == TaskTargetType.KILL_MONSTER_GIVEN)
            {
                A3_TaskOpt.Instance.IsOnKillMon = true;
                Vector3 waitPosition = Vector3.zero;
                SXML    monInfo      = A3_TaskModel.getInstance().GetTaskXML().GetNode("Task", "id==" + taskData.taskId);

                if (monInfo != null)
                {
                    //A3_TaskOpt.Instance.IsOnKillMon = true;
                    A3_TaskOpt.Instance.LockStat = false;
                    PlayerModel.getInstance().task_monsterIdOnAttack.Add(taskData.taskId, monInfo.getInt("target_param2"));
                    A3_TaskOpt.Instance.killPosition = new Vector3(monInfo.getFloat("target_coordinate_x"), 0, monInfo.getFloat("target_coordinate_y"));
                    waitPosition = A3_TaskOpt.Instance.killPosition;
                }

                //InterfaceMgr.getInstance().open(InterfaceMgr.TRANSMIT_PANEL, (ArrayList)new TransmitData
                //{
                //    mapId = monInfo.getInt("tasking_map_id"),
                //    check_beforeShow = true,
                //    handle_customized_afterTransmit = () => SelfRole.WalkToMap(monInfo.getInt("tasking_map_id"),
                //    waitPosition),
                //    targetPosition = waitPosition
                //});
                int mapId = monInfo.getInt("tasking_map_id");
                if (MapModel.getInstance().dicMappoint.ContainsKey(mapId))
                {
                    int mapPoint = MapModel.getInstance().dicMappoint[mapId];
                    if (GRMap.instance.m_nCurMapID != mapId && GRMap.instance.m_nCurMapID != mapPoint)
                    {
                        SelfRole.Transmit(mapPoint, () => SelfRole.WalkToMap(mapId, waitPosition, taskmove: true), taskTrans: true);
                    }
                    else
                    {
                        SelfRole.WalkToMap(mapId, waitPosition, taskmove: true);
                    }
                }
            } // endif kill given monster
            else if (taskTargetType == TaskTargetType.GET_ITEM_GIVEN)
            {
                int holdNum = 0, needNum = 0;
                //A3_TaskOpt.Instance.IsOnTaskWait = true;
                Action      uiHandle        = null;
                NpcShopData npcShopData     = null;
                SXML        taskinfoGetItem = A3_TaskModel.getInstance().GetTaskXML().GetNode("Task", "id==" + taskData.taskId);

                A3_TaskOpt.Instance.taskItemId = taskinfoGetItem.getUint("target_param2");
                needNum     = taskData.completion - taskData.taskRate;//taskinfoGetItem.getInt("target_param1");
                holdNum     = a3_BagModel.getInstance().getItemNumByTpid(A3_TaskOpt.Instance.taskItemId);
                uiHandle    = () => A3_TaskOpt.Instance?.ShowSubmitItem();
                npcShopData = A3_NPCShopModel.getInstance().GetDataByItemId(A3_TaskOpt.Instance.taskItemId);
                if (holdNum >= needNum)
                {
                    int   npcId   = taskinfoGetItem.getInt("complete_npc_id");
                    int   mapId   = taskinfoGetItem.getInt("tasking_map_id");
                    SXML  npcInfo = XMLMgr.instance.GetSXML("npcs").GetNode("npc", "id==" + npcId);
                    float mapY    = npcInfo.getFloat("location_height");
                    if (mapY < 0)
                    {
                        mapY = 0;
                    }
                    Vector3 npcPos = new Vector3(npcInfo.getFloat("location_x") / GameConstant.GEZI_TRANS_UNITYPOS, mapY / GameConstant.GEZI_TRANS_UNITYPOS, npcInfo.getFloat("location_y") / GameConstant.GEZI_TRANS_UNITYPOS);
                    //InterfaceMgr.getInstance().open(InterfaceMgr.TRANSMIT_PANEL, (ArrayList)new TransmitData
                    //{
                    //    mapId = mapId,
                    //    check_beforeShow = true,
                    //    handle_customized_afterTransmit = () =>
                    //    {
                    //        SelfRole.WalkToMap(mapId, npcPos, handle: () => { A3_TaskOpt.Instance.ShowSubmitItem(); }, stopDis: 2f);
                    //    }
                    //});
                    if (MapModel.getInstance().dicMappoint.ContainsKey(mapId))
                    {
                        int mapPoint = MapModel.getInstance().dicMappoint[mapId];
                        if (GRMap.instance.m_nCurMapID != mapId && GRMap.instance.m_nCurMapID != mapPoint)
                        {
                            SelfRole.Transmit(mapPoint, () => SelfRole.WalkToMap(mapId, npcPos, () => { A3_TaskOpt.Instance.ShowSubmitItem(); }, 2f, taskmove: true), taskTrans: true);
                        }
                        else
                        {
                            SelfRole.WalkToMap(mapId, npcPos, () => { A3_TaskOpt.Instance.ShowSubmitItem(); }, 2f, taskmove: true);
                        }
                    }
                }
                else if (npcShopData != null)
                {
                    //InterfaceMgr.getInstance().open(InterfaceMgr.TRANSMIT_PANEL, (ArrayList)new TransmitData
                    //{
                    //    mapId = npcShopData.mapId,
                    //    check_beforeShow = true,
                    //    handle_customized_afterTransmit = () => SelfRole.moveToNPc(npcShopData.mapId, npcShopData.npc_id)
                    //});
                    int mapId = npcShopData.mapId;
                    if (!PlayerModel.getInstance().inFb&& mapId != GRMap.instance.m_nCurMapID && MapModel.getInstance().dicMappoint.ContainsKey(mapId) && MapModel.getInstance().dicMappoint[mapId] != GRMap.instance.m_nCurMapID)
                    {
                        SelfRole.Transmit(toid: MapModel.getInstance().dicMappoint[mapId], after: () => SelfRole.moveToNPc(mapId, npcShopData.npc_id, taskmove: true), taskTrans: true);
                    }
                    else
                    {
                        SelfRole.moveToNPc(mapId, npcShopData.npc_id, taskmove: true);
                    }
                }
                else
                {
                    if (checkItems)
                    {
                        ArrayList data = new ArrayList();
                        data.Add(a3_BagModel.getInstance().getItemDataById(A3_TaskOpt.Instance.taskItemId));
                        //data.Add(null);
                        InterfaceMgr.getInstance().ui_async_open(InterfaceMgr.A3_ITEMLACK, data);
                    }
                }
            } // endif get given item
            #endregion
        }