public void CalculateNextAnimation() { submarineState = SubmarineState.Fighting; animationIndex = Random.Range(0, 2); currentAnimationName = animationNames[animationIndex]; animator.Play(currentAnimationName); }
// Update is called once per frame void Update() { if (sawableSubmarine.dead) { submarineState = SubmarineState.Dead; } switch (submarineState) { case SubmarineState.Emerging: break; case SubmarineState.Fighting: if (firingTimer > firingInterval) { firingTimer = 0; //If Submarine Goes Up And Down if (animationIndex == 0) { GameObject missile = Instantiate(missilePrefab, bottomLauncher.transform.position, bottomLauncher.transform.rotation); missile.transform.parent = null; } //If Submarine Strives Left and Right else { GameObject missile = Instantiate(missilePrefab, topLauncher.transform.position, topLauncher.transform.rotation); missile.transform.parent = null; } } else { firingTimer += Time.deltaTime; } break; case SubmarineState.Dead: if (!exploded) { exploded = true; Debug.LogError("Submarine Killed"); StartCoroutine(PlayExplosions()); animator.enabled = false; submarineState = SubmarineState.AfterDead; } break; } }
void Awake() { Singleton = this; }