Пример #1
0
    public void ShowBattle(CharacterManager playerManager, EnemyManager enemyManager, bool isMine, AttackOrDefense attackOrDefense)
    {
        battleCamera.enabled = true;
        state = State.Start;
        this.attackOrDefense = attackOrDefense;

        Sprite playerImg = playerManager.GetCharacterInstance().charImg;
        Sprite enemyImg  = enemyManager.GetEnemyInstance().enemySprite;

        if (attackOrDefense == AttackOrDefense.Attack)
        {
            player = BattleUtil.GetPlayer(playerManager.GetCharacterInstance(), leftPlayerUI);
            enemy  = BattleUtil.GetPlayer(enemyManager.GetEnemyInstance(), rightPlayerUI);

            SetBattleUnitImg(playerImg, enemyImg);

            enemy.SwitchDice();
        }
        else
        {
            player = BattleUtil.GetPlayer(playerManager.GetCharacterInstance(), rightPlayerUI);
            enemy  = BattleUtil.GetPlayer(enemyManager.GetEnemyInstance(), leftPlayerUI);

            SetBattleUnitImg(enemyImg, playerImg);

            player.SwitchDice();
        }

        this.playerManager = playerManager;
        this.enemyManager  = enemyManager;
        this.isMine        = isMine;
    }
Пример #2
0
 protected override void OnFixedUpdate()
 {
     if (Time.frameCount % GameLibrary.mMonsterDelay != 0)
     {
         return;
     }
     base.OnFixedUpdate();
     if (backFlag)
     {
         targetCs = null;
         thisCs.SetAttackTargetTo(null);
         BackToPos();
     }
     else if (!BattleUtil.ReachPos(transform.position, defaultPos, thisCs.CharData.attrNode.chase_range))
     {
         backFlag = true;
     }
     else if (targetCs != null)
     {
         thisCs.SetAttackTargetTo(targetCs);
         if (!aiSkillHandler.NormalAISkill())
         {
             aiSkillHandler.NormalAttack();
         }
     }
     else
     {
         BackToPos();
     }
 }
Пример #3
0
 void AttackAction(CharacterState target)
 {
     // Debug.LogError(target == null ? " change to null " + Time.realtimeSinceStartup : target.name);
     if (target == null)
     {
         cs.LastAttack = null;
         return;
     }
     if (timer <= 0)
     {
         if (enabled)
         {
             if (target == cs.LastAttack && BattleUtil.IsHeroTarget(target))
             {
                 plusAttack += (plusAttack > baseAttack * 0.7f) ? 0 : baseAttack * 0.2f;
                 Formula.SetAttrTo(ref cs.CharData.buffAttrs, AttrType.attack, plusAttack);
             }
             for (int i = 0; i < pss.Length; i++)
             {
                 pss[i].Play();
             }
             emission.PlayAttackEffect("attack" + (cs.groupIndex == 0 ? "" : "0"), target.gameObject);
         }
         cs.LastAttack = target;
         timer         = 1f / cs.CharData.attrNode.attack_speed;
     }
 }
Пример #4
0
    /// <summary>
    /// 初始化 英雄数据
    /// </summary>
    void InitHeroDatas()
    {
        int           level    = playerData.GetInstance().selfData.level;
        MobaRobotNode robotCfg = FSDataNodeTable <MobaRobotNode> .GetSingleton().FindDataByType(level);

        if (!isDungeons && robotCfg != null)
        {
            List <long> randIds       = null;
            HeroData    enemyHeroData = null;
            if (!GameLibrary.isNetworkVersion)
            {
# if UNITY_EDITOR
                randIds = BattleUtil.GetRandomTeam(3, new List <long>()
                {
                    GameLibrary.player
                });
                Globe.mobaMyTeam = new HeroData[] { new HeroData(GameLibrary.player), new HeroData(randIds[0]), new HeroData(randIds[1]), new HeroData(randIds[2]) };
                Globe.mobaMyTeam[0].AddFakeEquips(robotCfg.equipment_lv, robotCfg.equipment_grade);
                enemyHeroData = new HeroData(GameLibrary.emeny);
                enemyHeroData.AddFakeEquips(robotCfg.equipment_lv, robotCfg.equipment_grade);
#endif
            }
            else
            {
                randIds = BattleUtil.GetRandomTeam(1, new List <long>()
                {
                    Globe.mobaMyTeam[0].id
                });
                enemyHeroData = new HeroData(randIds[0], robotCfg.hero_lv, robotCfg.hero_grade, robotCfg.hero_star);
                enemyHeroData.AddFakeEquips(robotCfg.equipment_lv, robotCfg.equipment_grade);
            }
            Globe.mobaEnemyTeam = new HeroData[] { enemyHeroData, null, null, null };
        }
Пример #5
0
 void CheckIfHero(CharacterState cs)
 {
     if (cs.LastAttackBy != null && BattleUtil.IsHeroTarget(cs.LastAttackBy))
     {
         AddKoInfo(Localization.Get("MobaTowerKill"), "cuihui", cs.CharData, cs.LastAttackBy.CharData, new List <CharacterData>(), MobaKOInfoType.towerKill);
     }
 }
Пример #6
0
 public static void GetRadiusRandomPos(Transform tran, Transform target, float minVal, float maxVal)
 {
     tran.position = target.transform.position;
     tran.Rotate(new Vector3(0, UnityEngine.Random.Range(0, 360), 0));
     tran.position = tran.position + tran.forward * UnityEngine.Random.Range(minVal, maxVal);
     tran.position = BattleUtil.GetNearestNavPos(tran.gameObject);
 }
Пример #7
0
 protected override void PathFinding()
 {
     currentDefendPos = GetDefendPos();
     if (BattleUtil.ReachPos(thisCs.transform.position, currentDefendPos, thisCs.pm.nav.stoppingDistance))
     {
         if (currentDefendPos != lastDefendPos)
         {
             // Debug.LogError(name + " Reach " + currentDefendPos);
             // thisCs.pm.Stop();
             lastDefendPos = currentDefendPos;
             if (defendHpRate > fleeHpRate && ReachDefendHp())
             {
                 defendHpRate -= 0.1f;
                 // Debug.LogError(name + " Change DefRate to " + defendHpRate);
             }
         }
         if (thisCs.attackTarget != null)
         {
             if (!aiSkillHandler.NormalAISkill())
             {
                 aiSkillHandler.NormalAttack();
             }
         }
         else
         {
             thisCs.pm.Stop();
         }
     }
     else
     {
         thisCs.pm.Approaching(currentDefendPos);
     }
 }
Пример #8
0
    void SetBullockCarts(long id, float lvl)
    {
        MonsterData md = new MonsterData(id, (int)lvl);

        md.groupIndex = 1;
        md.lvlRate    = lvl;
        md.state      = Modestatus.NpcPlayer;
        cartCs        = BattleUtil.AddMoveComponents(cart, md.attrNode.modelNode);
        cartCs.pm.nav.obstacleAvoidanceType = UnityEngine.AI.ObstacleAvoidanceType.NoObstacleAvoidance;
        cartCs.pm.nav.avoidancePriority     = 59;
        cartCs.InitData(md);
        BullockCarts bc = UnityUtil.AddComponetIfNull <BullockCarts>(cart);

        if (bc)
        {
            bc.OnArrDes  += () => { DungeonOverHandle(null); };
            cartCs.OnHit += bc.BeAttacked;
        }
        cartCs.OnDead   += (c) => { WinCondition(false); };
        cartCs.moveSpeed = cartCs.moveInitSpeed;
        cartCs.AddHpBar();
        AddCs(cartCs);
        if (sceneType == SceneType.KV)
        {
            GameObject prompt = new GameObject("UIPrompt");
            prompt.transform.parent        = cartCs.transform;
            prompt.transform.localPosition = new Vector3(0, 1.2f, 0);
            CDTimer.GetInstance().AddCD(0.5f, (int count, long cid) => { HUDAndHPBarManager.instance.AddPrompt(prompt.transform); });
        }
        cart.tag = "Cart";
    }
Пример #9
0
    public override CharacterState GetAttackTarget(float radius = 2f)
    {
        CharacterState target = null;
        float          disMin = float.MaxValue;

        for (int i = 0; i < SceneBaseManager.instance.agents.size; i++)
        {
            CharacterState chs = SceneBaseManager.instance.agents[i];
            if (BattleUtil.IsTargeted(thisCs, chs, radius))
            {
                float dis = Vector3.Distance(thisCs.transform.position, chs.transform.position);
                if (BattleUtil.IsHeroTarget(chs))
                {
                    target = chs;
                    break;
                }
                if (chs.state == Modestatus.Tower && chs.currentHp < 0.2f * chs.maxHp)
                {
                    target = chs;
                    break;
                }
                if (dis < disMin)
                {
                    disMin = dis;
                    target = chs;
                }
            }
        }
        return(target);
    }
Пример #10
0
 protected virtual void PathFinding()
 {
     if (currentPathPoint != null)
     {
         if (BattleUtil.ReachPos(transform.position, currentPathPoint.transform.position, thisCs.pm.nav.stoppingDistance))
         {
             thisCs.pm.Stop();
             if (waitTime > 0)
             {
                 waitTime -= Time.fixedDeltaTime;
                 if (waitTime <= 0)
                 {
                     pIndex++;
                     currentPathPoint = GetPoint(pIndex);
                     PathFinding();
                     waitTime = isPatrol ? Random.Range(0.1f, 1f) : 0.02f;
                 }
             }
         }
         else
         {
             thisCs.pm.Approaching(currentPathPoint.transform.position);
         }
     }
     else
     {
         if (isPatrol && pIndex >= autoPoints.Length)
         {
             pIndex           = 0;
             currentPathPoint = GetPoint(pIndex);
         }
         thisCs.pm.Stop();
     }
 }
Пример #11
0
    void AttackMonster(CharacterState targetTower)
    {
        CharacterState        tower   = GetEnemyTower();
        List <CharacterState> monster = new List <CharacterState>();

        if (tower == null)
        {
            return;
        }
        if (targetTower != null)
        {
            var monsterList = SceneBaseManager.instance.enemy;
            if (monster != null)
            {
                for (int i = 0; i < monsterList.size; i++)
                {
                    if (monsterList[i].state == Modestatus.Monster)
                    {
                        if (BattleUtil.ReachPos(monsterList[i], tower, tower.AttackRange))
                        {
                            monster.Add(monsterList[i]);
                        }
                    }
                }
            }
            if (monster != null)
            {
                aiSkillHandler.NormalAttack(monster[0]);
            }
        }
    }
Пример #12
0
    Vector3 RandomPos(Transform sm)
    {
        BattleUtil.GetRadiusRandomPos(sm, player.transform, 1.5f, 3f);
        pos = sm.position;

        UnityEngine.AI.NavMeshHit hit;
        bool isHit = UnityEngine.AI.NavMesh.SamplePosition(sm.position, out hit, 0.01f, UnityEngine.AI.NavMesh.AllAreas);

        if (!isHit)
        {
            RandomPos(sm);
        }

        for (int i = 0; i < spwanList.Count; i++)
        {
            if (sm == spwanList[i].transform)
            {
                continue;
            }
            if (Vector3.Distance(sm.position, spwanList[i].transform.position) < 1.5f / spwanList.Count)
            {
                RandomPos(sm);
            }
        }

        return(pos);
    }
Пример #13
0
    protected override void OnFixedUpdate()
    {
        if (!GameLibrary.Instance().CanControlSwitch(thisCs.pm))
        {
            thisCs.pm.Stop();
            return;
        }
        CharacterState minHpCS = GetMinHpCS();

        thisCs.SetAttackTargetTo(minHpCS);//GetAttackTarget(thisCs.TargetRange)
        if (thisCs.attackTarget != null)
        {
            //float dis = Vector3.Distance(transform.position, minHpCS.transform.position);
            //List<SkillNode> skillsCanUse = aiSkillHandler.GetSkillsCanUse(aiSkillHandler.skillsCDOver, (SkillNode node) => { return (node.dist > dis || node.dist == 0); }, new SkillOrderComparer());
            //if (skillsCanUse.Count > 0 && aiSkillHandler.CanSkill())
            //    aiSkillHandler.UseSkill(skillsCanUse[0]);
            //else
            //    aiSkillHandler.NormalAttack();
            // aiSkillHandler.NormalAISkill(new SkillOrderComparer());
            if (!aiSkillHandler.NormalAISkill(new SkillOrderComparer()))
            {
                aiSkillHandler.NormalAttack();
            }
        }
        else if (minHpCS != null && !BattleUtil.ReachPos(thisCs.transform.position, minHpCS.transform.position, thisCs.TargetRange))
        {
            thisCs.pm.Approaching(minHpCS.transform.position);
        }
        else
        {
            thisCs.pm.Stop();
        }
    }
Пример #14
0
    IEnumerator FlopAnim(FlopItem flopItem)
    {
        yield return(new WaitForSeconds(0.1f));

        PressEffect.SetActive(true);
        BattleUtil.PlayParticleSystems(PressEffect);
        yield return(new WaitForSeconds(1f));

        Anim1.enabled = true;
        SpLight.gameObject.SetActive(true);
        if (GameLibrary.Instance().ItemStateList.ContainsKey(flopItem.itemId))
        {
            ItemNodeState item = GameLibrary.Instance().ItemStateList[flopItem.itemId];

            Num.text        = flopItem.num.ToString();
            Name.text       = item.name;
            Icon.spriteName = item.icon_name;
            if (item.types == 6)
            {
                Icon.atlas       = ResourceManager.Instance().GetUIAtlas("UIHeroHead");
                SpTypeIcon.alpha = 1;
            }
            else
            {
                Icon.atlas       = ResourceManager.Instance().GetUIAtlas("Prop");
                SpTypeIcon.alpha = 0;
            }
            Frame.spriteName = ItemData.GetFrameByGradeType((GradeType)item.grade);
        }
    }
Пример #15
0
 void SetSummonHeroTrans(Transform summnonHeroTrans, Transform targetTrans)
 {
     //summnonHeroTrans.position = targetTrans.position - 0.3f * ( targetTrans.position - transform.position ).normalized;
     summnonHeroTrans.position = targetTrans.position + GetRandomDirPos();
     summnonHeroTrans.position = BattleUtil.GetNearestNavPos(summnonHeroTrans.gameObject);
     summnonHeroTrans.LookAt(targetTrans.transform.position);
 }
Пример #16
0
    public GameObject AddAttackEffect(string id, GameObject target, SkillNode skillNode, Transform emissionPoint = null)
    {
        string idIndex = id;

        if (skillNode != null && skillNode.site == 0 &&
            (cs.mCurMobalId == MobaObjectID.HeroXiaohei || cs.mCurMobalId == MobaObjectID.HeroChenmo))
        {
            SkillBuff buff = SkillBuffManager.GetInst().GetSkillBuffListByCs(cs).Find
                                 (a => (SkillBuffType)a.id == SkillBuffType.Talent && a.attacker == cs);
            if (buff != null)
            {
                idIndex += "_1";
            }
        }
        else if (skillNode != null && skillNode.site == 1 && cs.mCurMobalId == MobaObjectID.HeroLuosa)
        {
            SkillBuff buff = SkillBuffManager.GetInst().GetSkillBuffListByCs(cs).Find
                                 (a => (SkillBuffType)a.id == SkillBuffType.SkillTalent && a.attacker == cs);
            idIndex += buff != null ? "_2_1" : "_1_1";
        }
        GameObject effect_go = BattleUtil.AddEffectTo(GetEffectResourceRoot() + idIndex, transform, id, skillNode, cs);

        if (effect_go != null)
        {
            effect_go.transform.parent = nip.transform;
            if (emissionPoint != null)
            {
                effect_go.transform.position = emissionPoint.position;
            }
        }
        return(effect_go);
    }
Пример #17
0
    public override CharacterState GetAttackTarget(float radius = 2)
    {
        CharacterState result   = null;
        CharacterState ifPlayer = null;

        float minDis = float.MaxValue;

        for (int i = 0; i < SceneBaseManager.instance.agents.size; i++)
        {
            CharacterState chs = SceneBaseManager.instance.agents[i];
            if (null == chs)
            {
                continue;
            }
            float dis = Vector3.Distance(thisCs.transform.position, chs.transform.position);
            if (chs != null && chs.groupIndex != thisCs.groupIndex && dis < radius && !chs.Invisible && !chs.Invincible)
            {
                if (!BattleUtil.IsHeroTarget(chs) && chs.state != Modestatus.Tower && dis < minDis)
                {
                    minDis = dis;
                    result = chs;
                }
                else
                {
                    ifPlayer = chs;
                }
            }
            if (result == null && ifPlayer != null)
            {
                result = ifPlayer;
            }
        }
        return(result);
    }
Пример #18
0
    public override void InitScene()
    {
        sceneType = SceneType.KM;

        ReadTask();

        EffectBlock[] eb = GetComponentsInChildren <EffectBlock>();
        for (int i = 0; i < eb.Length; i++)
        {
            eb[i].OnCloseWall += (int num) => OnCloseWall(num);
            effectList.Add(eb[i]);
        }

        SpawnMonster[] sm = GetComponentsInChildren <SpawnMonster>();
        for (int i = 0; i < sm.Length; i++)
        {
            sm[i].isKM            = false;
            sm[i].OnCreatMonster += (GameObject go, CharacterData cd) =>
            {
                if (BattleUtil.IsBoss(cd))
                {
                    bossCs         = go.GetComponent <CharacterState>();
                    bossCs.OnDead += (CharacterState bCs) => DungeonOverHandle(bCs);
                }
            };
            spwanList.Add(sm[i]);
            if (sm[i].tag == Tag.boss)
            {
                isHaveBoss = true;
            }
            if (sm[i].distance > endSpawn)
            {
                endSpawn = (int)sm[i].distance;
            }
        }

        CreateMainHero();
        escortNPC = player;

        ThirdCamera.instance._flatAngle = GameLibrary.dungeonId > 0 ? FSDataNodeTable <SceneNode> .GetSingleton().FindDataByType(GameLibrary.dungeonId).flat_angle : 270;

        if (null != CharacterManager.instance.autos && CharacterManager.instance.autos.Length > 0)
        {
            player.transform.LookAt(CharacterManager.instance.autos[0].transform);
        }

        player.OnDead += (CharacterState pCs) =>
        {
            WinCondition(false);
            playerDeadNum++;
        };

        BrushStrange();

        base.InitScene();
    }
Пример #19
0
 void CheckAutos(float radius = 0.5f)
 {
     //寻找离你最远的怪物 如果有则去离最远的怪的路点 没有寻找离你最近的路点和下一个路点的距离选择下一个路点
     if (SceneBaseManager.instance.enemy.size > 0)
     {
         //选择最远的怪物点
         SceneBaseManager.instance.enemy.Sort((a, b) =>
         {
             float aDis = BattleUtil.V3ToV2Dis(a.transform.position, transform.position);
             float bDis = BattleUtil.V3ToV2Dis(b.transform.position, transform.position);
             return(aDis - bDis > 0 ? -1 : (aDis == bDis ? 0 : 1));
         });
         CharacterState mFartestCs = SceneBaseManager.instance.enemy[0];
         //寻找离最远怪物的最近寻路点
         mAutoPoints.Sort((a, b) =>
         {
             if (a == null || b == null)
             {
                 return(0);
             }
             float aDis = BattleUtil.V3ToV2Dis(a.transform.position, mFartestCs.transform.position);
             float bDis = BattleUtil.V3ToV2Dis(b.transform.position, mFartestCs.transform.position);
             return(aDis - bDis > 0 ? 1 : (aDis == bDis ? 0 : -1));
         });
         nextAuto = mAutoPoints[0];
     }
     else
     {
         //寻找离你最近的寻路点,且有下一个寻路点,切到下一个寻路点
         mAutoPoints.Sort((a, b) =>
         {
             if (a == null || b == null)
             {
                 return(0);
             }
             float aDis = BattleUtil.V3ToV2Dis(a.transform.position, transform.position);
             float bDis = BattleUtil.V3ToV2Dis(b.transform.position, transform.position);
             return(aDis - bDis > 0 ? 1 : (aDis == bDis ? 0 : -1));
         });
         nextAuto = mAutoPoints[0];
         int mTempIndex = -1;
         for (int i = 0; i < autoPoints.Length; i++)
         {
             if (nextAuto == autoPoints[i] && i < autoPoints.Length - 1)
             {
                 mTempIndex = i;
                 break;
             }
         }
         if (mTempIndex != -1)
         {
             nextAuto = autoPoints[mTempIndex + 1];
         }
     }
 }
Пример #20
0
 void AutoNav()
 {
     if (nextAuto != null && !BattleUtil.ReachPos(transform.position, nextAuto.transform.position, thisCs.pm.nav.stoppingDistance))
     {
         thisCs.pm.Approaching(nextAuto.transform.position);
     }
     else
     {
         thisCs.pm.Stop();
     }
 }
Пример #21
0
    Vector3 GetDefendPos()
    {
        GameObject defendTarget = null;
        float      offset       = 0f;

        if (stayinHome)
        {
            defendTarget = myHome;
        }
        else
        {
            if (ReachDefendHp())
            {
                if (mal != null && mal.isShowing)
                {
                    defendTarget = mal.gameObject;
                }
                else if (ReachFleeHp())
                {
                    defendTarget = myHome;
                }
                else
                {
                    defendTarget = (myTower != null && !myTower.isDie) ? myTower.gameObject : (myCamp != null && !myCamp.isDie ? myCamp.gameObject : null);
                    offset       = 1.2f;
                }
            }
            else
            {
                if (enemyCamp != null && !enemyCamp.isDie)
                {
                    defendTarget = enemyCamp.gameObject;
                    offset       = FriendMonsterBefore() && !AttackByTower() ? thisCs.AttackRange - 0.2f : enemyCamp.AttackRange + 0.5f;
                }
                if (enemyTower != null && !enemyTower.isDie)
                {
                    defendTarget = enemyTower.gameObject;
                    offset       = FriendMonsterBefore() && !AttackByTower() ? thisCs.AttackRange - 0.2f : enemyTower.AttackRange + 0.5f;
                }
                if (mal != null && mal.isShowing && BattleUtil.ReachPos(mal.transform.position, transform.position, 1f) && thisCs.currentHp < 0.7f * thisCs.maxHp)
                {
                    defendTarget = mal.gameObject;
                }
            }
        }
        offset *= thisCs.groupIndex == 0 ? 1f : -1f;
        if (defendTarget == null)
        {
            return(Vector3.zero);
        }
        return(new Vector3(defendTarget.transform.position.x + offset, transform.position.y, defendTarget.transform.position.z));
    }
Пример #22
0
    public void NormalAttat(HeroTemplate role)
    {
        if (role == null)
        {
            return;
        }
        float damage = BattleUtil.CalcDamage(m_damage, (float)damageInteval);

#if UNITY_EDITOR
        Debug.Log(name + "对" + role.name + "造成了" + damage + "点伤害");
#endif
        role.UnderAttact(damage);
    }
Пример #23
0
 void SetNamePos()
 {
     //if ( UICamera.mainCamera != null && rType == RoleType.otherPlayer )
     //{
     //    Vector3 tempPos = Camera.main.WorldToScreenPoint( transform.Find( "Headbuff" ).transform.position );
     //    tempPos.z = 0;
     //    OtherName.transform.position = UICamera.mainCamera.ScreenToWorldPoint( tempPos );
     //}
     if (rType == RoleType.otherPlayer)
     {
         OtherName.transform.position = BattleUtil.WorldToScreenPoint(transform.Find("Headbuff").position);
     }
 }
Пример #24
0
 public void PlayDieEffect()
 {
     if (cs.mCurMobalId == MobaObjectID.HeroShuiren)
     {
         GameObject effect_go = BattleUtil.AddEffectTo(GetEffectResourceRoot() + "die", transform);
         if (effect_go != null)
         {
             effect_go.transform.parent = nip.transform;
             effect_go.SetActive(true);
             Destroy(effect_go, 2f);
         }
     }
 }
Пример #25
0
 private void AddMeterDiffuse()
 {
     if (mDiffusePrefab == null)
     {
         mDiffusePrefab = BattleUtil.AddEffectTo(attackerCs.emission.GetEffectResourceRoot() + "skill" + mCurSkillNode.site + "_1", transform);
         mDiffusePrefab.transform.parent   = transform.parent;
         mDiffusePrefab.transform.position = mTargetPos;
         mDiffusePrefab.gameObject.SetActive(true);
         mDiffusePrefab.transform.eulerAngles = transform.eulerAngles = new Vector3(0, attackerCs.transform.eulerAngles.y, 0);
         mLongCol.size = new Vector3(mWide, mWide, mLong);
         mWideCol.size = new Vector3(mLong, mWide, mWide);
     }
 }
Пример #26
0
    void AddMonsterAI(GameObject go)
    {
        if (BattleUtil.IsBoss(monsterData))
        {
            go.tag = Tag.boss;
            UnityUtil.AddComponetIfNull <Boss_AI>(go);
        }
        else
        {
            Monster_AI mAI = null;
            switch (SceneBaseManager.instance.sceneType)
            {
            case SceneType.TP:
                mAI = UnityUtil.AddComponetIfNull <TotalPoints_AI>(go);
                break;

            case SceneType.KV:
            case SceneType.TD:
            case SceneType.ACT_GOLD:
            case SceneType.ACT_EXP:
                mAI         = UnityUtil.AddComponetIfNull <EscoerMonster_AI>(go);
                mAI.IsElite = isElite;
                break;

            case SceneType.ES:
                mAI = UnityUtil.AddComponetIfNull <ToEscape_AI>(go);
                break;

            case SceneType.MB3:
                mAI = UnityUtil.AddComponetIfNull <MonsterAI3v3>(go);
                break;

            default:
                mAI = UnityUtil.AddComponetIfNull <Monster_AI>(go);
                break;
            }

            //switch(SceneManager.GetActiveScene().name)
            //{
            //    case GameLibrary.PVP_Moba:
            //        mAI.chaseTime = 1f;
            //        mAI.backPositon = BackPosition.chaseStartPos;
            //        break;
            //    default:
            //        mAI.isBackRestore = true;
            //        mAI.backPositon = BackPosition.bornPos;
            //        break;
            //}
            mAI.autoPoints = autos;
        }
    }
Пример #27
0
    public void SetCsAttackTargetByChoseTarget(SkillNode skill, CharacterState cs)
    {
        if (SceneBaseManager.instance == null)
        {
            return;
        }
        CharacterState        target        = null;
        List <CharacterState> mCurCalTarget = GetCsAttackTargetBySkillNode(skill, cs);

        if (mCurCalTarget.Count > 0)
        {
            mCurCalTarget.Sort((a, b) =>
            {
                float aDis = Vector3.Distance(cs.transform.position, a.transform.position);
                float bDis = Vector3.Distance(cs.transform.position, b.transform.position);
                return(Mathf.FloorToInt(aDis - bDis));
            });
            switch (skill.choseTarget)
            {
            case ChoseTarget.none:
                CharacterState mCurTarget = null;
                if (cs.mCurMobalId == MobaObjectID.HeroShengqi && skill.site == 2)
                {
                    mCurCalTarget.Sort((a, b) => a.currentHp - b.currentHp);
                    mCurTarget = mCurCalTarget [0];
                }
                else
                {
                    mCurTarget = mCurCalTarget.Find(chs => BattleUtil.IsHeroTarget(chs));
                }
                target = mCurTarget == null ? mCurCalTarget[0] : mCurTarget;
                break;

            case ChoseTarget.random:
                target = mCurCalTarget[Random.Range(0, mCurCalTarget.Count)];
                break;

            case ChoseTarget.farthest:
                target = mCurCalTarget[mCurCalTarget.Count - 1];
                break;

            default:
                break;
            }
        }
        cs.SetAttackTargetTo(target);
        if (cs.state == Modestatus.Player)
        {
            CharacterManager.instance.ChangePlayerAttackTargetTo(target);
        }
    }
Пример #28
0
    public void ComeBack()
    {
        string     id      = "skill" + mCurSkillNode.site + "_1";
        GameObject comeObj = BattleUtil.AddEffectTo(mResourceRoot + id, mAttackerCs.mHitPoint);

        if (comeObj != null)
        {
            comeObj.gameObject.SetActive(true);
            comeObj.transform.parent   = transform.parent;
            comeObj.transform.position = mAttackerCs.mHitPoint.position;
            comeObj.transform.rotation = transform.rotation;
            comeObj.AddMissingComponent <EffectFollowTarget>().init(mAttackerCs, 1.0f);
        }
    }
Пример #29
0
    Vector3 getNPCHeadPos()
    {
        //NPC对象 头顶上的任务状态图标
        //Vector2 headpos;
        //得到NPC头顶在3D世界中的坐标
        //默认NPC坐标点在脚底下,所以这里加上npcHeight它模型的高度即可
        Vector3 worldPosition = new Vector3(transform.position.x, transform.position.y + npcHeight + offset, transform.position.z);

        ////根据NPC头顶的3D坐标换算成它在2D屏幕中的坐标
        //headpos = camera.WorldToScreenPoint(worldPosition);
        ////得到真实NPC头顶的2D坐标
        //headpos = UICamera.mainCamera.ScreenToWorldPoint(headpos);

        return(BattleUtil.WorldToScreenPoint(worldPosition));
    }
Пример #30
0
    void OnTriggerStay(Collider other)
    {
        CharacterState cs = other.GetComponent <CharacterState>();

        if (cs == null || !isShowing)
        {
            return;
        }
        if (cs.currentHp < cs.maxHp && BattleUtil.IsHeroTarget(cs))
        {
            cs.Hp(-Mathf.CeilToInt(0.2f * cs.maxHp), HUDType.Cure, cs.state == Modestatus.Player);
            Show(false);
            Invoke("Init", refreshTime);
        }
    }