public override void Action(GameObject target) { base.Action(target); _cardAction = target.GetComponent <HeroAttack>(); _cardAction.enabled = true; }
void Die() { HeroAttack playerAttack = player.GetComponent <HeroAttack>(); playerAttack.isTargeting = false; arenaManager.gainedNotoriety += enemyStats.worthNotoriety; if (arenaManager.enemies.Contains(gameObject)) { arenaManager.enemies.Remove(gameObject); if (arenaManager.enemies.Count == 0) { Debug.Log("All enemies eliminated"); arenaManager.ActivitySuccess(); } } GetComponent <Rigidbody>().useGravity = false; enemyNav.enabled = false; GetComponent <Collider>().isTrigger = true; enemyAnim.StopPlayback(); enemyAnim.SetBool("IsDead", true); //Destroy(gameObject); }
public void ShowHeroState(HeroFightUnit hero) { healthBar.value = hero.healthValue; manaBar.value = hero.manaValue; if (healthBar.value <= 0.2) { healthBar.foregroundWidget.color = Color.red; } else if (healthBar.value > 0.2 && healthBar.value <= 0.5) { healthBar.foregroundWidget.color = new Color(1f, 0.75f, 0f, 1f); } if (hero.attack != null) { HeroAttack attack = (HeroAttack)hero.attack; if (attack.normalSkill.time != 0) { cdlabel.text = Mathf.RoundToInt(attack.normalSkill.time).ToString(); } else { cdlabel.text = string.Empty; } } if (HeadshotIcon.color.g == 0f && count == 3) { HeadshotIcon.color = Color.white; count = 0; } else if (HeadshotIcon.color.g == 0f) { count++; } }
public void InitAttack() { if (BattleFieldManager.Instance.MyPlayerIndex != 0) { _HeroAtk = BattleFieldManager.Instance.GetEntity(BattleFieldManager.Instance.MyPlayerIndex).GetComponent <HeroAttack>(); } }
private void InitHeroModel() { OrinHealth = Health; SpawnPos = transform.position; Hero_Animator = GetComponent <Animator>(); Hero_Attack = GetComponent <HeroAttack>(); Hero_Move = GetComponent <HeroMove>(); }
private void Awake() { ChangeMaterial(initMaterial); if (ally == kindOfAlly.hero) { heroAttack = GetComponentInChildren <HeroAttack>(); } }
// Start is called before the first frame update void Start() { m_FsmManager = GetComponent <FsmManager>(); FsmState <FsmTest>[] states = new FsmState <FsmTest> [3]; states[0] = new HeroRun(); states[1] = new HeroIdle(); states[2] = new HeroAttack(); m_HeroFsm = m_FsmManager.CreateFsm(this, states); m_HeroFsm.Start(typeof(HeroRun)); }
/// <summary> /// 替换头像控件绑定 /// </summary> /// <param name="oldHero"></param> /// <param name="newHero"></param> public void ReplaceHeadShot(HeroFightUnit oldHero, HeroFightUnit newHero) { HeadShotWidget headShot = HeadShotMapper[oldHero]; HeadShotMapper.Remove(oldHero); HeadShotMapper.Add(newHero, headShot); headShot.HeadshotIcon.spriteName = Util.GetConfigString(newHero.heroData.icon); headShot.SetShuxing((HurtType)newHero.heroData.element); HeroAttack attack = newHero.GetComponent <HeroAttack>(); headShot.onClick = attack.UI_UseActiveSkill; headShot.onDrag = attack.UI_UseUniqueSkill; }
/// <summary> /// 绑定英雄头像控件 /// </summary> /// <param name="unit"></param> /// <param name="i"></param> public void RegesterHeadShot(HeroFightUnit unit, int i) { string key = i + HeadShotWidget.nameExtension; HeadShotWidget headShot = (HeadShotWidget)widgetsMap[key]; HeadShotMapper.Add(unit, headShot); headShot.HeadshotIcon.spriteName = Util.GetConfigString(unit.heroData.icon); headShot.SetShuxing((HurtType)unit.heroData.element); HeroAttack attack = unit.GetComponent <HeroAttack>(); headShot.onClick = attack.UI_UseActiveSkill; headShot.onDrag = attack.UI_UseUniqueSkill; headShot.gameObject.SetActive(true); }
public void ShowHeroState(HeroFightUnit hero) { healthBar.value = hero.healthValue; manaBar.value = hero.manaValue; if (hero.attack != null) { HeroAttack attack = (HeroAttack)hero.attack; if (attack.normalSkill.time != 0) { cdlabel.text = Mathf.RoundToInt(attack.normalSkill.time).ToString(); } else { cdlabel.text = string.Empty; } } }
void enabledMoving() { this.gameObject.GetComponent <CapsuleCollider2D>().isTrigger = true; GameObject hero = GameObject.Find("main_hero"); HeroControl move = hero.GetComponent <HeroControl>(); move.enabled = false; HeroJump jump = hero.GetComponent <HeroJump>(); jump.enabled = false; HeroAttack attack = hero.GetComponent <HeroAttack>(); attack.enabled = false; }
/// <summary> /// 实例化所有作战单位 /// </summary> public void InstUnits() { HealthUIManager.instance.ResetDepth(); for (int i = 0; i < PlayerData.GetInstance().CurrentFightHero.Count; i++) { int id = PlayerData.GetInstance().CurrentFightHero[i]; string heroModelName = Encoding.Default.GetString(heroDataDic[id].model); GameObject child = AssetManager.GetGameObject(heroModelName, battle_points[i]); if (heroDataDic[id].direction == 1) { child.transform.Rotate(new Vector3(0, 180, 0)); } child.transform.parent = transform.parent; child.layer = gameObject.layer; unit = child.AddComponent <HeroFightUnit>(); fightUnits.Add(unit); unit.parentGroup = this; unit.orinPoint = battle_points[i]; //赋值战斗属性 unit.heroData = heroDataDic[id]; unit.heroEvolution = heroEvolution[110]; //假定品质1,星级0 unit.level = 1; //假定等级是1 unit.InitFightAttribute(); //赋值技能id HeroAttack heroAttack = child.GetComponent <HeroAttack>(); heroAttack.normalAttackId = (int)heroDataDic[id].attackID; heroAttack.normalSkillId = (int)heroDataDic[id].normalSkill; heroAttack.specailSkillId = (int)heroDataDic[id].specialSkill; //生成血条UI Transform healthBarPos = child.transform.Find("blood"); HealthUIManager.instance.AddNewHealthBar(fightUnits[i], healthBarPos, group == GroupType.Enemy); //绑定人物头像 ViewMapper <FightPanel> .instance.RegesterHeadShot(unit, i); unit.OnGotHit += OnHeadPicShake; anim = ViewMapper <FightPanel> .instance.HeadShotMapper[unit].anim_headpic; headcolor = ViewMapper <FightPanel> .instance.HeadShotMapper [unit].headcolor; //记录初始数值 DungeonRecord.totalHp += unit.fightAttribute.health; } /* 赋值备战单位 * 记录初始数值*/ }
/// <summary> /// 自动使用绝技 /// </summary> public void TryUseUniqueSkill() { if (FightEnergy.instance.EnergyVal < needEnergy || FightEnergy.instance.EnergyUseVal != 0 || mineGroup.fightUnits.Count == 0) { return; } List <HeroAttack> heroAttacks = new List <HeroAttack>(); for (int i = 0; i < mineGroup.fightUnits.Count; i++) { HeroAttack attack = (HeroAttack)mineGroup.fightUnits[i].attack; if (attack.specailSkill == null || attack.specailSkill.specialSkill.skillType == (uint)SkillType.Cure) { continue; } heroAttacks.Add(attack); } heroAttacks.Sort(delegate(HeroAttack a, HeroAttack b){ return(a.specailSkill.specialSkill.weight.CompareTo(b.specailSkill.specialSkill.weight)); }); int usedNum = 0; for (int i = heroAttacks.Count - 1; i >= 0; i--) { if (Random.value * 10000 <= heroAttacks[i].specailSkill.specialSkill.weight * DecisionFactorDic[usedNum + 1].factor) { if (heroAttacks[i].self.state == FightUnit.UnitState.Fighting) { usedNum++; heroAttacks[i].AutoUseUniqueSkill(); } } } if (usedNum == 0 && heroAttacks.Count > 0 && heroAttacks[0].self.state == FightUnit.UnitState.Fighting) { heroAttacks[0].AutoUseUniqueSkill(); } }
// Use this for initialization void Start() { foreach (CapsuleCollider rs in this.gameObject.GetComponentsInChildren<CapsuleCollider>()) { rs.isTrigger = true; } foreach (BoxCollider rs in this.gameObject.GetComponentsInChildren<BoxCollider>()) { rs.isTrigger = true; } foreach (SphereCollider rs in this.gameObject.GetComponentsInChildren<SphereCollider>()) { rs.isTrigger = true; } foreach (Rigidbody rs in this.gameObject.GetComponentsInChildren<Rigidbody>()) { rs.Sleep(); } currentSpeed = MoveSpeed; dead = false; defaultRot = transform.rotation; complete = false; anim = gameObject.GetComponent<Animator>(); GUI = Camera.mainCamera.GetComponent<GUIScript>(); am = GameObject.Find("FellowHeroes").GetComponent<ArmyMovement>(); ha = gameObject.GetComponent<HeroAttack>(); }
void OnEnable() { player = GameObject.FindGameObjectWithTag("Player"); heroAtk = player.GetComponent <HeroAttack>(); hookSpawn = transform.parent; }
// Start is called before the first frame update void Start() { attack = GetComponentInParent <HeroAttack>(); }