Ejemplo n.º 1
0
        private void onFloat(Variant data)
        {
            ModelBase <A3_NPCShopModel> .getInstance().alltimes = data["next_tm"];

            ModelBase <A3_NPCShopModel> .getInstance().price.Clear();

            bool flag = data.ContainsKey("float_list");

            if (flag)
            {
                Variant variant = data["float_list"];
                ModelBase <A3_NPCShopModel> .getInstance().float_list.Clear();

                ModelBase <A3_NPCShopModel> .getInstance().float_list_last.Clear();

                ModelBase <A3_NPCShopModel> .getInstance().float_list_num.Clear();

                ModelBase <A3_NPCShopModel> .getInstance().limit_num.Clear();

                foreach (Variant current in variant._arr)
                {
                    bool flag2 = !ModelBase <A3_NPCShopModel> .getInstance().float_list.ContainsKey(current["item_id"]);

                    if (flag2)
                    {
                        NpcShopData npcShopData = new NpcShopData();
                        npcShopData.shop_id = current["shop_idx"]._uint;
                        bool flag3 = !ModelBase <A3_NPCShopModel> .getInstance().float_list.ContainsKey(current["item_id"]);

                        if (flag3)
                        {
                            ModelBase <A3_NPCShopModel> .getInstance().float_list.Add(current["item_id"], current["cost"]);

                            npcShopData.nowprice = current["cost"]._int;
                        }
                        bool flag4 = !ModelBase <A3_NPCShopModel> .getInstance().float_list_last.ContainsKey(current["item_id"]);

                        if (flag4)
                        {
                            ModelBase <A3_NPCShopModel> .getInstance().float_list_last.Add(current["item_id"], current["last_cost"]);

                            npcShopData.lastprice = current["last_cost"]._int;
                        }
                        bool flag5 = !ModelBase <A3_NPCShopModel> .getInstance().float_list_num.ContainsKey(current["item_id"]);

                        if (flag5)
                        {
                            ModelBase <A3_NPCShopModel> .getInstance().float_list_num.Add(current["item_id"], current["self_limit"]);
                        }
                        ModelBase <A3_NPCShopModel> .getInstance().price.Add((int)npcShopData.shop_id, npcShopData);

                        ModelBase <A3_NPCShopModel> .getInstance().limit_num.Add(current["item_id"], current["limit_num"]);
                    }
                }
                base.dispatchEvent(GameEvent.Create(A3_NPCShopProxy.EVENT_NPCSHOP_TIME, this, data, false));
            }
        }
Ejemplo n.º 2
0
        private void ReadXML()
        {
            SXML        sXML     = XMLMgr.instance.GetSXML("npc_shop", "");
            List <SXML> nodeList = XMLMgr.instance.GetSXML("npc_shop", "").GetNodeList("npc_shop", "");
            bool        flag     = nodeList != null;

            if (flag)
            {
                for (int i = 0; i < nodeList.Count; i++)
                {
                    NpcShopData npcShopData = new NpcShopData();
                    npcShopData.shop_id   = nodeList[i].getUint("shop_id");
                    npcShopData.npc_id    = nodeList[i].getInt("npc_id");
                    npcShopData.shop_name = nodeList[i].getString("shop_name");
                    string[] array = nodeList[i].getString("float_list").Split(new char[]
                    {
                        ','
                    });
                    string[] array2 = nodeList[i].getString("goods_list").Split(new char[]
                    {
                        ','
                    });
                    npcShopData.dicFloatList = new Dictionary <uint, uint>();
                    npcShopData.dicGoodsList = new Dictionary <uint, uint>();
                    for (int j = 0; j < array.Length; j++)
                    {
                        uint num;
                        bool flag2 = uint.TryParse(array[j], out num);
                        if (flag2)
                        {
                            npcShopData.dicFloatList.Add(num, sXML.GetNode("float_list", "id==" + num).getUint("item_id"));
                        }
                    }
                    for (int k = 0; k < array2.Length; k++)
                    {
                        uint num;
                        bool flag3 = uint.TryParse(array2[k], out num);
                        if (flag3)
                        {
                            npcShopData.dicGoodsList.Add(num, sXML.GetNode("goods_list", "id==" + num).getUint("item_id"));
                        }
                    }
                    npcShopData.mapId = XMLMgr.instance.GetSXML("npcs", "").GetNode("npc", "id==" + npcShopData.npc_id).getInt("map_id");
                    this.local_dicNpcShop.Add(npcShopData.npc_id, npcShopData);
                }
            }
        }
        private void ReadXML()
        {
            SXML        sxmlFloat   = XMLMgr.instance.GetSXML("npc_shop");
            List <SXML> listNpcShop = XMLMgr.instance.GetSXML("npc_shop").GetNodeList("npc_shop");

            if (listNpcShop != null)
            {
                for (int i = 0; i < listNpcShop.Count; i++)
                {
                    NpcShopData data = new NpcShopData();
                    data.shop_id   = listNpcShop[i].getUint("shop_id");
                    data.npc_id    = listNpcShop[i].getInt("npc_id");
                    data.shop_name = listNpcShop[i].getString("shop_name");
                    string[] floatList = listNpcShop[i].getString("float_list").Split(',');
                    string[] goodsList = listNpcShop[i].getString("goods_list").Split(',');
                    data.dicFloatList = new Dictionary <uint, uint>();
                    data.dicGoodsList = new Dictionary <uint, uint>();
                    uint id;
                    for (int j = 0; j < floatList.Length; j++)
                    {
                        if (uint.TryParse(floatList[j], out id))
                        {
                            data.dicFloatList.Add(id, sxmlFloat.GetNode("float_list", "id==" + id).getUint("item_id"));
                        }
                    }
                    for (int j = 0; j < goodsList.Length; j++)
                    {
                        if (uint.TryParse(goodsList[j], out id))
                        {
                            data.dicGoodsList.Add(id, sxmlFloat.GetNode("goods_list", "id==" + id).getUint("item_id"));
                        }
                    }
                    data.mapId = XMLMgr.instance.GetSXML("npcs").GetNode("npc", "id==" + data.npc_id).getInt("map_id");
                    local_dicNpcShop.Add(data.npc_id, data);
                }
            }
        }
Ejemplo n.º 4
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
        }