Ejemplo n.º 1
0
 public void CalculateNextAnimation()
 {
     submarineState       = SubmarineState.Fighting;
     animationIndex       = Random.Range(0, 2);
     currentAnimationName = animationNames[animationIndex];
     animator.Play(currentAnimationName);
 }
Ejemplo n.º 2
0
    // 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;
        }
    }
Ejemplo n.º 3
0
 void Awake()
 {
     Singleton = this;
 }