protected override void Init() { maxHealth = 5; hpPercWhenFlee = 0.4f; expForKilling = 10; movingStrategy = WanderingStrategy.CreateComponent(gameObject); attackingStrategy = MeleeStrategy.CreateComponent(gameObject, Vector3.up * 0.45f, 0.5f, 0.5f); base.Init(); }
public static MeleeStrategy CreateComponent(GameObject where, Vector3 attackPoint, float weaponRange = 1f, float attackRate = 1f, int attackDamage = 1) { MeleeStrategy strategy = where.AddComponent <MeleeStrategy>(); strategy.attackPoint = attackPoint; strategy.weaponRange = weaponRange; strategy.attackRate = attackRate; strategy.attackDamage = attackDamage; strategy.Start(); return(strategy); }
// Use this for initialization void Start() { transform.LookAt(GameObject.Find("Player").transform); m_player = GameObject.FindGameObjectWithTag("Player").transform; m_FireBallStrategy = GetComponent <FireBallStrategy> (); m_MeleeStrategy = GetComponent <MeleeStrategy> (); m_Movement = GetComponent <EnemyFollowerMovement> (); m_Strategy = m_FireBallStrategy; m_CanAttack = false; anim = GetComponentInChildren <Animator>(); playerMov = GameObject.Find("Player").GetComponent <PlayerMovement>(); }