void DestroyMe()
        {
            IpcDestroyNpcMsg msg = new IpcDestroyNpcMsg();

            msg.id = UniqueId;
            wmMgr.realServer.proxyCli.NpcDestroy(msg);
            Destroy(gameObject);
        }
Beispiel #2
0
 public void NpcDestroy(IpcDestroyNpcMsg msg)
 {
     AsyncTask.QueueOnMainThread(
         () => {
         int id = msg.id;
         WarClientManager mgr = WarClientManager.Instance;
         if (mgr != null)
         {
             ClientNPC npc = mgr.npcMgr.GetNpc(id);
             if (npc != null)
             {
                 WarMsgParam param = new WarMsgParam();
                 param.cmdType     = WarMsg_Type.Destroy;
                 mgr.npcMgr.SendMessageAsync(id, id, param);
             }
         }
     });
 }
Beispiel #3
0
        public void CastSk(params Object[] args)
        {
            if (castor != null && param != null)
            {
                WarSrcAnimParam srcParam = param as WarSrcAnimParam;
                if (srcParam != null)
                {
                    SelfDescribed sd = srcParam.described;
                    if (sd != null)
                    {
                        EndResult result = sd.srcEnd;
//                        float x = result.param8;
//                        float z = result.param9;
                        Vector3 pos = Vector3.zero;
//                        castor.transform.position = pos;
//                        castor.SendNpcMoveMsg(true);
                        if (castor is ServerLifeNpc)
                        {
                            ServerLifeNpc sCastor = castor as ServerLifeNpc;
                            sCastor.HitAnimReset();
                        }
                        int clearFlag = result.param1;
                        if (clearFlag == 0)
                        {
                            ServerNPC npc = castor.getOneChildNpc(result.param2);
                            if (npc != null)
                            {
                                pos   = npc.transform.position;
                                pos.y = 0.1f;
                                castor.transform.position = pos;
                                castor.SendNpcMoveMsg(true);
                                castor.removeChild(npc);
                                WarServerManager mgr = WarServerManager.Instance;
                                IpcDestroyNpcMsg msg = new IpcDestroyNpcMsg();
                                msg.id = npc.UniqueID;
                                mgr.realServer.proxyCli.NpcDestroy(msg);
                                UnityEngine.GameObject.Destroy(npc.gameObject);
                            }
                        }
                    }
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// 所有消息的处理地方
        /// </summary>
        /// <param name="msg">Message.</param>
        void HandleIpcMsg(IpcMsg msg)
        {
            if (msg != null)
            {
                switch (msg.op)
                {
                case OP.CtorMap:
                    IpcCreateMapMsg ctor = msg as IpcCreateMapMsg;
                    MapInfo         amap = new MapInfo()
                    {
                        ID   = ctor.MapId,
                        type = (ConfigType)Enum.ToObject(typeof(ConfigType), ctor.MapType),
                    };
                    CtorEnv(amap);
                    break;

                case OP.CtorNpc:
                    IpcCreateNpcMsg ctorNpc = msg as IpcCreateNpcMsg;
                    CtorNpc(ctorNpc);
                    break;

                case OP.CtorHero:
                    IpcCreateHeroMsg crtHero = msg as IpcCreateHeroMsg;
                    CtorHero(crtHero);
                    break;

                case OP.NpcMove:
                    IpcNpcMoveMsg moveMsg = msg as IpcNpcMoveMsg;
                    NPCMove(moveMsg);
                    break;

                case OP.NpcHp:
                    IpcNpcHpMsg hpMsg = msg as IpcNpcHpMsg;
                    NPChp(hpMsg);
                    break;

                case OP.NpcAnim:
                    IpcNpcAnimMsg animMsg = msg as IpcNpcAnimMsg;
                    NPCAnim(animMsg);
                    break;

                case OP.NpcStatus:
                    IpcNpcStatusMsg statusMsg = msg as IpcNpcStatusMsg;
                    NPCStatus(statusMsg);
                    break;

                case OP.ServerReady:
                    IpcServerReadyMsg SerInfo = msg as IpcServerReadyMsg;
                    ServerInfo        server  = new ServerInfo(SerInfo);
                    ServerReady(server);
                    break;

                case OP.AsyncClient:
                    IpcSyncClientMsg Sync = msg as IpcSyncClientMsg;
                    SyncClient(Sync);
                    break;

                case OP.EnterWar:
                    IpcEnterWar enter   = msg as IpcEnterWar;
                    ServerInfo  aserver = new ServerInfo()
                    {
                        ServerName = enter.ServerName,
                        ServerID   = enter.ServerID,
                    };
                    MapInfo map = new MapInfo()
                    {
                        ID   = enter.MapId,
                        type = (ConfigType)Enum.ToObject(typeof(ConfigType), enter.MapType),
                    };
                    EnterWar(aserver, map);
                    break;

                case OP.ServerQuit:
                    IpcServerQuitMsg quit = msg as IpcServerQuitMsg;
                    ServerQuit(quit.ServerID);
                    break;

                case OP.DestroyNpc:
                    IpcDestroyNpcMsg des = msg as IpcDestroyNpcMsg;
                    NpcDestroy(des);
                    break;

                case OP.SkillCD:
                    IpcSkillMsg skMsg = msg as IpcSkillMsg;
                    NpcSkillCD(skMsg);
                    break;
                }
            }
        }
Beispiel #5
0
 public void NpcDestroy(IpcDestroyNpcMsg msg)
 {
     publisher.send(msg);
 }