void OnHeroDead(CharacterState cs) { HandleKillInfo(cs); if (cs.groupIndex == 0) { ScoreBlue++; } else { ScoreRed++; } RefreshInfo(); if (cs.state == Modestatus.Player) { SceneUIManager.instance.pnReborn.ShowRebornCD(RebornCD); ThirdCamera.instance._MainPlayer = null; } int mid = cs.CharData.memberId; int pos = GetPos(cs); UILabel laReborn = rebornThumbs[pos].GetComponentInChildren <UILabel>(); CDTimer.CD cd = CDTimer.GetInstance().AddCD(1f, (int count, long id) => { if (isFinish) { return; } ChangeColorGray.Instance.ChangeSpriteColor(rebornThumbs[pos].SpHeadIcon, false); rebornThumbs[pos].LaRebornCD.text = (count - 1).ToString(); if (cs.groupIndex != CharacterManager.playerGroupIndex) { rebornThumbs[pos].gameObject.SetActive(true); } }, RebornCD); cd.OnRemove += (int count, long id) => { ChangeColorGray.Instance.ChangeSpriteColor(rebornThumbs[pos].SpHeadIcon, true); rebornThumbs[pos].LaRebornCD.text = ""; if (cs.groupIndex != CharacterManager.playerGroupIndex) { rebornThumbs[pos].gameObject.SetActive(false); } HeroAttackLine randLine = UnityEngine.Random.Range(0, 2) > 0 ? HeroAttackLine.RightLine : HeroAttackLine.leftLine; CreatHero(cs.groupIndex == 1 ? herosDataBlue[mid] : herosDataRed[mid], cs.groupIndex == 1 ? matesPos[mid].gameObject : matesPos[mid + 3].gameObject, randLine); }; }
HeroAttackLine getAtkLineById(int id) { HeroAttackLine atkLine = HeroAttackLine.none; int type = id % 2; if (type == 0) { atkLine = HeroAttackLine.leftLine; } else if (type == 1) { atkLine = HeroAttackLine.RightLine; } return(atkLine); }
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); }