public void LootDrop()
    {
        if (AssetPool)
        {
            upgradeDropper = (Random.Range(0, 200));

            //when an upgrade is spawned the information is sent to an offsite brain to relay the information to the other member of the group.
            if (upgradeDropper < 30)
            {
                Debug.Log(upgradeDropper);
                if (!upgradeDropped)
                {
                    if ((upgradeDropper <= 20 && upgradeDropper > 10) && (UpgradeDetect.BeamLaserDropped == 0) && (UpgradeDetect.beamLaserCounter == 0))
                    {
                        UpgradeDetect.BeamLaserDropped += 1;
                        upgradeDropped = true;
                        spawnee        = AssetPool.GetFromPool("UpgradeBeamLaser");
                        if (null != spawnee)
                        {
                            spawnee.transform.position = (gameObject.transform.position + new Vector3(0, 0.2f, 0));
                            spawnee.transform.rotation = (gameObject.transform.rotation);
                            spawnee.SetActive(true);
                        }
                    }
                    if ((upgradeDropper <= 10) && (UpgradeDetect.MultiSpawnAmount < multiShotCount.MaxMultiShot))
                    {
                        UpgradeDetect.MultiSpawnAmount += 1;
                        upgradeDropped = true;
                        spawnee        = AssetPool.GetFromPool("TripleShotUpgrade");
                        if (null != spawnee)
                        {
                            spawnee.transform.position = (gameObject.transform.position + new Vector3(0, 0.2f, 0));
                            spawnee.transform.rotation = (gameObject.transform.rotation);
                            spawnee.SetActive(true);
                        }
                    }
                    if ((upgradeDropper <= 30 && upgradeDropper > 20) && (UpgradeDetect.UpgradeLifeCounter == 0))
                    {
                        UpgradeDetect.UpgradeLifeCounter += 1;
                        upgradeDropped = true;
                        spawnee        = AssetPool.GetFromPool("PlayerLifeUpgrade");
                        if (null != spawnee)
                        {
                            spawnee.transform.position = (gameObject.transform.position + new Vector3(0, 0.2f, 0));
                            spawnee.transform.rotation = (gameObject.transform.rotation);
                            spawnee.SetActive(true);
                        }
                    }
                }
            }
        }
    }
예제 #2
0
        /// <summary>
        /// Fires the weapon
        /// </summary>
        public override void FireWeapon()
        {
            // Spawn the projectile
            GameObject projectile = Pooling.GetFromPool(ProjectilePrefab, transform.position, transform.rotation);

            // Grab its Rigidbody2D
            Rigidbody2D rb2d = projectile.GetComponent <Rigidbody2D>();

            // Set its speed
            rb2d.velocity = ProjectileSpeed * transform.up;
        }
예제 #3
0
        /// <summary>
        /// Spawns an explosion effect
        /// </summary>
        private void SpawnExplosionEffect()
        {
            // Check we have an explosion prefab to spawn
            if (ExplosionPrefab == null)
            {
                return;
            }

            // Spawn at the center of the tile
            Pooling.GetFromPool(ExplosionPrefab, mTilemap.GetCellCenterWorld(mTilePos), Quaternion.identity);
        }
예제 #4
0
        /// <summary>
        /// Spawns a single enemy tank
        /// </summary>
        private void SpawnSingleEnemy()
        {
            // Get a random spawn point from our list
            int randomSpawnPointIndex = Random.Range(0, SpawnPoints.Count);

            // Spawn the enemy at the spawn location
            GameObject enemyTank = Pooling.GetFromPool(EnemyTankPrefab, SpawnPoints[randomSpawnPointIndex].position, Quaternion.identity);

            // Add the enemy into the list
            mSpawnedEnemyTanks.Add(enemyTank);

            // Update our internal counter
            mEnemyTanksSpawnedCount++;
        }
예제 #5
0
        /// <summary>
        /// Initialises our level with its tilemap
        /// </summary>
        private void SetupLevel()
        {
            // Get the current level info
            LevelsDataHolder.LevelInfo currentLevelInfo = LevelsData.Levels[mCurrentLevel - 1];

            // Destroy our current tilemap if we have one
            if (mCurrentTilemapGO)
            {
                Destroy(mCurrentTilemapGO);
            }

            // Spawn the new tilemap
            mCurrentTilemapGO = Pooling.GetFromPool(currentLevelInfo.LevelTilemap.gameObject, Vector3.zero, Quaternion.identity);
            mCurrentTilemapGO.transform.SetParent(TilemapParent);
            mCurrentTilemapGO.transform.position   = Vector3.zero;
            mCurrentTilemapGO.transform.localScale = Vector3.one;

            // Setup our collidable tilemaps
            CollidableTilemaps.Clear();
            CollidableTilemaps.Add(mCurrentTilemapGO.GetComponentInChildren <Tilemap>());
        }
예제 #6
0
        /// <summary>
        /// Displays the high scores in a list
        /// </summary>
        private void DisplayHighScores()
        {
            // Clear the display of scores
            ClearDisplay();

            // Get the high scores
            var highScores = HighScoreManager.Instance.HighScores;

            // If we have no high scores inform the player
            if (highScores == null || highScores.Count <= 0)
            {
                NoHighScoresLayout.SetActive(true);
                HighScoresScrollView.gameObject.SetActive(false);
                return;
            }

            // Sort high scores
            highScores.Sort((score1, score2) => score2.Score.CompareTo(score1.Score));

            // Loop through all high scores
            for (int i = 0; i < highScores.Count; i++)
            {
                // Spawn the row
                GameObject row = Pooling.GetFromPool(i == 0 ? HighScorePrefab : ScorePrefab, Vector3.zero, Quaternion.identity);

                // Reset its transform values
                row.transform.SetParent(HighScoresLayoutContainer);
                row.transform.localScale = Vector3.one;

                // Update the rows display
                HighScoreDisplayer highScoreDisplayer = row.GetComponent <HighScoreDisplayer>();
                if (highScoreDisplayer != null)
                {
                    highScoreDisplayer.Init(i + 1, highScores[i]);
                }
            }
        }
    // instantiates the Missle projectiles at specified locations relative to the origin position of MissleLoc, then provides a quaternion rotation.
    // also sets the velocity of the rigidbodies to be multiplied by the MissleSpeed integer
    // and finally adds a destroy component with a delay of 2 seconds. though that is not strictly required for standard gameplay,
    // it's more of an insurance that there won't be millions of projectiles if the MissleSpeed int is set below 6.
    void Fire()
    {
        switch (null != AmmoPool)
        {
        case true:
            missle = AmmoPool.GetFromPool("PlayerMissile");
            if (null != missle)
            {
                missle.transform.position = (MissleLoc.position + new Vector3(-0.075f, 0, 0.5f));
                missle.transform.rotation = (Quaternion.identity);
                missle.SetActive(true);
                missle.GetComponent <Rigidbody>().velocity = missle.transform.forward * MissleSpeed;
                missle.GetComponent <RaycastEmitter>().SetOwner("Player");
            }

            missle1 = AmmoPool.GetFromPool("PlayerMissile");
            if (null != missle1)
            {
                missle1.transform.position = (MissleLoc.position + new Vector3(0.075f, 0, 0.5f));
                missle1.transform.rotation = (Quaternion.identity);
                missle1.SetActive(true);
                missle1.GetComponent <Rigidbody>().velocity = missle1.transform.forward * MissleSpeed;
                missle1.GetComponent <RaycastEmitter>().SetOwner("Player");
            }
            break;

        case false:
            break;

        default:
            break;
        }

        /*
         * projm = (GameObject)Instantiate (Missle, MissleLoc.position + new Vector3(-0.075f, 0, 0.5f), Quaternion.identity);
         * projm.transform.SetParent(GameObject.Find("PlayerProjectileKeeper").transform, false); projm.GetComponent<Rigidbody>().velocity = projm.transform.forward * MissleSpeed;
         *      Destroy (projm, 2f);
         *
         *      projm = (GameObject)Instantiate (Missle, MissleLoc.position + new Vector3(0.075f, 0, 0.5f), Quaternion.identity);
         * projm.transform.SetParent(GameObject.Find("PlayerProjectileKeeper").transform, false); projm.GetComponent<Rigidbody>().velocity = projm.transform.forward * MissleSpeed;
         *      Destroy (projm, 2f);
         */
    }
예제 #8
0
 /// <summary>
 /// Assigns a new weapon to use
 /// </summary>
 /// <param name="newWeapon"></param>
 private void AssignWeapon(GameObject newWeapon)
 {
     CurrentWeapon = Pooling.GetFromPool(newWeapon, BarrelEndTransform.position, transform.rotation).GetComponent <BaseTankWeapon>();
     CurrentWeapon.transform.SetParent(transform);
     CurrentWeapon.transform.localScale = Vector3.one;
 }
예제 #9
0
 /// <summary>
 /// Spanws the player at the spawn location
 /// </summary>
 private void InstantiatePlayer()
 {
     mActivePlayer = Pooling.GetFromPool(PlayerPrefab, PlayerSpawnPoint.position, Quaternion.identity);
 }
예제 #10
0
 /// <summary>
 /// Called when the level starts
 /// </summary>
 public void OnLevelStart()
 {
     // Spawn the trophy
     Pooling.GetFromPool(BaseTrophy, SpawnPoint.position, Quaternion.identity);
 }