示例#1
0
        /// <summary>
        /// 切换主英雄之后的UI操作
        /// </summary>
        /// <param name="tran">target.</param>
        public void SwitchHero(ClientNPC npc)
        {
//            npcMgr.ActiveHero = npc;
            mainCameraFollow.SetFollowTarget(npc.transform, false);
            isSwitch = true;
            StartCoroutine(SwitchFlag());
        }
示例#2
0
        //Index is zero-based
        public ClientNPC get(int index)
        {
            ClientNPC npc   = null;
            bool      found = team.TryGetValue(index, out npc);

            return(found ? npc : null);
        }
示例#3
0
        public override void EmitEffect(ClientNPC _from, ClientNPC _target, bool _needUpdate = true)
        {
            Target                  = _target;
            Parent                  = _from;
            transform.parent        = Target.transform;
            transform.localPosition = Vector3.zero;
            ClientNpcAnimState cna = Target.animState;

            if (cna == null)
            {
                transform.localPosition = Vector3.up * 2f;
            }
            else
            {
                ed = GetComponent <EffectDef>();
                Transform cm = cna.getModelPart(ed.End);
                if (cm != null)
                {
                    transform.parent        = cm;
                    transform.localPosition = Vector3.up * 0.5f;
                }
                else
                {
                    transform.localPosition = Vector3.up * 2f;
                }
            }
//            transform.parent = Target.transform;
        }
示例#4
0
        public void NpcSkillCD(IpcSkillMsg msg)
        {
            NpcSkillAttr attr = new NpcSkillAttr()
            {
                npcId      = msg.uniqueID,
                skillIndex = msg.index,
                baseCd     = msg.baseCD,
                cdValue    = msg.baseCD,
                isInCd     = true,
            };

            AsyncTask.QueueOnMainThread(
                () =>
            {
                WarClientManager mgr = WarClientManager.Instance;
                if (mgr != null)
                {
                    ClientNPC npc = mgr.npcMgr.GetNpc(msg.uniqueID);
                    if (npc != null)
                    {
                        npc.AddSkillAttr(msg.index, attr);
                    }
                }
            }
                );
        }
示例#5
0
        public void CreateHero(IpcCreateHeroMsg msg)
        {
            int len = msg.npclist.Length;

            for (int i = 0; i < len; i++)
            {
                CrtHero   hero = msg.npclist[i];
                ClientNPC npc  = Npcloader.Load(hero.npcID, hero.uniqueId, (CAMP)hero.camp, WarPoint);

                if (npc == null)
                {
                    ConsoleEx.DebugWarning("Create npc fail!!!!!!!!!   id::  " + hero.npcID);
                    continue;
                }

                warMgr.clientTeam.filterNpc(hero, npc);

                npc.transform.localPosition    = new Vector3(hero.pos.x, hero.pos.y, hero.pos.z);
                npc.transform.localScale       = Vector3.one;
                npc.transform.localEulerAngles = new Vector3(hero.rotation.x, hero.rotation.y, hero.rotation.z);
            }

            warMgr.SwitchHero(warMgr.clientTeam.activeNpc);
            warMgr.CreateHeroFinished();
        }
示例#6
0
        public void SwitchActiveHeroSuc(ClientNPC npc)
        {
            bool found = team.ContainsValue(npc);

            if (found)
            {
                activeNpc = npc;
            }
        }
示例#7
0
        public void filterNpc(CrtHero hero, ClientNPC npc)
        {
            if (hero.ClientID == DeviceInfo.GUID)
            {
                team[hero.index] = npc;

                if (hero.index == 0)
                {
                    activeNpc = npc;
                }
            }
        }
示例#8
0
 public virtual void On_Effect(WarMsgParam param)
 {
     if (param != null)
     {
         string        m_str = param.param as string;
         NpcEffectInfo info  = JSON.Instance.ToObject <NpcEffectInfo>(m_str);
         if (info != null && info.to == cachedNpc.UniqueID)
         {
             Effect3DModelConfigData ecd = Core.Data.getIModelConfig <Effect3DModel>().get(info.hitAction);
             if (ecd != null)
             {
                 GameObject obj = null;
                 string     key = info.from + "_" + ecd.Start;
                 Debug.Log(key, gameObject);
                 if (info.Op == 0)
                 {
                     obj = WarEffectLoader.Load(ecd.Start);
                     if (obj != null)
                     {
                         obj = Instantiate(obj, cachedTran.position, cachedTran.rotation) as GameObject;
                         obj.transform.parent = cachedTran;
                         SkillEffectBase seb    = obj.GetComponent <SkillEffectBase>();
                         ClientNPC       srcNpc = cliMgr.npcMgr.GetNpc(info.from);
                         if (seb != null)
                         {
                             seb.EmitEffect(srcNpc, cachedNpc, false);
                         }
                         if (!uiEffectCache.ContainsKey(key))
                         {
                             uiEffectCache.Add(key, obj);
                         }
                     }
                     else
                     {
                         Debug.Log(string.Format("Fail to load effect obj with name:{0} from:{1} shootAction:{2}", ecd.Start, info.from));
                     }
                 }
                 else
                 {
                     if (uiEffectCache.TryGetValue(key, out obj))
                     {
                         uiEffectCache.Remove(key);
                         Destroy(obj);
                         obj = null;
                     }
                 }
             }
         }
     }
 }
示例#9
0
        public void OnHeroSelected(int id)
        {
            Debug.Log("switch to npc : " + id);
            WarClientManager mgr = WarClientManager.Instance;

            if (mgr != null)
            {
                cachedNpc = mgr.npcMgr.GetNpc(id);
                if (cachedNpc != null)
                {
                    string name = cachedNpc.data.configData.model + "_skill_" + index;
                    sprite.spriteName = name;
                    attr = cachedNpc.GetSkillAttr(index - 1);
                }
            }
        }
示例#10
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);
             }
         }
     });
 }
示例#11
0
        public void On_SwitchHero_Ok(string msg)
        {
            int id = 0;

            if (int.TryParse(msg, out id))
            {
                ClientNPC npc = warCliMgr.npcMgr.GetNpc(id);
                if (npc != null)
                {
                    warCliMgr.clientTeam.SwitchActiveHeroSuc(npc);
                    warCliMgr.SwitchHero(npc);
                }
                if (onHeroSwitch != null)
                {
                    onHeroSwitch(id);
                }
            }
        }
示例#12
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);
             }
         }
     });
 }
示例#13
0
        public void CreateNpc(IpcCreateNpcMsg msg)
        {
            int len = msg.npclist.Length;

            for (int i = 0; i < len; i++)
            {
                CrtHero   hero = msg.npclist[i];
                ClientNPC npc  = Npcloader.Load(hero.npcID, hero.uniqueId, (CAMP)hero.camp, WarPoint);
//                Debug.Log(fastJSON.JSON.Instance.ToJSON(msg));
                if (npc == null)
                {
                    ConsoleEx.DebugWarning("Create npc fail!!!!!!!!!   id::  " + hero.npcID);
                    continue;
                }

                npc.transform.localPosition    = new Vector3(hero.pos.x, hero.pos.y, hero.pos.z);
                npc.transform.localScale       = Vector3.one;
                npc.transform.localEulerAngles = new Vector3(hero.rotation.x, hero.rotation.y, hero.rotation.z);
            }
        }
示例#14
0
        public override void SetItemController(WarUI root)
        {
            rootUI             = root;
            root.onHeroSwitch += OnHeroSelected;
            WarClientManager mgr = WarClientManager.Instance;

            if (mgr != null)
            {
                ClientNPC npc = mgr.clientTeam.get(index);
                if (npc != null)
                {
                    cachedNpc = npc;
                    npc.animState.HeroHealthBar = health;
                    string name = "head_" + npc.data.configData.model;
                    head.spriteName = name;
                }
                else
                {
                    gameObject.SetActive(false);
                }
            }
        }
示例#15
0
        /// <summary>
        /// 创建npc缓存, 服务通知后创建缓存
        /// </summary>
        public void CreateNpcCache()
        {
            List <NPCInSceneData> freshPtList = GetFreshPtList();

            if (freshPtList != null && freshPtList.Count > 0)
            {
                FreshPoolModel  poolModel = Core.Data.getIModelConfig <FreshPoolModel>();
                FreshGroupModel gropModel = Core.Data.getIModelConfig <FreshGroupModel>();
                for (int i = 0; i < freshPtList.Count; i++)
                {
                    int          poolId = freshPtList [i].freshParam.freshPoolID;
                    NPCFreshPool pool   = poolModel.GetNPCFreshPool(poolId);
                    if (pool != null)
                    {
                        for (int j = 0; j < pool.freshPool.Count; j++)
                        {
                            NPCFreshGroup grop = gropModel.GetFreshGroup(pool.freshPool [j]);
                            if (grop != null)
                            {
                                for (int m = 0; m < grop.freshGroup.Count; m++)
                                {
                                    ClientNPC npcsript = Npcloader.Load(grop.freshGroup[m], -1, freshPtList[i].camp, WarPoint);

                                    npcsript.data.rtData.curHp = 0;
                                    npcsript.dataInScene       = freshPtList[i];
                                    npcsript.data.btData.way   = freshPtList[i].way;

                                    npcsript.gameObject.SetActive(false);

                                    //加入缓存中
                                    warMgr.npcMgr.SignDeadNpcCache(npcsript);
                                }
                            }
                        }
                    }
                }
            }
        }
示例#16
0
        public override void EmitEffect(ClientNPC _from, ClientNPC _target, bool _needUpdate = true)
        {
            npcPos = _target.CachedTran.position;

            length = Vector3.Distance(_from.transform.position, _target.transform.position);

            int i = 0;

            numOfPoint = (int)Mathf.Abs(length / 2) + 1;
            line.SetVertexCount(numOfPoint);

            float interval = length / (numOfPoint - 1);
            float pointZ   = 0;

            while (i < numOfPoint)
            {
                Vector3 pos = new Vector3(0.5f * Random.Range(-1f, 1f), 0.5f * Random.Range(-1f, 1f), pointZ);

                line.SetPosition(i, pos);
                i++;
                pointZ = pointZ + interval;
            }
        }
示例#17
0
        //TODO 是否要加建筑的血条

        public void CreateUIForNpc(ClientNPC npc)
        {
            if (npc != null)
            {
                GameObject obj    = null;
                bool       isHero = npc.WhatTypeOf.check(LifeNPCType.Hero);
                if (isHero)
                {
                    obj = NGUITools.AddChild(HealthRoot, HeroHealthObj);
                }
                else
                {
                    obj = NGUITools.AddChild(HealthRoot, UnitHealthObj);
                }
                obj.SetActive(true);
                UIProgressBar health = obj.GetComponent <UIProgressBar>();
                UISprite      sp     = health.foregroundWidget as UISprite;

                ClientNpcAnimState cna = npc.animState;

                if (cna != null)
                {
                    cna.HealthBar = health;
                    cna.HitNum    = GenerateHitNumber;
                }

                if (sp != null)
                {
                    if (isHero)
                    {
                        if (npc.Camp == CAMP.Player)
                        {
                            sp.spriteName = "battle-021";
                        }
                        else if (npc.Camp == CAMP.Enemy)
                        {
                            sp.spriteName = "battle-020";
                        }
                        else
                        {
                            sp.spriteName = "battle-020";
                        }
                    }
                    else
                    {
                        if (npc.Camp == CAMP.Player)
                        {
                            sp.spriteName = "battle-043";
                        }
                        else
                        {
                            sp.spriteName = "battle-044";
                        }
                    }
                }

                if (!isHero)
                {
                    obj.SetActive(false);
                }
            }
        }
示例#18
0
 public override void EmitEffect(ClientNPC _from, ClientNPC _target, bool _needUpdate = true)
 {
     From   = _from;
     Target = _target;
 }
示例#19
0
        public override void CreateEffect(NpcAnimEffect effect)
        {
            GameObject obj = null;
            string     src = "";

            switch (effect)
            {
            case NpcAnimEffect.Skill_1:
                src = curMsg.ecd.Middle;
                if (!string.IsNullOrEmpty(src) && src != "[]")
                {
                    obj = WarEffectLoader.Load(src);
                    if (obj != null)
                    {
                        obj = Instantiate(obj, attackPoint.position, cachedTran.rotation) as GameObject;
                        SkillEffectBase seb = obj.GetComponent <SkillEffectBase>();
                        if (seb != null)
                        {
                            seb.LifeTime(1f);
                            seb.EmitEffect(null, null, false);
                        }
                        else
                        {
                            Destroy(seb, 1f);
                        }
                    }
                }
                break;

            case NpcAnimEffect.Skill_2:
                src = curMsg.ecd.Middle;
                if (!string.IsNullOrEmpty(src) && src != "[]")
                {
                    obj = WarEffectLoader.Load(src);
                    if (obj != null)
                    {
                        Vector3   pos = Vector3.zero;
                        ClientNPC npc = cliMgr.npcMgr.GetNpc(curMsg.targetId);
                        if (npc != null)
                        {
                            pos = npc.CachedTran.position;
                        }
                        else
                        {
                            pos = cachedTran.position + cachedTran.rotation * Vector3.forward * 5f;
                        }
                        obj = Instantiate(obj, pos, cachedTran.rotation) as GameObject;
                        Destroy(obj, 3f);
                    }
                }
                break;

            case NpcAnimEffect.Skill_3:
                src = curMsg.ecd.Middle;
                if (!string.IsNullOrEmpty(src) && src != "[]")
                {
                    obj = WarEffectLoader.Load(src);
                    if (obj != null)
                    {
                        obj = Instantiate(obj, cachedTran.position, cachedTran.rotation) as GameObject;
                        if (obj != null)
                        {
                            ClientNPC       npc = cliMgr.npcMgr.GetNpc(curMsg.targetId);
                            SkillEffectBase seb = obj.GetComponent <SkillEffectBase>();
                            if (npc != null && seb != null)
                            {
                                Vector3 dir = npc.transform.position;
                                dir.y = cachedTran.position.y;
                                dir   = dir - cachedTran.position;
                                Quaternion rot = Quaternion.LookRotation(dir, Vector3.up);
                                obj.transform.rotation = rot;
                                seb.EmitEffect(cachedNpc, npc, false);
                            }
                            Destroy(obj, 0.2f);
                        }
                    }
                }
                break;

            default:
                base.CreateEffect(effect);
                break;
            }
        }
示例#20
0
 public override void EmitEffect(ClientNPC _from, ClientNPC _target, bool _needUpdate = true)
 {
     tran   = transform;
     inited = true;
 }