コード例 #1
0
        void StartBattle()
        {
            Dictionary <WarCamp, List <RoomCharactor> > allCharactors = realServer.monitor.CharactorPool.allCharactors;

            foreach (KeyValuePair <WarCamp, List <RoomCharactor> > itor in allCharactors)
            {
                List <RoomCharactor> list = itor.Value;
                int len = list.Count;
                for (int i = 0; i < len; i++)
                {
                    WrapperTeam          team    = list[i].team as WrapperTeam;
                    List <ServerLifeNpc> npcList = team.realTeam;
                    int npcCnt = npcList.Count;
                    for (int j = 0; j < npcCnt; j++)
                    {
                        if (realServer.monitor.CharactorPool.IsHeroActive(npcList[j]))
                        {
                            npcList[j].SwitchAutoBattle(list[i].autoBattle);
                        }
                        else
                        {
                            npcList[j].SwitchAutoBattle(true);
                        }
                    }
                }
            }

            battleStart = true;
        }
コード例 #2
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);
        }
コード例 #3
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);
        }
コード例 #4
0
        //NPC是否控制的主英雄
        public bool IsHeroActive(ServerLifeNpc npc)
        {
            WarCamp warCamp = WarCamp2Camp.toWarCamp(npc.Camp);
            List <RoomCharactor> chaList = get(warCamp);

            if (chaList != null)
            {
                int len = chaList.Count;
                for (int i = 0; i < len; i++)
                {
                    WrapperTeam team = chaList[i].team as WrapperTeam;
                    if (team.activeNpc.UniqueID == npc.UniqueID)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
コード例 #5
0
        //是否队伍中的英雄
        public bool IsTeamHero(int uniqueID)
        {
            foreach (KeyValuePair <WarCamp, List <RoomCharactor> > itor in allCharactors)
            {
                List <RoomCharactor> list = itor.Value;
                int len = list.Count;
                for (int i = 0; i < len; i++)
                {
                    WrapperTeam          team    = list[i].team as WrapperTeam;
                    List <ServerLifeNpc> npcList = team.realTeam;
                    int npcCnt = npcList.Count;
                    for (int j = 0; j < npcCnt; j++)
                    {
                        if (npcList[j].UniqueID == uniqueID)
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
コード例 #6
0
        void makeUpData(WarCamp camp)
        {
            if (camp == WarCamp.FirstCamp || camp == WarCamp.SecondCamp)
            {
                List <RoomCharactor> chalist = null;
                bool exist = allCharactors.TryGetValue(camp, out chalist);
                if (exist)
                {
                    foreach (RoomCharactor charactor in chalist)
                    {
                        if (charactor.team is WrapperTeam)
                        {
                            continue;
                        }

                        WrapperTeam wTeam = new WrapperTeam()
                        {
                            dataTeam = new List <NPCData>(),
                        };

                        foreach (RoomNpc npc in charactor.team.team)
                        {
                            NPCConfigData config = Model.get(npc.NpcNum);
                            NPCData       data   = new NPCData()
                            {
                                configData = config,
                                rtData     = new NPCRuntimeData(config),
                            };
                            wTeam.dataTeam.Add(data);
                        }
                        wTeam.team = charactor.team.team;

                        charactor.team = wTeam;
                    }
                }
            }
        }
コード例 #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);
        }
コード例 #8
0
        void CreateOneSideHero(WarCamp wc, out List <ServerLifeNpc> NpcContainer, List <CrtHero> heroList)
        {
            NpcContainer = new List <ServerLifeNpc>();

            List <RoomCharactor> OneSide = Charactors.get(wc);

            int count = OneSide.Count;

            for (int j = 0; j < count; ++j)
            {
                WrapperTeam    wrapperTeam = (WrapperTeam)OneSide[j].team;
                List <NPCData> dataTeam    = wrapperTeam.dataTeam;
                int            cnt         = dataTeam.Count;
                #if SINGLE_HERO
                cnt = 1;
                #endif

                if (dataTeam != null && cnt > 0)
                {
                    //一方出生点
                    CAMP camp = WarCamp2Camp.toCamp(wc);

                    List <ServerNPC> npcList = WarSMgr.npcMgr.GetNPCListByNum(NpcMgr <ServerNPC> .BORN_POINT, camp);

                    for (int i = 0; i < cnt; i++)
                    {
                        ServerNPC npc = virNpcLoader.Load(dataTeam[i].configData.ID, camp, WarPoint);

                        //设置出生点
                        npc.transform.position = npcList[i].transform.position;

                        npc.spawnPos = npc.transform.position;
                        npc.spawnRot = npc.transform.rotation;

                        ServerLifeNpc hero = npc as ServerLifeNpc;
                        NpcContainer.Add(hero);

                        wrapperTeam.AddNpcMember(hero, i);

                        BehaviorTree tree = hero.gameObject.AddComponent <BehaviorTree>();
                        tree.ExternalBehavior    = AiLoader.load(AILoader.PATHFIND_ATK);
                        tree.StartWhenEnabled    = true;
                        tree.RestartWhenComplete = true;

                        hero.SwitchAutoBattle(true);
                        hero.SwitchAutoBattle(false);

                        CrtHero crt = new CrtHero();
                        crt.camp     = (int)npc.Camp;
                        crt.npcID    = npc.data.configData.ID;
                        crt.uniqueId = npc.UniqueID;
                        crt.pos      = VectorWrap.ToVector(npc.transform.position);
                        crt.rotation = VectorWrap.ToVector(npc.transform.eulerAngles);
                        crt.ClientID = OneSide[j].UID;
                        crt.index    = i;

                        heroList.Add(crt);
                    }
                }
            }
        }