Example #1
0
        /// <summary>
        /// 判定某个UniqueID是否处于激活状态
        /// </summary>
        /// <returns><c>true</c>, if under active status was ised, <c>false</c> otherwise.</returns>
        /// <param name="camp">Camp.</param>
        /// <param name="UniqueID">Unique I.</param>
        public ServerLifeNpc findActionNpc(WarUIInfo switchInfo)
        {
            ServerLifeNpc activeOne = null;

            if (switchInfo != null)
            {
                WarCamp camp     = switchInfo.camp;
                string  UID      = switchInfo.ClientID;
                int     UniqueID = switchInfo.uniqueId;

                List <RoomCharactor> CharactorList = null;
                bool found = allCharactors.TryGetValue(camp, out CharactorList);
                if (found)
                {
                    RoomCharactor existC = CharactorList.Find(c => c.UID == UID);
                    if (existC != null)
                    {
                        WrapperTeam wrapperTeam = (WrapperTeam)existC.team;
                        if (wrapperTeam.activeNpc.UniqueID == UniqueID)
                        {
                            activeOne = wrapperTeam.activeNpc;
                        }
                    }
                }
            }

            return(activeOne);
        }
Example #2
0
        //退出房间
        public void QuitRoom(RoomCharactor charactor)
        {
            if (charactor != null)
            {
                string  UID  = charactor.UID;
                WarCamp camp = charactor.camp;

                List <RoomCharactor> CharactorList = null;
                bool found = allCharactors.TryGetValue(camp, out CharactorList);
                if (found)
                {
                    RoomCharactor existC = CharactorList.Find(c => c.UID == UID);
                    if (existC != null)
                    {
                        CharactorList.RemoveAt(existC.pos);

                        //resize pos
                        int cnt = CharactorList.Count;
                        for (int i = 0; i < cnt; ++i)
                        {
                            CharactorList[i].pos = i;
                        }
                    }
                }
            }
        }
Example #3
0
        //加入房间
        public void JoinRoom(RoomCharactor charactor)
        {
            if (charactor != null)
            {
                string  UID  = charactor.UID;
                WarCamp camp = charactor.camp;

                List <RoomCharactor> CharactorList = null;
                bool found = allCharactors.TryGetValue(camp, out CharactorList);
                if (found)
                {
                    RoomCharactor existC = CharactorList.Find(c => c.UID == UID);
                    if (existC == null)
                    {
                        int cnt = CharactorList.Count;
                        charactor.pos = cnt;

                        CharactorList.Add(charactor);
                    }
                }
                else
                {
                    //没有其他的玩家,so一定是0
                    charactor.pos = 0;
                    CharactorList = new List <RoomCharactor>();
                    CharactorList.Add(charactor);

                    allCharactors[camp] = CharactorList;
                }
            }
        }
Example #4
0
        /// <summary>
        /// 服务准备好了
        /// </summary>
        public void ServerReady(ServerInfo Server)
        {
            ConsoleEx.DebugLog(war.Side.ToString() + " Sub Received : Server is Ready ", ConsoleEx.YELLOW);
            //避免重复收听
            if (proxyReady == false)
            {
                proxyReady = true;
                monitor.ServerReady(Server);

                proxyServer = new ProxyServer(war, () => {
                    JoinInfo join = new JoinInfo()
                    {
                        ClientID   = DeviceInfo.GUID,
                        ClientName = "AW_Client",
                        Charactor  = war.Charactor,
                    };

                    string plainJoin = JSON.Instance.ToJSON(join);
                    proxyServer.Join(plainJoin);

                    if (war.warMo == WarMode.NativeWar)
                    {
                        RoomCharactor vir = war.Charactor.DeepCopy();
                        vir.camp          = WarCamp.SecondCamp;
                        vir.UID           = "-1";
                        vir.team          = new DebugModel().getTeam(WarCamp.SecondCamp);
                        ///
                        /// 创建虚拟Client
                        ///
                        JoinInfo virtualJoin = new JoinInfo()
                        {
                            ClientID   = "-1",
                            ClientName = "AWClient",
                            Charactor  = vir,
                        };
                        plainJoin = JSON.Instance.ToJSON(virtualJoin);
                        proxyServer.Join(plainJoin);
                    }
                });

                register();
            }             /*else {
                           *    //Test purpose
                           *    JoinInfo join = new JoinInfo() {
                           *            ClientID   = DeviceInfo.GUID,
                           *            ClientName = "AW_Client",
                           *            Charactor  = war.Charactor,
                           *    };
                           *
                           *    string plainJoin = JSON.Instance.ToJSON(join);
                           *    proxyServer.Join(plainJoin);
                           * }*/
        }
Example #5
0
        public RoomCharactor DeepCopy()
        {
            RoomCharactor rc = (RoomCharactor)this.MemberwiseClone();

            rc.team      = new Team();
            rc.team.team = new List <RoomNpc>();

            int cnt = team.team.Count;

            for (int i = 0; i < cnt; ++i)
            {
                rc.team.team.Add(team.team[i].shallowCopy());
            }

            return(rc);
        }
Example #6
0
        //切换英雄
        public bool SwitchActiveHero(SwitchInfo si)
        {
            bool ok = false;

            if (si != null)
            {
                List <RoomCharactor> CharactorList = null;
                bool found = allCharactors.TryGetValue(si.camp, out CharactorList);
                if (found)
                {
                    RoomCharactor existC = CharactorList.Find(c => c.UID == si.ClientID);
                    if (existC != null)
                    {
                        WrapperTeam wTeam = (WrapperTeam)existC.team;
                        ok = true;

                        ServerLifeNpc npc = wTeam.realTeam.Find(s => s.UniqueID == si.UniqueID);
                        wTeam.activeNpc = npc;

                        AsyncTask.QueueOnMainThread(
                            () =>
                        {
                            if (npc != null)
                            {
                                //前一个主英雄英雄切换为自动战斗
                                if (WarServerManager.Instance.battleStart)
                                {
                                    wTeam.activeNpc.SwitchAutoBattle(true);
                                }

                                if (WarServerManager.Instance.battleStart)
                                {
                                    wTeam.activeNpc.SwitchAutoBattle(existC.autoBattle);
                                }
                            }
                        }
                            );
                    }
                }
            }
            return(ok);
        }
Example #7
0
        //    切换手动和自动
        //-- 主要是切换为自动 --
        public bool SwitchManulOrAuto(ManualOrAuto ma, ref bool isAuto)
        {
            bool exist = false;

            if (ma != null)
            {
                WarCamp camp     = ma.camp;
                string  UID      = ma.ClientID;
                int     UniqueID = ma.UniqueID;

                List <RoomCharactor> CharactorList = null;
                bool found = allCharactors.TryGetValue(camp, out CharactorList);
                if (found)
                {
                    RoomCharactor existC = CharactorList.Find(c => c.UID == UID);
                    if (existC != null)
                    {
                        WrapperTeam wrapperTeam = (WrapperTeam)existC.team;
                        if (wrapperTeam.activeNpc.UniqueID == UniqueID)
                        {
                            existC.autoBattle = ma.auto == 1;
                            exist             = true;
                            isAuto            = existC.autoBattle;
                            AsyncTask.QueueOnMainThread(
                                () =>
                            {
                                wrapperTeam.activeNpc.SwitchAutoBattle(existC.autoBattle);
                            }
                                );
                        }
                    }
                }
            }

            return(exist);
        }