コード例 #1
0
    private void OnTriggerEnter(Collider other)
    {
        Enemy      enemy      = other.GetComponentInParent <Enemy>();
        EnemyPlane enemyPlane = other.GetComponentInParent <EnemyPlane>();
        Bridge     bridge     = other.GetComponentInParent <Bridge>();

        if (enemy)
        {
            Destroy(enemy.gameObject);
            scoreKeeper.score++;

            this.triggerBoom(enemy.transform);
        }
        else if (enemyPlane)
        {
            Destroy(enemyPlane.gameObject);
            scoreKeeper.score += 5;

            this.triggerBoom(enemyPlane.transform);
        }
        else if (bridge)
        {
            bridge.ShiftMesh();
            Destroy(this.gameObject);
        }
        else if (other.CompareTag("Wall"))
        {
            Destroy(this.gameObject);
        }
    }
コード例 #2
0
		public void LowerLifeWhenHitByBullet()
		{
			enemy = new EnemyPlane(new Vector2D(1.2f, 0.5f));
			Assert.AreEqual(5, enemy.Hitpoints);
			enemy.CheckIfHitAndReact(new Vector2D(1.2f, 0.5f));
			Assert.AreEqual(4, enemy.Hitpoints);
		}
コード例 #3
0
    private void OnTriggerEnter(Collider other)
    {
        Enemy      enemy      = other.GetComponentInParent <Enemy>();
        EnemyPlane enemyPlane = other.GetComponentInParent <EnemyPlane>();

        //Śmierć
        if (enemy || enemyPlane || other.CompareTag("Wall"))
        {
            this.Wreck();
        }
        else
        {
            if (other.gameObject.name.Equals("FuelTank"))
            {
                play.fuelCount += 20f;
            }
            else if (other.gameObject.name.Equals("SpawnWall"))
            {
                var     oldpos = currentStage.transform.position;
                Vector3 newpos = new Vector3(oldpos.x, oldpos.y, oldpos.z + 50);
                nextStage = Instantiate(stagePrefab, newpos, currentStage.transform.rotation, null);
                EnemyPlane enpl = nextStage.GetComponentInChildren <EnemyPlane>();
                enpl.player = play.gameObject;
            }
            else if (other.gameObject.name.Equals("DespawnWall"))
            {
                Destroy(currentStage);
                currentStage = nextStage;
            }
        }
    }
コード例 #4
0
 public void LowerLifeWhenHitByBullet()
 {
     enemy = new EnemyPlane(new Vector2D(1.2f, 0.5f));
     Assert.AreEqual(5, enemy.Hitpoints);
     enemy.CheckIfHitAndReact(new Vector2D(1.2f, 0.5f));
     Assert.AreEqual(4, enemy.Hitpoints);
 }
コード例 #5
0
		public void DefeatEnemyPlane()
		{
			enemy = new EnemyPlane(new Vector2D(1.2f, 0.9f));
			bool defeated = false;
			enemy.Destroyed += () => { defeated = true; };
			enemy.ReceiveAttack(5);
			Assert.LessOrEqual(enemy.Hitpoints, 0);
			Assert.IsTrue(defeated);
		}
コード例 #6
0
        public void DefeatEnemyPlane()
        {
            enemy = new EnemyPlane(new Vector2D(1.2f, 0.9f));
            bool defeated = false;

            enemy.Destroyed += () => { defeated = true; };
            enemy.ReceiveAttack(5);
            Assert.LessOrEqual(enemy.Hitpoints, 0);
            Assert.IsTrue(defeated);
        }
コード例 #7
0
    /// <summary>
    /// Enemy Creation
    /// </summary>
    /// <returns></returns>
    IEnumerator CreateEnemyWave()
    {
        for (int i = 0; i < count; i++)
        {
            GameObject enemyObject;
            enemyObject = Instantiate(enemy, enemy.transform.position, Quaternion.identity);
            WayPoints waypoints = enemyObject.GetComponent <WayPoints>();
            waypoints.pathPoints = pathPoints;
            waypoints.speed      = speed;
            waypoints.SetPath();
            EnemyPlane enemyClass = enemyObject.GetComponent <EnemyPlane>();
            enemyClass.shotChance  = shooting.fireChance;
            enemyClass.shotTimeMin = shooting.minTime;
            enemyClass.shotTimeMax = shooting.maxTime;
            enemyObject.SetActive(true);
            yield return(new WaitForSeconds(delay));
        }

        Destroy(gameObject);
    }
コード例 #8
0
ファイル: Octree.cs プロジェクト: ozcoolpon/ShootingGame
        private EnemyPlane UpdateEnemyPlane(GameTime gameTime, EnemyPlane enemy, Random rnd)
        {
            EnemyPlane newPlane = enemy;

            if (newPlane.canEnemyAttack(gameTime, rnd, player.Position))
            {
                AddEnemyBulletModel(enemy.Position, enemy.getAttackDirection(rnd, player.Position));
            }

            if (isFlyingOutOfBoundry(newPlane))
            {
                newPlane.CalculateEnemyTurnAround(rnd);
            }

            if (newPlane.IsTurningAround() == true)
            {
                newPlane.PerformTurnAction(player.Position);
            }
            return(newPlane);
        }
コード例 #9
0
		public void EnemyDespawnsOutsideScreenArea()
		{
			enemy = new EnemyPlane(new Vector2D(ScreenSpace.Current.Left - enemy.DrawArea.Width, 0.5f));
			AdvanceTimeAndUpdateEntities();
			Assert.IsFalse(enemy.IsActive);
		}
コード例 #10
0
		public void CreateEnemyPlane()
		{
			enemy = new EnemyPlane(new Vector2D(1.2f, 0.5f));
		}
コード例 #11
0
 public void EnemyDespawnsOutsideScreenArea()
 {
     enemy = new EnemyPlane(new Vector2D(ScreenSpace.Current.Left - enemy.DrawArea.Width, 0.5f));
     AdvanceTimeAndUpdateEntities();
     Assert.IsFalse(enemy.IsActive);
 }
コード例 #12
0
 public void CreateEnemyPlane()
 {
     enemy = new EnemyPlane(new Vector2D(1.2f, 0.5f));
 }
コード例 #13
0
ファイル: Octree.cs プロジェクト: ozcoolpon/ShootingGame
        public void Update(GameTime gameTime, FirstPersonCamera camera, int[] enemyData)
        {
            List <DrawableModel> models = new List <DrawableModel>();

            UpdateAndAddEnemy(gameTime, enemyData);
            octreeRoot.GetUpdatedModels(ref models);
            //Update All Models
            foreach (DrawableModel model in models)
            {
                if (model.GetType().ToString().Equals("ShootingGame.EnemyPlane"))
                {
                    EnemyPlane newModel = UpdateEnemyPlane(gameTime, (EnemyPlane)model, rnd);
                    octreeRoot.Add(newModel);
                }
                else if (model.GetType().ToString().Equals("ShootingGame.Player"))
                {
                    Player newPlayer = (Player)model;
                    newPlayer.DoTranslation(new Vector3((camera.Position - newPlayer.Position).X, 0, (camera.Position - newPlayer.Position).Z));
                    octreeRoot.Add(newPlayer);
                    player = newPlayer;
                }
                else if (model.GetType().ToString().Equals("ShootingGame.TankModel"))
                {
                    TankModel newTankModel = (TankModel)model;
                    newTankModel.Update(gameTime, player, rnd);
                    octreeRoot.Add(newTankModel);
                    this.tank = newTankModel;
                }
                else
                {
                    octreeRoot.Add(model);
                }
            }
            //Detect Collision
            List <int> modelsToRemove  = new List <int>();
            List <int> bulletsToRemove = new List <int>();

            octreeRoot.DetectCollision(sceneManager.GetCity(), ref modelsToRemove, ref bulletsToRemove);

            foreach (int modelID in bulletsToRemove)
            {
                octreeRoot.RemoveDrawableModel(modelID);
            }

            foreach (int modelID in modelsToRemove)
            {
                DrawableModel model = octreeRoot.RemoveDrawableModel(modelID);
                if (model.GetType().ToString().Equals("ShootingGame.EnemyPlane"))
                {
                    sceneManager.IncreasePlayerScore(((EnemyPlane)model).GetEnemyScore());
                    sceneManager.GetMusic().EffectStopPlay();
                    sceneManager.GetMusic().EffectPlay();
                    sceneManager.GetExplosionHandler().CreateExplosion(model.Position);
                }
                else if (model.GetType().ToString().Equals("ShootingGame.EnemyBullet"))
                {
                    sceneManager.DeductPlayerHealth(10);
                    sceneManager.GetMusic().hitSoundPlay();
                }
                else if (model.GetType().ToString().Equals("ShootingGame.HealthGlobe"))
                {
                    sceneManager.RecoverPlayerHealth(10);
                }
            }
        }
コード例 #14
0
ファイル: Octree.cs プロジェクト: ozcoolpon/ShootingGame
        public void AddEnemyModel(Vector3 position, Vector3 direction, int[] enemyData)
        {
            DrawableModel newDModel = new EnemyPlane(enemyPlaneModel, Matrix.CreateTranslation(position.X, position.Y, position.Z), direction, enemyData);

            octreeRoot.Add(newDModel);
        }