void Start() { // Set up the references. source = GetComponent <AudioSource>(); player = GameObject.FindGameObjectsWithTag("Player")[0].transform; torchLight = GameObject.FindGameObjectWithTag("Spirit").GetComponent <LightFuel>(); animator = GetComponent <Animator>(); body = GetComponent <Rigidbody>(); nav = GetComponent <NavMeshAgent>(); fireball = GetComponent <SkillManager>().getSkill(SkillsID.Fireball); skillModel = fireball.model as FireballSkill; currentDamage = skillModel.damageAttack; skillModel.castTime = castingTime; // Set hurt and death reactions var health = GetComponent <HealthManager>(); health.setHurtCallback(() => { animator.SetTrigger("hurt"); if (hurtSound != null) { source.PlayOneShot(hurtSound); } }); health.setDeathCallback(() => { animator.SetTrigger("death"); if (deathSound != null) { source.PlayOneShot(deathSound); } em.CountDeath(); Destroy(gameObject, 1.5f); }); if (SceneManager.getMulti()) { multiplayer = true; player2 = GameObject.FindGameObjectsWithTag("Player")[1].transform; } currentAction = this.TryToFire; isObstacle = false; isInRange = false; isRetreating = false; //body.isKinematic = true; // start as immobile shift = UnityEngine.Random.Range(0, 2); if (shift == 0) { shift = -1; } currentShiftDistance = 0; }
void Start() { // Set up the references. source = GetComponent <AudioSource>(); player = GameObject.FindGameObjectsWithTag("Player")[0].transform; torchLight = GameObject.FindGameObjectWithTag("Spirit").GetComponent <LightFuel>(); animator = GetComponent <Animator>(); nav = GetComponent <NavMeshAgent>(); playerHealth = player.GetComponent <HealthManager>(); currentAttackDamage = baseAttackDamage; playerInRange = false; timer = timeBetweenAttacks; // Set hurt and death reactions var health = GetComponent <HealthManager>(); health.setHurtCallback(() => { animator.SetTrigger("hurt"); if (hurtSound != null) { source.PlayOneShot(hurtSound); } }); health.setDeathCallback(() => { animator.SetTrigger("death"); if (deathSound != null) { source.PlayOneShot(deathSound); } if (em != null) { em.CountDeath(); } Destroy(gameObject, 1.5f); }); if (GeneralData.multiplayer) { multiplayer = true; player2 = GameObject.FindGameObjectsWithTag("Player")[1].transform; playerHealth2 = player2.GetComponent <HealthManager>(); } }
void Start() { // Set up the references. source = GetComponent <AudioSource>(); player = GameObject.FindGameObjectWithTag("Player").transform; torchLight = GameObject.FindGameObjectWithTag("Spirit").GetComponent <LightFuel>(); animator = GetComponent <Animator>(); animator.SetBool("walk", true); nav = GetComponent <NavMeshAgent>(); moveCancelled = false; GetComponent <SphereCollider>().radius = range; // Set hurt and death reactions var health = GetComponent <HealthManager>(); health.setHurtCallback(() => { animator.SetTrigger("hurt"); if (hurtSound != null) { source.PlayOneShot(hurtSound); } }); health.setDeathCallback(() => { animator.SetTrigger("death"); if (deathSound != null) { source.PlayOneShot(deathSound); } em.CountDeath(); Destroy(gameObject, 1.5f); }); currentAction = this.FindTargets; currentFledDistance = 0; }