IEnumerator FireBullet()
    {
        while (true)
        {
            // Check every 0.2 seconds if shoot button is pressed
            yield return(new WaitForSeconds(0.15f));

            if (isFiring)
            {
                _bulletSound.Play();

                //TODO: this code needs to change to user the BulletPoolManager's
                if (bulletType == 1)
                {
                    nextBullet = BulletPoolManager.getInstance().GetBullet();
                    nextBullet.transform.position = bulletSpawn.transform.position;
                    nextBullet.SetActive(true);
                }
                else if (bulletType == 2)
                {
                    nextBullet = BulletPoolManager.getInstance().GetBullet2();
                    nextBullet.transform.position = bulletSpawn.transform.position;
                    nextBullet.SetActive(true);
                }


                //TODO: bullet object.
                //TODO: Ensure you position the new bullet at the bulletSpawn position
            }
        }
    }
示例#2
0
 public void loadLevel(int level)
 {
     States.gamePhaseGuiEnabled = true;
     States.inPauseMenu         = false;
     clearStorage();
     BulletPoolManager.getInstance().initialize();
     MisslePoolManager.getInstance().initialize();
     UnityEngine.SceneManagement.SceneManager.LoadScene(Templates.getInstance().getLevel((int)States.currentCampaign.levels[level]).file);
 }
示例#3
0
    public void STEP()
    {
        if (!exploded)
        {
            foreach (Templates.GunOnShuttle gun in planeTemplate.guns)
            {
                gunTemp = Templates.getInstance().getGunTemplate(gun.gunId);
                if (!gun.ready)
                {
                    if (gun.shotTime + gunTemp.reuse < Time.time)
                    {
                        gun.ready = true;
                    }
                }

                enemy = GameStorage.getInstance().getFriendlyInFireZone(this, gun);
                if (gun.ready && enemy != null)
                {
                    f = Quaternion.Euler(0, 0, -gameObject.transform.eulerAngles.y) * gun.pos;
                    BulletPoolManager.getInstance().shotBullet(BulletSide.ENEMY, new Vector3(transform.position.x + f.x, 5, transform.position.z + f.y), enemy.transform.position, gunTemp.damage, gunTemp.bulletSpeed, gunTemp.gunType, gunTemp.attackRange, gunTemp.bulletDispersion);
                    gun.ready    = false;
                    gun.shotTime = Time.time;
                }
            }

            if (underGas)
            {
                if (Time.time >= lastGasBurned + Abilities.GasParameters.gasReuse)
                {
                    Attacked(Abilities.GasParameters.gasDamage);
                    lastGasBurned = Time.time;
                }
            }

            t       += 1f / 151f;
            x        = (1 - t) * (1 - t) * (1 - t) * point1.x + 3 * (1 - t) * (1 - t) * t * point2.x + 3 * (1 - t) * t * t * point3.x + t * t * t * point4.x;
            y        = (1 - t) * (1 - t) * (1 - t) * point1.y + 3 * (1 - t) * (1 - t) * t * point2.y + 3 * (1 - t) * t * t * point3.y + t * t * t * point4.y;
            tmpVec.x = x;
            tmpVec.y = 5;
            tmpVec.z = y;

            v2tmp1.x = x - transform.position.x;
            v2tmp1.y = y - transform.position.z;
            v2tmp2   = new Vector2(0, 5);
            f1tmp    = (v2tmp2.x * v2tmp1.y - v2tmp2.y * v2tmp1.x);
            f2tmp    = Vector2.Angle(v2tmp2, v2tmp1);
            if (f1tmp > 0)
            {
                f2tmp = (180 - f2tmp) + 180;
            }
            transform.eulerAngles = new Vector3(270, f2tmp, 0);
            fortestAngle          = f2tmp;

            transform.position = tmpVec;
        }
    }
    private void CheckBounds()
    {
        if (transform.position.y >= boundary.Top)
        {
            //TODO: This code needs to change to use the BulletPoolManager's
            //TODO: ResetBullet function which will return the bullet to the pool

            BulletPoolManager.getInstance().ResetBullet2(this.gameObject);
        }
    }
示例#5
0
 private void Accelerates()
 {
     GameStorage.getInstance().processExplode();
     if (States.WorldRunning)
     {
         GameStorage.getInstance().AccelerateAllUnits();
         BulletPoolManager.getInstance().stepAllBullets();
         MisslePoolManager.getInstance().MoveRocketsAndThorpeds();
         if (Time.time >= GameStorage.getInstance().getEndTime())
         {
             States.WorldRunning = false;
             GameStorage.getInstance().toggleOnStepEnd();
         }
     }
 }
示例#6
0
 void initBullets()
 {
     foreach (Templates.GunOnShuttle gun in planeTemplate.guns)
     {
         gunTemp = Templates.getInstance().getGunTemplate(gun.gunId);
         if (gunTemp.gunType == BulletType.GUN_SMALL_BULLET)
         {
             BulletPoolManager.getInstance().createPoolObjs(BulletType.GUN_SMALL_BULLET, 15);
         }
         else if (gunTemp.gunType == BulletType.GUN_MID_BULLET)
         {
             BulletPoolManager.getInstance().createPoolObjs(BulletType.GUN_MID_BULLET, 10);
         }
         else if (gunTemp.gunType == BulletType.GUN_LARGE_BULLET)
         {
             BulletPoolManager.getInstance().createPoolObjs(BulletType.GUN_LARGE_BULLET, 10);
         }
     }
 }
示例#7
0
    public void toggleOnStepEnd()
    {
        BulletPoolManager.getInstance().clearAllActiveBullets();
        foreach (FriendlySpaceship obj in friendlySpaceships)
        {
            obj.onStepEnd();
            obj.showAttackIcon();
        }
        foreach (EnemySpaceship obj in enemySpaceships)
        {
            obj.onStepEnd();
        }

        clearRemoveLists();
        if (friendlySpaceships.Count == 0 || enemySpaceships.Count == 0)
        {
            CalculateWinLose();
        }

        MisslePoolManager.getInstance().ToggleOnStepEnd();

        checkZalpButtonState();
    }
    public void STEP()
    {
        if (!exploded)
        {
            if (!Abilities.getLockGun(activeAbil))
            {
                foreach (Templates.GunOnShuttle gun in planeTemplate.guns)
                {
                    gunTemp = Templates.getInstance().getGunTemplate(gun.gunId);
                    if (!gun.ready)
                    {
                        if (gun.shotTime + gunTemp.reuse < Time.time)
                        {
                            gun.ready = true;
                        }
                    }

                    enemy = GameStorage.getInstance().getEnemyInFireZone(this, gun);
                    if (gun.ready && enemy != null)
                    {
                        //SHOT PROCEDURE WITH POOLING
                        f = Quaternion.Euler(0, 0, -gameObject.transform.eulerAngles.y) * gun.pos;
                        BulletPoolManager.getInstance().shotBullet(BulletSide.FRIENDLY, new Vector3(transform.position.x + f.x, 5, transform.position.z + f.y), enemy.transform.position, gunTemp.damage, gunTemp.bulletSpeed, gunTemp.gunType, gunTemp.attackRange, gunTemp.bulletDispersion);
                        gun.ready    = false;
                        gun.shotTime = Time.time;
                    }
                }
            }

            if (underGas)
            {
                if (Time.time >= lastGasBurned + Abilities.GasParameters.gasReuse)
                {
                    Attacked(Abilities.GasParameters.gasDamage);
                    lastGasBurned = Time.time;
                }
            }

            t           += 1f / 151f;
            x            = (1 - t) * (1 - t) * (1 - t) * point1.x + 3 * (1 - t) * (1 - t) * t * point2.x + 3 * (1 - t) * t * t * point3.x + t * t * t * point4.x;
            y            = (1 - t) * (1 - t) * (1 - t) * point1.y + 3 * (1 - t) * (1 - t) * t * point2.y + 3 * (1 - t) * t * t * point3.y + t * t * t * point4.y;
            tmpVec.x     = x;
            tmpVec.y     = 5;
            tmpVec.z     = y;
            curDistance += Vector3.Distance(forDist, tmpVec);
            if (activeAbil == Abilities.AbilityType.halfRoundTurn)
            {
                f2tmp = transform.eulerAngles.y + abilRandonRotateDirection * 180 * Time.fixedDeltaTime / 3;
            }
            else if (activeAbil == Abilities.AbilityType.turnAround)
            {
                f2tmp = transform.eulerAngles.y + abilRandonRotateDirection * 360 * Time.fixedDeltaTime / 3;
            }
            else
            {
                v2tmp1.x = x - transform.position.x;
                v2tmp1.y = y - transform.position.z;
                v2tmp2   = new Vector2(0, 5);
                f1tmp    = (v2tmp2.x * v2tmp1.y - v2tmp2.y * v2tmp1.x);
                f2tmp    = Vector2.Angle(v2tmp2, v2tmp1);
                if (f1tmp > 0)
                {
                    f2tmp = (180 - f2tmp) + 180;
                }
            }

            if (activeAbil == Abilities.AbilityType.homingMissle && t >= 0.5f && !rocketLaunched)
            {
                MisslePoolManager.getInstance().LaunchRocket(MissleSide.FRIENDLY, this);
                rocketLaunched = true;
            }
            else if (activeAbil == Abilities.AbilityType.homingThorpede && t >= 0.5f && !rocketLaunched)
            {
                MisslePoolManager.getInstance().LaunchThorpede(MissleSide.FRIENDLY, this);
                rocketLaunched = true;
            }
            else if (activeAbil == Abilities.AbilityType.gas)
            {
                if (curDistance >= gasLastSpawnDist)
                {
                    MisslePoolManager.getInstance().LaunchGas(MissleSide.FRIENDLY, this);
                    gasLastSpawnDist = curDistance + Abilities.GasParameters.betweenDist;
                }
            }
            else if (activeAbil == Abilities.AbilityType.mines)
            {
                if (curDistance >= gasLastSpawnDist)
                {
                    MisslePoolManager.getInstance().LaunchMine(MissleSide.FRIENDLY, this);
                    gasLastSpawnDist = curDistance + Abilities.MinesParameters.betweenDist;
                }
            }

            transform.eulerAngles = new Vector3(270, f2tmp, 0);
            //Debug.Log("ALLY: "+f2tmp);
            fortestAngle = f2tmp;

            transform.position = tmpVec;
            forDist            = transform.position;
        }
    }