Пример #1
0
    void AddHeroAIs(CharacterState cs)
    {
        BasePlayerAI ai = AddHeroAIBySceneType(cs);

        if (ai != null)
        {
            if (cs.groupIndex == 1 && cs.CharData.memberId == 0)
            {
                ai.enabled = false;
            }
            else
            {
                ai.enabled       = true;
                cs.pm.isAutoMode = true;
            }
        }
    }
Пример #2
0
    public void SwitchAutoMode(bool isAuto)
    {
        if (SceneUIManager.instance != null)
        {
            SceneUIManager.instance.autoFight.SetActive(isAuto);
            ResetAutoFightEffect(SceneUIManager.instance.autoFight.transform);
        }
        if (FightTouch._instance != null)
        {
            FightTouch._instance.autoBattleEffect.SetActive(isAuto);
        }

        if (!PlayerAlive())
        {
            return;
        }
        BasePlayerAI ai = player.GetComponent <BasePlayerAI>();

        if (ai != null)
        {
            ai.enabled = isAuto;
            if (isAuto)
            {
                AISkillHandler aisHandler = player.GetComponent <AISkillHandler>();
                if (aisHandler != null && FightTouch._instance != null)
                {
                    aisHandler.SetSkills(playerCS.GetSkills(), GetCds());
                }
            }
        }
        if (playerMotion.isAutoMode != isAuto)
        {
            playerMotion.isAutoMode  = isAuto;
            playerMotion.nav.enabled = false;
            playerMotion.nav.enabled = true;
            if (!isAuto)
            {
                playerMotion.Stop();
            }
        }
    }
Пример #3
0
    CharacterState CreatHero(HeroData data, GameObject parGo, HeroAttackLine atkLine)
    {
        CharacterState cs = null;

        data.useServerAttr = false;
        data.RefreshAttr();
        if (data.groupIndex == 1)
        {
            if (data.state == Modestatus.Player)
            {
                cs = CreateMainHero(data).GetComponent <CharacterState>();
            }
            else if (data.state == Modestatus.NpcPlayer)
            {
                cs = CreateBattleHero(data, parGo).GetComponent <CharacterState>();
            }
            cs.AddHpBar(true);
            cs.pm.moveAreaMask = 1 | 1 << (int)NavAreas.BlueHeroPass;
        }
        else if (data.groupIndex == 0)
        {
            cs = CreateBattleHero(data, parGo).GetComponent <CharacterState>();
            cs.CharData.groupIndex = 0;
            cs.AddHpBar(true);
            cs.gameObject.tag  = "EnemyPlayer";
            cs.pm.moveAreaMask = 1 | 1 << (int)NavAreas.RedHeroPass;
        }
        if (cs != null)
        {
            BasePlayerAI ai = AddHeroAIBySceneType(cs);
            if (cs.groupIndex == 1 && cs.CharData.memberId == 0)
            {
                ai.enabled = false;
            }
            else
            {
                ai.enabled = true;
            }
        }
        cs.OnHelp     += TowerHelp;
        cs.OnDead     += OnHeroDead;
        cs.OnDead     += ChangeMorale;
        cs.OnDamageBy += (CharacterState mcs, CharacterState attackerCs) =>
        {
            if (BattleUtil.IsHeroTarget(attackerCs))
            {
                RefreshAttackedHeroRecords(mcs.CharData, attackerCs.CharData);
            }
            else if (attackerCs.state == Modestatus.SummonHero && attackerCs.Master != null)
            {
                RefreshAttackedHeroRecords(mcs.CharData, attackerCs.Master.CharData);
            }
        };
        cs.moveSpeed = cs.moveInitSpeed = 0.75f * cs.moveInitSpeed;
        cs.InitHp(cs.maxHp);
        cs.atkLine = atkLine;

        if (MobaMiniMap.instance != null)
        {
            MobaMiniMap.instance.AddMapIconByType(cs);
        }

        return(cs);
    }