Exemplo n.º 1
0
 private void fire()
 {
     if (lastFire + fireWait <= Time.time && playerShipRuntime.Ammo > 0)
     {
         PlayerSpaceAmmo ammo = Instantiate(ammoPrefab);
         ammo.transform.position = transform.position + new Vector3(0.5f * dir, 0, 0);
         ammo.SetDir(dir);
         lastFire = Time.time;
         playerShipRuntime.Ammo--;
     }
 }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        dir = enemy.GetDir();
        if (enemy.GetEnemyType() == EnemyType.Military)
        {
            front.flipX = dir < 1;
            back.flipX  = dir < 1;

            if (dir > 0)
            {
                front.transform.localPosition = new Vector3(1, 0, 0);
                back.transform.localPosition  = new Vector3(0, 0, 0);
            }
            else
            {
                front.transform.localPosition = new Vector3(0, 0, 0);
                back.transform.localPosition  = new Vector3(1, 0, 0);
            }
        }
        else if (enemy.GetEnemyType() == EnemyType.Fighter)
        {
            back.flipX = dir < 1;

            if (dir > 0)
            {
                back.transform.localPosition = new Vector3(0, 0, 0);
            }
            else
            {
                back.transform.localPosition = new Vector3(1, 0, 0);
            }
        }

        if (enemy.GetShooting() && lastFire + fireWait <= Time.time)
        {
            PlayerSpaceAmmo ammo = Instantiate(ammoPrefab);
            float           x    = dir > 0 ? 1.4065f : -0.4065f;
            ammo.transform.position = transform.position + new Vector3(x, -0.2189f, 0);
            ammo.SetDir(dir);
            lastFire = Time.time;
        }
    }