Example #1
0
    // Update is called once per frame
    void Update()
    {
        camLeft  = Camera.main.ScreenToWorldPoint(new Vector3(0.0f, 0.0f, 100.0f));
        camRight = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, 0.0f, 100.0f));
        camTop   = Camera.main.ScreenToWorldPoint(new Vector3(0.0f, Screen.height, 100.0f));
        camBot   = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, 100.0f));

        fAttackSpeed -= Time.deltaTime;

        if (!bOnScreen && transform.position.z + 7.5f < camTop.z)
        {
            bOnScreen = true;
            phase1.SetActive(true);
        }

        if (isFlashing)
        {
            flashTimer -= Time.deltaTime;
            if (flashTimer <= 0.0f)
            {
                flashTimer = 0.05f;
                isFlashing = false;
                GetComponent <Renderer>().material = materials[0];
            }
        }

        if (GameGod.playerPos.z > transform.position.z && fAttackSpeed <= 0.0f)
        {
            Vector3 toPlayer = GameGod.playerPos;
            toPlayer -= transform.position;
            toPlayer.Normalize();
            toPlayer    *= 50.0f;
            fAttackSpeed = 0.25f;
            SpawnBullet(toPlayer);
        }

        // TODO: Remove this testing code.
        if (Input.GetKey(KeyCode.T))
        {
            nPhase         = 2;
            nCurrentHealth = (int)(nMaxHealth * .66f);
            phase3.SetActive(false);
            phase2.SetActive(true);
            phase1.SetActive(false);
        }
        if (Input.GetKey(KeyCode.U))
        {
            nPhase         = 3;
            nCurrentHealth = (int)(nMaxHealth * .33f);
            phase1.SetActive(false);
            phase2.SetActive(false);
            phase3.SetActive(true);
        }
    }