private void animLaserFire() { switch (attackAnimationState) { case AttackAnimationState.NeedsToStart: LaserFire.Play(); playSound(LaserFireSound); attackAnimationState = AttackAnimationState.InProgress; break; case AttackAnimationState.InProgress: LaserFire.transform.Rotate(new Vector3(0, 0, 10) * Time.deltaTime); if (LaserFire.transform.rotation.eulerAngles.z > 9 && LaserFire.transform.rotation.eulerAngles.z < 10) { LaserFire.Stop(); LaserFire.Clear(); LaserFire.transform.localRotation = initialLaserRot; currentAnimation = AnimationSequence.None; attackAnimationState = AttackAnimationState.Off; //EVERYONE DIES HAHAHAHAHAHAH targets.ForEach(t => t.Damage(AttackPower)); AnimationInProgress = false; } break; } }
void LateUpdate() { if (hitObject != null && opacity > 0.99f) { LaserFire laser = hitObject.GetComponent <LaserFire>(); if (laser != null) { laser.isFiring = true; } } }
//Collisions private void OnTriggerEnter2D(Collider2D collision) { LaserFire laser = collision.gameObject.GetComponent <LaserFire>(); //Checks if collider is LaserFire object to take damage, if less than heath, destroys. if (laser) { laser.Hit(); health -= laser.GetDamage(); Debug.Log("Player shot!!!"); if (health <= 0) { PlayerDeath(); } } }
//Collisions with this enemy private void OnTriggerEnter2D(Collider2D collision) { //gets reference to LaserFire type object if is collision LaserFire laser = collision.gameObject.GetComponent <LaserFire>(); //if not null object if (laser != null) { //calls Hit() of the laser, gets damage amount and ups the score by enemy scoreValue laser.Hit(); health -= laser.GetDamage(); scoreKeeper.Score(scoreValue); if (health <= 0) { Destroy(gameObject); AudioSource.PlayClipAtPoint(deathSound, transform.position); Debug.Log("destroyed!!!"); } } }
private void animLaserCharge() { switch (attackAnimationState) { case AttackAnimationState.NeedsToStart: LaserCharge.Play(); attackAnimationState = AttackAnimationState.InProgress; playSound(LaserChargeSound); break; case AttackAnimationState.InProgress: if (LaserCharge.time >= 2.5) { currentAnimation = AnimationSequence.LaserFire; attackAnimationState = AttackAnimationState.NeedsToStart; LaserFire.Stop(); } break; } }