Example #1
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);
            }
        }
Example #2
0
        public void ManualAuto(string autoInfo)
        {
            ManualOrAuto auto = JSON.Instance.ToObject <ManualOrAuto>(autoInfo);

            processedMsg = new NetMQMessage();

            bool isAuto = false;
            bool ok     = monitor.CharactorPool.SwitchManulOrAuto(auto, ref isAuto);

            if (ok)
            {
                processedMsg.Append(WarMsgConsts.ManualOrAutoRep);
                processedMsg.Append(isAuto ? "1" : "0");


                //如果战斗开始了,切换AI
                if (WarServerManager.Instance.battleStart)
                {
                    WarUIInfo ui = new WarUIInfo();
                    ui.camp     = auto.camp;
                    ui.ClientID = auto.ClientID;
                    ui.uniqueId = auto.UniqueID;

                    ServerLifeNpc npc = monitor.CharactorPool.findActionNpc(ui);

                    //TODO : switch AI
                    AsyncTask.QueueOnMainThread(() => {
                        if (npc != null)
                        {
                            npc.SwitchAutoBattle(isAuto);
                        }
                    });
                }
            }
            else
            {
                processedMsg.Append(WarMsgConsts.ManualOrAutoRepE);
            }
        }
Example #3
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);
        }