private void OnRoleDieCallBack(RoleCtrl ctrlTemp)
 {
     if (ctrlTemp.CurRoleType == RoleType.Hero)
     {
         HeroPlatform platform = GetHeroPlatform(ctrlTemp.CurRoleInfo.RoleId);
         platform.RefreshRoleId(0);
         RemoveHero(ctrlTemp);
         if (HeroList.Count <= 0)
         {
             m_LevelProcedure.ChangeState(LevelProcedure.Fail);
         }
     }
     else
     {
         if (MonsterList.Contains(ctrlTemp))
         {
             MonsterList.Remove(ctrlTemp);
             if (MonsterList.Count <= 0)
             {
                 m_LevelProcedure.ChangeState(LevelProcedure.Win);
             }
         }
         else
         {
             Debug.LogError("错误;角色被已经被移除了");
         }
     }
     ctrlTemp.OnRoleDie -= OnRoleDieCallBack;
 }
        public void Init(RoleCtrl master, int skillType, int range)
        {
            Master = master;
            if (m_CellPoolList == null)
            {
                m_CellPoolList = new List <GameObject>();
            }
            if (m_CellList == null)
            {
                m_CellList = new List <GameObject>();
            }

            List <Vector2> posArr = GameSceneCtrl.Instance.GetPositionsByShape(skillType, Vector2.zero, range);

            for (int i = 0; i < posArr.Count; i++)
            {
                GameObject go = null;
                if (m_CellPoolList.Count > 0)
                {
                    go = m_CellPoolList[0];
                    m_CellPoolList.RemoveAt(0);
                    go.SetActive(true);
                }
                else
                {
                    go = ResourcesMrg.Instance.Load(ResourcesMrg.ResourceType.Scene, "Items/SkillCell", isCache: true);
                }
                go.transform.SetParent(this.transform);
                go.transform.localPosition = posArr[i];
            }
        }
        public void ReplaceHero(RoleCtrl source, HeroPlatform target)
        {
            if (ForwardHeroList.Contains(source))
            {
                if (ForwardHeroPlatformList.Contains(target))
                {
                    return;
                }
                ForwardHeroList.Remove(source);
                BackwardHeroList.Add(source);
            }
            else if (BackwardHeroList.Contains(source))

            {
                if (BackwardHeroPlatformList.Contains(target))
                {
                    return;
                }
                BackwardHeroList.Remove(source);
                ForwardHeroList.Add(source);
            }
            else
            {
                Debug.Log("错误:还没有加入");
            }
        }
Пример #4
0
 public void Used(RoleCtrl hero)
 {
     if (HeroToUsed.ContainsKey(hero))
     {
         if (HeroToUsed[hero])
         {
             Debug.Log("错误:这个英雄已经使用过了");
         }
         else
         {
             HeroToUsed[hero] = true;
             bool isOver = true;
             foreach (var item in HeroToUsed)
             {
                 if (!item.Value)
                 {
                     isOver = false;
                 }
             }
             if (isOver)
             {
                 //等1.5秒钟,等角色攻击完,伤害结算完
                 Invoke("RoundEnd", 1.5f * Time.timeScale);
             }
         }
     }
     else
     {
         Debug.Log("错误:使用了已经移除了的英雄");
     }
 }
Пример #5
0
 protected override void Attack()
 {
     m_AttackTimer -= Time.deltaTime;
     if (m_AttackTimer < 0)
     {
         for (int i = 0; i < m_PhyCtroller.ForwardHitsStorage.Length; i++)
         {
             if (m_PhyCtroller.ForwardHitsStorage[i].distance > 0)
             {
                 RoleCtrl ctrl = m_PhyCtroller.ForwardHitsStorage[i].collider.GetComponent <RoleCtrl>();
                 if (ctrl != null)
                 {
                     ctrl.ToHurt(m_AttackImpuse, true);
                     m_AttackTimer = m_AttackInterval;
                     return;
                 }
             }
         }
         for (int i = 0; i < m_PhyCtroller.BackwardHitsStorage.Length; i++)
         {
             if (m_PhyCtroller.BackwardHitsStorage[i].distance > 0)
             {
                 RoleCtrl ctrl = m_PhyCtroller.BackwardHitsStorage[i].collider.GetComponent <RoleCtrl>();
                 if (ctrl != null)
                 {
                     ctrl.ToHurt(m_AttackImpuse, true);
                     m_AttackTimer = m_AttackInterval;
                     return;
                 }
             }
         }
     }
 }
        //在平台上创建英雄
        public void CreateHero(long roleId, Vector2 screenPos)
        {
            HeroInfo info = Global.HeroInfoList.Find(x => x.RoleId == roleId);

            if (info != null)
            {
                HeroEntity heroEntity = HeroDBModel.Instance.Get(info.HeroID);
                GameObject go         = RoleMgr.Instance.LoadRole(RoleType.Hero, heroEntity.PrefabName);
                RoleCtrl   ctrl       = go.GetComponent <RoleCtrl>();
                ctrl.Init(RoleType.Hero, info, null);
                HeroPlatform platform = GetHeroPlatformByScreenPos(screenPos);
                platform.RefreshRoleId(ctrl.CurRoleInfo.RoleId);
                ctrl.RefreshPlatfrom(platform);
                ctrl.StandOnPlatfrom();
                go.transform.position = platform.transform.TransformPoint(platform.StandPos);
                bool inFoward = ForwardHeroPlatformList.Contains(platform);
                if (inFoward)
                {
                    AddHero(ctrl, true);
                }
                else
                {
                    AddHero(ctrl, false);
                }
                ctrl.OnRoleDestory += OnRoleDestoryCallBack;
                ctrl.OnRoleDie     += OnRoleDieCallBack;
                return;
            }
            Debug.Log("错误:在模拟服务器上找不到持有的英雄信息");
        }
        //替换平台上的英雄
        public void ReplaceHeroOnPlatform(long sourceRoleId, long targetRole, Vector2 screenPos)
        {
            RoleCtrl ctrl = GetHero(sourceRoleId);

            DestroyImmediate(ctrl.gameObject);
            CreateHero(targetRole, screenPos);
        }
        //交换平台上的英雄
        public void SwapHeroOnPlatfrom(long sourceRoleId, long targetRoleId)
        {
            RoleCtrl sourcrRole = GetHero(sourceRoleId);
            RoleCtrl targetRole = GetHero(targetRoleId);

            HeroPlatform sourcrePlatform = GetHeroPlatform(sourceRoleId);
            HeroPlatform targetPlatform  = GetHeroPlatform(targetRoleId);

            if (sourcrRole == null || targetRole == null || sourcrePlatform == null || targetPlatform == null)
            {
                Debug.LogError("错误");
                return;
            }


            ReplaceHero(sourcrRole, targetPlatform);
            ReplaceHero(targetRole, sourcrePlatform);

            sourcrePlatform.RefreshRoleId(targetRole.CurRoleInfo.RoleId);
            targetPlatform.RefreshRoleId(sourcrRole.CurRoleInfo.RoleId);

            sourcrRole.RefreshPlatfrom(targetPlatform);
            sourcrRole.StandOnPlatfrom();
            targetRole.RefreshPlatfrom(sourcrePlatform);
            targetRole.StandOnPlatfrom();
        }
Пример #9
0
 /// <summary>
 /// 增加角色
 /// </summary>
 /// <param name="roleCtrl"></param>
 public void AddRole(RoleCtrl roleCtrl)
 {
     if (RoleCtrlList == null)
     {
         RoleCtrlList = new List <RoleCtrl>();
     }
     RoleCtrlList.Add(roleCtrl);
 }
        //创建怪物
        private void CreateMonster()
        {
            //if (m_CurrentCreateCount > 0) return;
            List <GameLevelMonsterEntity> gameLevelMonsterEntityList = GameLevelMonsterDBModel.Instance.GetMonsterListByLevelAndGeade(CurLevel, CurGrade);

            for (int i = 0; i < gameLevelMonsterEntityList.Count; i++)
            {
                if (String.IsNullOrEmpty(gameLevelMonsterEntityList[i].SpriteRowAndCol))
                {
                    continue;
                }
                string[] rowAndColArr = gameLevelMonsterEntityList[i].SpriteRowAndCol.Split('|');
                for (int j = 0; j < rowAndColArr.Length; j++)
                {
                    SpriteEntity spriteEntity = SpriteDBModel.Instance.GetSpriteEntityById(gameLevelMonsterEntityList[i].SpriteId);
                    if (spriteEntity != null)
                    {
                        GameObject go = RoleMgr.Instance.LoadRole(RoleType.Monster, spriteEntity.PrefabName);
                        if (go != null)
                        {
                            RoleCtrl ctrl = go.GetComponent <RoleCtrl>();
                            if (ctrl != null)
                            {
                                ctrl.OnRoleDie     = OnRoleDieCallBack;
                                ctrl.OnRoleDestory = OnRoleDestoryCallBack;

                                MonsterInfo info = new MonsterInfo(spriteEntity);
                                info.RoleId       = ++m_TempIndex;
                                info.RoleNickName = spriteEntity.Name;
                                info.Level        = spriteEntity.Level;
                                info.MaxHP        = spriteEntity.Hp;
                                info.CurrentHP    = info.MaxHP;
                                info.PhyAtk       = spriteEntity.PhyAtk;
                                info.MgicAtk      = spriteEntity.MgicAtk;
                                info.PhyDef       = spriteEntity.PhyDef;
                                info.MgicDef      = spriteEntity.MgicDef;
                                info.Cri          = spriteEntity.Cri;
                                info.CriValue     = spriteEntity.CriValue;
                                info.SpriteEntity = spriteEntity;
                                ctrl.AttackRange  = spriteEntity.AttackRange;
                                ctrl.MoveStep     = spriteEntity.MoveCellCount;
                                //位置赋值
                                string[] arr  = rowAndColArr[j].Split('_');
                                int      row  = arr[0].ToInt();
                                int      col  = arr[1].ToInt();
                                Node     node = GridManager.Instance.GetNode(row, col);
                                ctrl.transform.position = node.Position;
                                ctrl.Init(RoleType.Monster, info, new MonsterAI(ctrl, info));
                                BormMonsterCount++;
                                MonsterList.Add(ctrl);
                            }
                        }
                    }
                }
            }
        }
Пример #11
0
 protected override void Attack()
 {
     m_AttackTimer -= Time.deltaTime;
     for (int i = 0; i < m_PhyCtroller.AboveHitsStorge.Length; i++)
     {
         if (m_PhyCtroller.AboveHitsStorge[i].distance > 0)
         {
             if (m_AttackTimer < 0)
             {
                 RoleCtrl player = m_PhyCtroller.AboveHitsStorge[i].collider.GetComponent <RoleCtrl>();
                 if (player != null)
                 {
                     player.ToHurt(m_AttackImpuse);
                     m_AttackTimer = m_AttackInterval;
                     return;
                 }
             }
         }
     }
     if (!IsAboveAttack)
     {
         for (int i = 0; i < m_PhyCtroller.ForwardHitsStorage.Length; i++)
         {
             if (m_PhyCtroller.ForwardHitsStorage[i].distance > 0)
             {
                 if (m_AttackTimer < 0)
                 {
                     RoleCtrl player = m_PhyCtroller.ForwardHitsStorage[i].collider.GetComponent <RoleCtrl>();
                     if (player != null)
                     {
                         player.ToHurt(m_AttackImpuse);
                         m_AttackTimer = m_AttackInterval;
                         return;
                     }
                 }
             }
         }
         for (int i = 0; i < m_PhyCtroller.BackwardHitsStorage.Length; i++)
         {
             if (m_PhyCtroller.BackwardHitsStorage[i].distance > 0)
             {
                 if (m_AttackTimer < 0)
                 {
                     RoleCtrl player = m_PhyCtroller.BackwardHitsStorage[i].collider.GetComponent <RoleCtrl>();
                     if (player != null)
                     {
                         player.ToHurt(m_AttackImpuse);
                         m_AttackTimer = m_AttackInterval;
                         return;
                     }
                 }
             }
         }
     }
 }
Пример #12
0
        private void OnTriggerEnter2D(Collider2D collision)
        {
            RoleCtrl ctrl = collision.GetComponent <RoleCtrl>();

            if (ctrl != null)
            {
                ctrl.AddHp();
                Destroy(this.gameObject);
                EazySoundManager.PlaySound(Clip);
            }
        }
 private void OnHeroAttackCallBack(object[] p)
 {
     if (GameSceneCtrl.Instance.GetLevelProcedure.CurState == LevelProcedure.Player)
     {
         RoleCtrl role    = (RoleCtrl)p[0];
         int      skillId = (role.IsRage ? ((HeroInfo)role.CurRoleInfo).SkillList[1] : ((HeroInfo)role.CurRoleInfo).SkillList[0]).SkillId;
         role.ToAttack(AttackType.SkillAttack, skillId);
         m_DragSkillItem.Hide();
         m_DragSkillItem.transform.position = Vector3.one * 2000;
         GameSceneCtrl.Instance.HeroFaction.Used(role);
     }
 }
 public void AddHero(RoleCtrl ctrl, bool forward)
 {
     if (forward)
     {
         ForwardHeroList.Add(ctrl);
     }
     else
     {
         BackwardHeroList.Add(ctrl);
     }
     HeroList.Add(ctrl);
 }
 private void OnRoleDestoryCallBack(Transform obj)
 {
     if (m_LevelProcedure.CurState == LevelProcedure.HeroEditor)
     {
         RoleCtrl roleCtrl = obj.GetComponent <RoleCtrl>();
         if (roleCtrl.CurRoleType == RoleType.Hero)
         {
             HeroPlatform platform = GetHeroPlatform(roleCtrl.CurRoleInfo.RoleId);
             platform.RefreshRoleId(0);
             RemoveHero(roleCtrl);
         }
     }
 }
        //刷新英雄平台
        public void RefreshHeroPlatform(long roleId, HeroPlatform platfrom)
        {
            RoleCtrl     role           = GetHero(roleId);
            HeroPlatform sourcePlatform = GetHeroPlatform(roleId);

            ReplaceHero(role, platfrom);

            sourcePlatform.RefreshRoleId(0);
            platfrom.RefreshRoleId(role.CurRoleInfo.RoleId);

            role.RefreshPlatfrom(platfrom);
            role.StandOnPlatfrom();
        }
        private RoleCtrl RayCastRoleCtr(Vector2 pos)
        {
            RaycastHit2D hit = Physics2D.Raycast(pos, Vector2.up, 0.05f);

            if (hit.collider != null)
            {
                RoleCtrl ctrl = hit.collider.GetComponent <RoleCtrl>();
                if (ctrl != null)
                {
                    return(ctrl);
                }
            }
            return(null);
        }
        public void RemoveHero(long roleId)
        {
            RoleCtrl ctrl = HeroList.Find(x => x.CurRoleInfo.RoleId == roleId);

            if (ctrl == null)
            {
                Debug.LogError("错误:找不到英雄");
                return;
            }
            else
            {
                RemoveHero(ctrl);
            }
        }
 //origin 是根据Node的position值
 public List <RoleCtrl> SearchEnemys(Vector2 origin, int skillType, int range)
 {
     m_EnemyList.Clear();
     m_AttackPosList.Clear();
     m_AttackPosList = GameSceneCtrl.Instance.GetPositionsByShape(skillType, origin, range);
     for (int i = 0; i < m_AttackPosList.Count; i++)
     {
         RoleCtrl role = RayCastRoleCtr(m_AttackPosList[i]);
         if (role != null)
         {
             m_EnemyList.Add(role);
         }
     }
     return(m_EnemyList);
 }
Пример #20
0
 public RoleFSMMgr(RoleCtrl roleCtrl, Action onDestory, Action onDie)
 {
     this.CurRoleCtrl = roleCtrl;
     states           = new Dictionary <RoleState, RoleStateAbstract>();
     //装载状态
     //states.Add(RoleState.Idle, new RoleStateIdle(this));
     //states.Add(RoleState.Run, new RoleStateRun(this));
     //states.Add(RoleState.Attack, new RoleStateAttack(this));
     //states.Add(RoleState.Hurt, new RoleStateHurt(this));
     //states.Add(RoleState.Die, new RoleStateDie(this));
     //states.Add(RoleState.Select, new RoleStateSelect(this));
     if (states.ContainsKey(CurrentRoleStateEnum))
     {
         CurrentRoleState = states[CurrentRoleStateEnum];
     }
 }
Пример #21
0
 private void OnTriggerStay2D(Collider2D collision)
 {
     m_AttackTimer -= Time.deltaTime;
     if (m_AttackTimer < 0)
     {
         m_IsAttack = true;
     }
     if (m_IsAttack)
     {
         RoleCtrl ctrl = collision.GetComponent <RoleCtrl>();
         if (ctrl != null)
         {
             ctrl.ToHurt(m_AttackImpuse);
             m_IsAttack    = false;
             m_AttackTimer = m_AttackInterval;
         }
     }
 }
        public RoleCtrl GetHeroByScreenPos(Vector2 screenPos)
        {
            Vector3 worldPos = Camera.main.ScreenToWorldPoint(screenPos);

            RaycastHit2D[] hits = Physics2D.RaycastAll(worldPos, Vector2.up, 0.01f);
            for (int i = 0; i < hits.Length; i++)
            {
                if (hits[i].collider != null)
                {
                    RoleCtrl h = hits[i].collider.GetComponent <RoleCtrl>();
                    if (h != null)
                    {
                        return(h);
                    }
                }
            }
            return(null);
        }
        //英雄脱离战场
        private void OnSceneLevelFightCallBack(object[] p)
        {
            RoleCtrl ctrl     = (RoleCtrl)p[0];
            Vector3  scenePos = (Vector3)p[1];

            HeroPlatform platform = GameSceneCtrl.Instance.GetHeroPlatformByScreenPos(scenePos);

            //依然在平台内
            if (platform != null)
            {
                SetGameObjectLayer(ctrl.gameObject, "Role", 0);
                ctrl.transform.SetParent(null);
                if (platform.RoleId != 0)
                {
                    //替换
                    GameSceneCtrl.Instance.SwapHeroOnPlatfrom(ctrl.CurRoleInfo.RoleId, platform.RoleId);
                }
                else
                {
                    //刷新
                    GameSceneCtrl.Instance.RefreshHeroPlatform(ctrl.CurRoleInfo.RoleId, platform);
                }
            }
            else
            {
                //在UI内
                RectTransform rect       = ((UIGameSceneView)UISceneCtrl.Instance.CurrentUIScene).HeroGridRect;
                bool          inHeroGrid = RectTransformUtility.RectangleContainsScreenPoint(rect, scenePos, UISceneCtrl.Instance.CurrentUIScene.UICamera);
                if (inHeroGrid)
                {
                    //移除这个战斗英雄
                    SimulatedDatabase.Instance.RemoveFightHero(ctrl.CurRoleInfo.RoleId);
                    GameObject.DestroyImmediate(ctrl.gameObject);
                    UpdateAllHeroInfo();
                }
                else
                {
                    //复原
                    SetGameObjectLayer(ctrl.gameObject, "Role", 0);
                    ctrl.transform.SetParent(null);
                    ctrl.StandOnPlatfrom();
                }
            }
        }
        private RoleTransferAttackInfo CalculationHurtValue(AttackType attackType, RoleCtrl enemy, SkillEntity skillEntity, SkillLevelEntity skillLevelEntity)
        {
            RoleTransferAttackInfo attackInfo = new RoleTransferAttackInfo();

            attackInfo.AttackRoleID   = m_Role.CurRoleInfo.RoleId;
            attackInfo.BeAttaclRoleID = enemy.CurRoleInfo.RoleId;
            attackInfo.IsCri          = false;
            float damage = 0;

            if (attackType == AttackType.PhyAttack)
            {
                damage = m_Role.CurRoleInfo.PhyAtk - enemy.CurRoleInfo.PhyDef;
            }
            else
            {
                attackInfo.SkillId    = skillEntity.Id;
                attackInfo.SkillLevel = skillLevelEntity.Level;
                //物理系攻击
                if (skillEntity.SkillType == 0)
                {
                    damage = m_Role.CurRoleInfo.PhyAtk * skillLevelEntity.HurtValueRate - enemy.CurRoleInfo.PhyDef;
                }
                else
                {
                    //魔法系攻击
                    damage = m_Role.CurRoleInfo.MgicAtk * skillLevelEntity.HurtValueRate - enemy.CurRoleInfo.MgicDef;
                }
                damage /= 10;
                bool isCri = Random.Range(1, 101) < m_Role.CurRoleInfo.Cri;
                attackInfo.IsCri = isCri;
                if (isCri)
                {
                    damage *= m_Role.CurRoleInfo.CriValue;
                }
                if (damage <= 0)
                {
                    damage = 1;
                }
            }
            attackInfo.HurtValue = (int)damage;
            return(attackInfo);
        }
        private void CreatePlayer()
        {
            string     path = string.Format("Player{0}/Player{0}", Global.Instance.UserInfo.CurJob.ToString());
            GameObject go   = ResourcesMgr.Instance.Load(ResourcesMgr.ResourceType.Role, "Player/" + path);

            go.transform.position   = PlayerBornPos.transform.position;
            go.transform.rotation   = PlayerBornPos.transform.rotation;
            go.transform.localScale = Vector3.one;
            m_Player = go.GetComponent <RoleCtrl>();
            switch (Global.Instance.UserInfo.CurJob)
            {
            default:
                m_Player.Init(null, 3);
                break;
            }
            m_Player.OnRoleJumpToNextFloor = OnRoleJumpToNextFloor;
            m_Player.OnRoleDie             = OnRoleDead;
            m_Player.OnRoleHurt            = OnRoleHurt;
            m_Player.OnRoleAddHp           = OnRoleAddHp;
        }
 public void RemoveHero(RoleCtrl ctrl)
 {
     if (ForwardHeroList.Contains(ctrl))
     {
         ForwardHeroList.Remove(ctrl);
     }
     else
     {
         if (BackwardHeroList.Contains(ctrl))
         {
             BackwardHeroList.Remove(ctrl);
         }
         else
         {
             Debug.LogError("错误:找不到英雄");
             return;
         }
     }
     HeroList.Remove(ctrl);
 }
        //开始技能拖拽
        private void OnBeginDragTheSkillCallBack(object[] p)
        {
            long    roleId  = (long)p[0];
            Vector2 rolePos = (Vector3)p[1];
            Vector2 minPos  = Vector2.zero;
            float   minDis  = Mathf.Infinity;

            //从第一列中找最近的点
            for (int i = 0; i < GridManager.Instance.NumOfRow; i++)
            {
                Node  n   = GridManager.Instance.GetNode(i, 0);
                float dis = Vector2.Distance(rolePos, n.Position);
                if (dis < minDis)
                {
                    minDis = dis;
                    minPos = n.Position;
                }
            }
            if (m_DragSkillItem == null)
            {
                m_DragSkillItem = ResourcesMrg.Instance.Load(ResourcesMrg.ResourceType.Scene, "Items/DragSkillItem").GetComponent <DragSkillItem>();
                m_DragSkillItem.transform.SetParent(null);
                m_DragSkillItem.transform.localScale = Vector3.one;
            }
            m_DragSkillStartRelaticvePos       = minPos - rolePos;
            m_DragSkillItem.transform.position = minPos;
            RoleCtrl role = GameSceneCtrl.Instance.GetHero(roleId);

            if (role == null)
            {
                Debug.LogError("错误:");
                return;
            }
            HeroInfo heroInfo = Global.HeroInfoList.Find(x => x.RoleId == roleId);

            SkillEntity skillEntity = SkillDBModel.Instance.Get((role.IsRage ? heroInfo.SkillList[1] : heroInfo.SkillList[0]).SkillId);

            m_DragSkillItem.Init(role, skillEntity.AttackArea, skillEntity.AttackRange);
        }
        private bool CheckHeroAndPlatformNoDifference(long roleId, bool forward)
        {
            RoleCtrl heroTemp = HeroList.Find(x => x.CurRoleInfo.RoleId == roleId);

            if (heroTemp == null)
            {
                Debug.Log("错误:没有这个英雄");
                return(false);
            }
            if (forward)
            {
                HeroPlatform forwardPlatform = ForwardHeroPlatformList.Find(x => x.RoleId == roleId);
                RoleCtrl     hero            = ForwardHeroList.Find(x => x.CurRoleInfo.RoleId == roleId);
                if (hero == null || forwardPlatform == null)
                {
                    Debug.Log("错误:平台和英雄 不一致");
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            else
            {
                HeroPlatform forwardPlatform = BackwardHeroPlatformList.Find(x => x.RoleId == roleId);
                RoleCtrl     hero            = BackwardHeroList.Find(x => x.CurRoleInfo.RoleId == roleId);
                if (hero == null || forwardPlatform == null)
                {
                    Debug.Log("错误:平台和英雄 不一致");
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
        }
Пример #29
0
        public void Init(RoleCtrl master, string effectName, List <RoleCtrl> enemyList, List <Vector2> posList)
        {
            m_SingleEffectList = new List <GameObject>();

            m_EnemyList        = enemyList;
            m_PosList          = posList;
            m_EffectName       = effectName;
            m_EffectSingleName = m_EffectName + "_Single";
            m_Master           = master;
            if (ShowOne)
            {
                //通用只显示一个特效的位置
                Vector2 totalPos = Vector2.zero;
                for (int i = 0; i < posList.Count; i++)
                {
                    totalPos += posList[i];
                }
                m_ShowOnePos = totalPos / posList.Count;
                CreateSingleEffect(m_ShowOnePos);
            }
            else
            {
                if (NeedTarget)
                {
                    for (int i = 0; i < enemyList.Count; i++)
                    {
                        CreateSingleEffect(enemyList[i].transform.position);
                    }
                }
                else
                {
                    for (int i = 0; i < posList.Count; i++)
                    {
                        CreateSingleEffect(posList[i]);
                    }
                }
            }
        }
        public RoleCtrl GetHero(long roleId)
        {
            RoleCtrl ctrl = ForwardHeroList.Find(x => x.CurRoleInfo.RoleId == roleId);

            if (ctrl == null)
            {
                ctrl = BackwardHeroList.Find(x => x.CurRoleInfo.RoleId == roleId);
                if (ctrl == null)
                {
                    Debug.Log("错误:英雄不存在");
                    return(null);
                }
                else
                {
                    CheckHeroAndPlatformNoDifference(roleId, false);
                }
            }
            else
            {
                CheckHeroAndPlatformNoDifference(roleId, true);
            }
            return(ctrl);
        }