Beispiel #1
0
 public void UpdateHp(IpcNpcHpMsg msg)
 {
     if (animState != null)
     {
         animState.UpdateHealthValue(msg);
     }
 }
Beispiel #2
0
 //npc血量变化
 public void NPChp(IpcNpcHpMsg msg)
 {
     ConsoleEx.DebugLog(war.Side.ToString() + " Sub Received : NPChp.", ConsoleEx.YELLOW);
     AsyncTask.QueueOnMainThread(
         () => {
         int id = msg.uniqueId;
         WarClientManager mgr = WarClientManager.Instance;
         if (mgr != null)
         {
             ClientNPC npc = mgr.npcMgr.GetNpc(id);
             if (npc != null)
             {
                 npc.UpdateHp(msg);
             }
         }
     });
 }
Beispiel #3
0
        public override void OnAwake()
        {
            loader          = Core.ResEng.getLoader <VirtualNpcLoader>();
            mWarPoint       = GameObject.FindGameObjectWithTag("WarServer");
            freshGroupModel = Core.Data.getIModelConfig <FreshGroupModel>();
            freshPoolModel  = Core.Data.getIModelConfig <FreshPoolModel>();
            AiLoader        = Core.ResEng.getLoader <AILoader>();

            myHero  = gameObject.GetComponent <BNPC>();
            curPool = freshPoolModel.GetNPCFreshPool(myHero.dataInScene.freshParam.freshPoolID);

            crtMsg            = new IpcCreateNpcMsg();
            crtMsg.npclist    = new CrtHero[1];
            crtMsg.npclist[0] = new CrtHero();

            hpMsg = new IpcNpcHpMsg();
        }
Beispiel #4
0
        public override void Awake()
        {
            base.Awake();

            warServerMgr = WarServerManager.Instance;
            npcMgr       = warServerMgr.npcMgr;
            chaPool      = warServerMgr.realServer.monitor.CharactorPool;

            animMsg = new IpcNpcAnimMsg();
            hpMsg   = new IpcNpcHpMsg();
            skMsg   = new IpcSkillMsg();

            animState = gameObject.AddComponent <ServerNpcAnimState>();
            if (animState != null)
            {
                broadcast           = animState.OnNewStateReceived;
                animState.cachedNpc = this;
            }
        }
Beispiel #5
0
 public virtual void UpdateHealthValue(IpcNpcHpMsg msg)
 {
     if (health != null && msg != null && cliMgr != null)
     {
         bool isDamage = msg.isDamage;
         int  val      = msg.deltaHp;
         healthPoint = msg.curHp;
         if (msg.srcID == cliMgr.clientTeam.activeNpc.UniqueID || cliMgr.clientTeam.activeNpc.UniqueID == cachedNpc.UniqueID)
         {
             if (HitNum != null)
             {
                 Vector3 pos = cachedTran.position;
                 pos.y += 4f;
                 pos    = cliMgr.GetUIPosRef3DPos(pos);
                 HitNum(val, isDamage, false, pos);
             }
         }
         if (!isHero)
         {
             if (!health.gameObject.activeInHierarchy && healthPoint < totalPoint && healthPoint > 0)
             {
                 health.gameObject.SetActive(true);
             }
             if (health.gameObject.activeInHierarchy && healthPoint >= totalPoint)
             {
                 health.gameObject.SetActive(false);
             }
         }
         if (healthPoint > 0)
         {
             float healthVal = healthPoint / (totalPoint * 1.0f);
             health.value = healthVal;
             if (heroHealth != null)
             {
                 heroHealth.value = healthVal;
             }
         }
     }
 }
Beispiel #6
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 #7
0
 //npc血量变化
 public void NPChp(IpcNpcHpMsg msg)
 {
     publisher.send(msg);
 }