Ejemplo n.º 1
0
        void On_JoystickMove(MovingJoystick move)
        {
            float angle = move.Axis2Angle(true);

            qua  = Quaternion.Euler(new Vector3(0, angle, 0));
            wrap = QuaternionWrap.QuaternionToWrap(qua);

            string      plainText = JSON.Instance.ToJSON(wrap);
            NpcAnimInfo info      = new NpcAnimInfo()
            {
                ClientID  = DeviceInfo.GUID,
                nextState = NpcAnimState.ManualInput,
                ui        = new WarUIInfo()
                {
                    ClientID = DeviceInfo.GUID,
                    uniqueId = warCliMgr.clientTeam.activeNpc.UniqueID,
                    camp     = WarCamp2Camp.toWarCamp(warCliMgr.clientTeam.activeNpc.Camp),
                },
                data = plainText,
            };

            plainText = JSON.Instance.ToJSON(info);

            proxyServer.Move(plainText);

            if (warCliMgr.clientTeam.isAuto)
            {
                warCliMgr.clientTeam.SwitchAutoOrManual(false);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 切换激活状态的英雄
        /// </summary>
        /// <param name="index">Index.</param>
        /// <param name="SwitchOK">Switch O.</param>
        public bool SwitchActive(int index)
        {
            bool validate = false;

            bool found = team.ContainsKey(index);

            if (found)
            {
                int  wishtoID = team[index].UniqueID;
                CAMP cp       = team[index].Camp;

                bool same = wishtoID == activeNpc.UniqueID;
                validate = same ? false : true;
                if (validate)
                {
                    WarCamp wcamp = WarCamp2Camp.toWarCamp(cp);

                    SwitchInfo si = new SwitchInfo()
                    {
                        UniqueID = wishtoID,
                        ClientID = DeviceInfo.GUID,
                        camp     = wcamp,
                    };
                    string plaintext = JSON.Instance.ToJSON(si);
                    realClient.proxyServer.Switch(plaintext);
                }
            }

            return(validate);
        }
Ejemplo n.º 3
0
        //得到英雄队伍
        public List <ServerLifeNpc> GetHeroList(CAMP camp)
        {
            List <ServerLifeNpc> list = null;

            if (allHeros.TryGetValue(WarCamp2Camp.toWarCamp(camp), out list))
            {
                return(list);
            }

            ConsoleEx.DebugError("hero list is null ::  " + camp.ToString());
            return(null);
        }
Ejemplo n.º 4
0
        void On_JoystickMoveEnd(MovingJoystick move)
        {
            string      plainText = "";
            NpcAnimInfo info      = new NpcAnimInfo()
            {
                ClientID  = DeviceInfo.GUID,
                nextState = NpcAnimState.Stand,
                ui        = new WarUIInfo()
                {
                    ClientID = DeviceInfo.GUID,
                    uniqueId = warCliMgr.clientTeam.activeNpc.UniqueID,
                    camp     = WarCamp2Camp.toWarCamp(warCliMgr.clientTeam.activeNpc.Camp),
                },
                data = plainText,
            };

            plainText = JSON.Instance.ToJSON(info);
            proxyServer.MoveStop(plainText);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 切换自动和手动
        /// </summary>
        /// <returns><c>true</c>, if auto or manual was switched, <c>false</c> otherwise.</returns>
        public void SwitchAutoOrManual(bool bAuto)
        {
            if (activeNpc != null)
            {
                CAMP    cp    = activeNpc.Camp;
                WarCamp wcamp = WarCamp2Camp.toWarCamp(cp);

                ManualOrAuto ma = new ManualOrAuto()
                {
                    UniqueID = activeNpc.UniqueID,
                    ClientID = DeviceInfo.GUID,
                    camp     = wcamp,
                };

                ma.auto = (short)(bAuto == true ? 1 : 0);
                string plaintext = JSON.Instance.ToJSON(ma);
                realClient.proxyServer.ManualAuto(plaintext);
            }
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
0
        public void On_Attack_Clicked()
        {
            string      plainText = "";
            NpcAnimInfo info      = new NpcAnimInfo()
            {
                ClientID  = DeviceInfo.GUID,
                nextState = NpcAnimState.Attack,
                ui        = new WarUIInfo()
                {
                    ClientID = DeviceInfo.GUID,
                    uniqueId = warCliMgr.clientTeam.activeNpc.UniqueID,
                    camp     = WarCamp2Camp.toWarCamp(warCliMgr.clientTeam.activeNpc.Camp),
                },
                data = "",
            };

            plainText = JSON.Instance.ToJSON(info);
            proxyServer.Attack(plainText);
            if (warCliMgr.clientTeam.isAuto)
            {
                warCliMgr.clientTeam.SwitchAutoOrManual(false);
            }
        }
Ejemplo n.º 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);
                    }
                }
            }
        }