コード例 #1
0
ファイル: EnemyHandler.cs プロジェクト: TeamDoldur/RPG-Game
        public void LoadEnemies(string map)
        {
            var enemyFactory = new EnemyFactory();
            this.enemyList = new List<Enemy>();
            StreamReader reader = new StreamReader(@"..\..\Resources\Maps\ShadowMountains\EnemiesLocation\" + map + ".txt");
            string[] enemySprites = new string[3];
            enemySprites[0] = "None";
            enemySprites[1] = "Bandit";
            enemySprites[2] = "Gargoyle";

            int y = 0;

            while (!reader.EndOfStream)
            {
                string line = reader.ReadLine();

                for (int x = 0; x < line.Length; x++)
                {
                    int lineX = line[x] - '0';
                    Enemy enemy = enemyFactory.CreateEnemy(enemySprites[lineX], new Position(x*40,y*40));
                    if(enemy != null)
                    {
                        this.enemyList.Add(enemy);
                    }
                }

                y++;
            }

            reader.Close();
        }
コード例 #2
0
	void Awake()
	{
		if( mInstance == null )
		{
			mInstance = this;

            // Work out the width of each column
			mColumnWidth = ( GameLogic.ScreenHeight * GameplayCamera.aspect * 0.8f ) / (int)Column.NumColumns;

			// Create the enemies, initialise the active and available lists, put all enemies in the available list
			mActive = new List<GameObject>();
			mInactive = new List<GameObject>();
			mPool = new GameObject[EnemyPoolSize];
            for (int count = 0; count < mPool.Length; count++)
			{
				GameObject enemy = new GameObject( "Enemy_PoolID" + ( count + 1 ) );
				CreateMesh m = enemy.AddComponent<CreateMesh>();
				m.Material = EnemyMaterial;
				enemy.transform.localScale = new Vector3( EnemyScale, EnemyScale, EnemyScale );
				enemy.transform.localRotation = Quaternion.AngleAxis( 180.0f, Vector3.forward );
				enemy.transform.parent = transform;
                mPool[count] = enemy;
				mInactive.Add( enemy );
				enemy.SetActive( false );
			}
		}
		else
		{
			Debug.LogError( "Only one EnemyFactory allowed - destorying duplicate" );
			Destroy( this.gameObject );
		}
	}
コード例 #3
0
	void Start(){

		#region コンポーネント取得.
		// Timer取得.
		GameTimer = GameObject.FindGameObjectWithTag ("Timer").GetComponent<Timer>();

		// Quest取得.
		quest = GameObject.FindGameObjectWithTag ("Quest").GetComponent<Quest> ();

		// Player取得.
		player = GameObject.FindGameObjectWithTag("Player").GetComponent<Player>();

		enemyFactory = EnemyFactory.Instance;
		#endregion

		#region イベント登録.
		// Timerのイベント登録.
		GameTimer.TimeEndEvent += E_TimeOver;

		// プレイヤーが死んだ時のイベント登録.
		player.die += GameOver;

		// ゲームクリアー時のイベント登録.
		quest.EndQuestEvent += GameClear;
		#endregion

		// ゲームスタート時のカットシーンスタート.
		StartCoroutine (GameStart_CutScene());

	}
コード例 #4
0
 public Entity ReplaceEnemyFactory(EnemyFactory newFactory)
 {
     var component = CreateComponent<EnemyFactoryComponent>(ComponentIds.EnemyFactory);
     component.factory = newFactory;
     ReplaceComponent(ComponentIds.EnemyFactory, component);
     return this;
 }
コード例 #5
0
 void createEnemyFactory()
 {
     EnemyFactory factory = new EnemyFactory();
     factory.SetPool(pool);
     pool.CreateEntity()
         .AddEnemyFactory(factory);
 }
コード例 #6
0
ファイル: Seal.cs プロジェクト: siwenRen/Wolf
	// Use this for initialization
	void Start () {

		factory = GetComponent<EnemyFactory> ();
		factory.StopCreate ();


		effect = Instantiate(Resources.Load( "Model/Ca" + id.ToString(), typeof(GameObject))) as GameObject;
		if (effect != null) {
			//effect.transform.position = transform.position;
			effect.transform.parent = factory.effectPoint.transform;
			effect.transform.localPosition = Vector3.zero;
			effect.transform.localRotation = Quaternion.Euler(Vector3.zero);
			effect.SetActive(false);
			parentControl.SetSealEffect(effect);
		}

		for(int i = 0 ; i < parentControl.transform.GetChild(0).childCount ; ++i)
		{
			GameObject obj = parentControl.transform.GetChild(0).GetChild(i).gameObject;
			if(obj.name.Contains("frag"))
			{
				fragObject.Add(obj);
			}
		}

		parentControl.PlayAnimator (1);
		
		CameraControl.Me.ShakeCamera (0.05f, duration);
		
		InvokeRepeating ("RandomBombOnChild", 0f , 0.5f);

	}
コード例 #7
0
 public void SetData(BossEnemyData.BossEnemyFormation boss_data, GameObject baseObj, GameObject[] walls, EnemyFactory factoryClass)
 {
     EnemyBulletBaseObject   = baseObj;
     WallObjects             = walls;
     hp                      = boss_data.life;
     bossData                = boss_data;
     factory                 = factoryClass;
 }
コード例 #8
0
        public void ShouldCreateNormalEnemy_Cast()
        {
            var test = new EnemyFactory();
            object enemy = test.Create(false);

            NormalEnemy normalEnemy = Assert.IsType<NormalEnemy>(enemy);
            Assert.Equal(10, normalEnemy.Power);
        }
コード例 #9
0
        public void ShouldBeOfBaseType()
        {
            var sut = new EnemyFactory();

            object enemy = sut.Create(true);

            Assert.That(enemy, Is.InstanceOf<Enemy>());            
        }
コード例 #10
0
        public void ShouldCreateNormalEnemy()
        {
            var sut = new EnemyFactory();

            object enemy = sut.Create(false);

            Assert.That(enemy, Is.TypeOf<NormalEnemy>());
        }
コード例 #11
0
        public void ShouldCreateBossEnemy()
        {
            var sut = new EnemyFactory();

            object enemy = sut.Create(true);

            Assert.That(enemy, Is.TypeOf<BossEnemy>());
        }
コード例 #12
0
ファイル: Enemy.cs プロジェクト: RegalStranger/shootingGame
 public void SetData(NormalEnemyData.EnemyFormation enemyFormData, GameObject baseObj, EnemyFactory factory)
 {
     EnemyBulletBaseObject   = baseObj;
     hp                      = enemyFormData.life;
     score                   = enemyFormData.score;
     enemyAi                 = enemyFormData.enemyAI;
     this.factory            = factory;
     SetBezierState();
 }
コード例 #13
0
 public void SetPool(Pool pool)
 {
     _pool = pool;
     _group = pool.GetGroup(Matcher.EnemySpawner);
     _camera = pool.GetGroup(Matcher.Camera);
     _difficulty = pool.GetGroup(Matcher.DifficultyController);
     _factory = new EnemyFactory();
     _factory.SetPool(_pool);
 }
コード例 #14
0
ファイル: Map.cs プロジェクト: TheAnosmic/MetaLanParty0x00
 // Use this for initialization
 void Start()
 {
     factory = new EnemyFactory(gameObject);
     factory.PossibleEnemies = PossibleEnemies;
     factory.Target = Player;
     powerUpsManager = new PowerUpsManager(PowerUpPrefab);
     InvokeRepeating("Launch", 0.1f, 0.3F);
     // Create power up every 30 sec
     InvokeRepeating("CreatePrefab", 0.1f, 30F);
 }
コード例 #15
0
        public void ShouldHaveExtraPower()
        {
            var sut = new EnemyFactory();

            object enemy = sut.Create(true);

            Assert.That(enemy, Has.Property("ExtraPower"));

            //Assert.That(enemy, Has.Property("SomeOtherProperty"));
        }
コード例 #16
0
 /// <summary>
 /// Spawns Enemies created by the EnemyFactory at random locations on the screen
 /// </summary>
 /// <param name="constructEnemy">Function to define an enemy</param>
 /// <param name="numEnemies">Number of enemies</param>
 internal static void Spawn(EnemyFactory constructEnemy, int numEnemies)
 {
     if (!This.Cheats.SpawnEnemies.Enabled)
     {
         FrostbyteLevel l = (This.Game.CurrentLevel != This.Game.NextLevel && This.Game.NextLevel != null ? This.Game.NextLevel : This.Game.CurrentLevel) as FrostbyteLevel;
         for (int i = 0; i < numEnemies; i++)
         {
             Sprite virus = constructEnemy();
             virus.Pos = l.Camera.Pos +
                 new Vector2(rand.Next(-500, This.Game.GraphicsDevice.Viewport.Width+500),
                     rand.Next(-500, This.Game.GraphicsDevice.Viewport.Height+500));
         }
     }
 }
コード例 #17
0
    // Use this for initialization
    void Start () {
		Debug.Log ("GameManager->Start");

		plotFactory = GetComponent<PlotFactory>();
		enemyFactory = GetComponent<EnemyFactory>();

		canvasInit();

		state = State.NewGame;
		PlayFabSettings.TitleId = "E232";
		UpdateUserStatisticsRequest updateReq = new UpdateUserStatisticsRequest (); 
		updateReq.UserStatistics = new System.Collections.Generic.Dictionary<string, int> (); 
		updateReq.UserStatistics.Add("nightsSurvived", nightCounter); 
		Login ("E232", SystemInfo.deviceUniqueIdentifier);
	}
コード例 #18
0
ファイル: SkillStopCreateEnemy.cs プロジェクト: siwenRen/Wolf
	// Use this for initialization
	void Start ()
	{
	
		factory = GetComponent<EnemyFactory> ();
		factory.StopCreate ();

		effect = Instantiate (Resources.Load ("Model/Stop", typeof(GameObject))) as GameObject;
		if (effect != null) {
			effect.transform.position = transform.position;
			effect.transform.up = (transform.position - PlanetControl.Me.gameObject.transform.position).normalized;
		}

		ClipSound.Me.Play ("ganrao_attack");

		ZhangYuControl.Me.PlayAnimator (ZhangYuControl.Me.skill2);
	}
コード例 #19
0
    void spawnIfCan(Entity e, Vector3 cameraPosition, EnemyFactory factory)
    {
        EnemySpawnerComponent enemySpawner = e.enemySpawner;
        LevelModelComponent levelModel = enemySpawner.model;

        if (levelModel.enemyIndex < levelModel.enemies.Count) {
            EnemySpawnModel enemyModel = levelModel.enemies[levelModel.enemyIndex];
            if (enemyModel.spawnBarrier < cameraPosition.y) {
                levelModel.enemyIndex += 1;
                factory.CreateEnemyByModel(enemyModel);
            }
        }

        if (levelModel.waveIndex < levelModel.waves.Count) {
            WaveSpawnModel waveModel = levelModel.waves[levelModel.waveIndex];
            if (waveModel.spawnBarrier < cameraPosition.y) {
                levelModel.waveIndex += 1;
                pool.CreateEntity()
                    .AddWaveSpawner(waveModel.count, waveModel.type, waveModel.spawnOffset, 0.0f, waveModel.speed, waveModel.health, waveModel.path, waveModel.grid, waveModel.damage);
            }
        }
    }
コード例 #20
0
 public Entity AddEnemyFactory(EnemyFactory newFactory)
 {
     var component = CreateComponent<EnemyFactoryComponent>(ComponentIds.EnemyFactory);
     component.factory = newFactory;
     return AddComponent(ComponentIds.EnemyFactory, component);
 }
コード例 #21
0
ファイル: EnemyFactory.cs プロジェクト: satela/xjhU3d
	// Use this for initialization
	void Start () {

        _instance = this;
        createEnemy();    
	}
コード例 #22
0
 public void SetUp()
 {
     sut = new EnemyFactory();
 }
コード例 #23
0
 public EnemySpawnerEngine(EnemyFactory enemyFactory, IEntityFunctions entityFunctions)
 {
     _entityFunctions      = entityFunctions;
     _enemyFactory         = enemyFactory;
     _numberOfEnemyToSpawn = 15;
 }
コード例 #24
0
 /// <summary>
 /// Spawns Enemies created by the EnemyFactory centered within a radius 
 /// proportional to the number of enemies around a specified position
 /// </summary>
 /// <param name="constructEnemy"></param>
 /// <param name="numEnemies"></param>
 /// <param name="position"></param>
 internal static void Spawn(EnemyFactory constructEnemy, int numEnemies, Vector2 position)
 {
     if (!This.Cheats.SpawnEnemies.Enabled)
     {
         double radius = 160f;
         double angleInc = (1.5 * Math.PI) / numEnemies;
         double startAngle = Math.PI * 2 * rand.NextDouble();
         for (int i = 0; i < numEnemies; i++)
         {
             Sprite virus = constructEnemy();
             virus.Pos = position + new Vector2((float)(Math.Cos(angleInc * i + startAngle) * radius * rand.NextDouble()),
                 (float)(Math.Sin(angleInc * i + startAngle) * radius * rand.NextDouble()));
         }
     }
 }
コード例 #25
0
 public EnemyPool(EnemyFactory _enemyFactory)
 {
     enemyFactory = _enemyFactory;
 }
コード例 #26
0
 public EnemyFactoryShould()
 {
     _sut = new EnemyFactory();
 }
コード例 #27
0
 void Start()
 {
     instance = this;
 }
コード例 #28
0
 // Use this for initialization
 void Start()
 {
     enemyFactory = FindObjectOfType <EnemyFactory>();
     canvasGroup  = GetComponent <CanvasGroup>();
     RefreshDebugUI();
 }
 private void InitializeEnemyFactory(int areaLevel)
 {
     _factory = new EnemyFactory(areaLevel);
 }
コード例 #30
0
ファイル: EnemyFactory.cs プロジェクト: Niloc37/UniJam
    private void Awake()
    {
        if (Instance != null)
        {
            Debug.LogError("There is multiple instance of singleton BallFactory");
            return;
        }

        Instance = this;

        foreach (object value in System.Enum.GetValues(typeof(EnemyType)))
        {
            this.availableEnemyByType.Add((EnemyType)value, new Queue<BaseEnemy>());
        }
    }
コード例 #31
0
 private GameSceneController()
 {
     enemyFactory      = EnemyFactory.getInstance();
     cannonBallFactory = CannonBallFactory.getInstance();
 }
コード例 #32
0
ファイル: MapLoader.cs プロジェクト: plmng/SoftUni_OOP_HWs
        public void Load(IRace selectedPlayerRace)
        {
            //TODO implement diff levels //-> pass as parameter in methed the level create sweatch for levels and set for mapPath diff map resourse

            var mapPath = AppSettings.MapLevel1;
            var frientFactory = new FriendFactory();
            var enemyFactory = new EnemyFactory();

            this.PlayerRace = selectedPlayerRace;
            var width = AppSettings.MapElementSize.Width;
            var height = AppSettings.MapElementSize.Height;

            try
            {
                using (var reader = new StreamReader(mapPath))
                {
                    for (var row = 0; row < AppSettings.MapElementsCountY; row++)
                    {
                        var top = (row*height)+AppSettings.MapPosition.Top;

                        var line = reader.ReadLine();
                        for (var col = 0; col < AppSettings.MapElementsCountX; col++)
                        {
                            var left = col*width;

                            var currentsymbol = line[col];
                            switch (currentsymbol)
                            {
                                case 'p':
                                    this.Player = new Player(this.PlayerRace)
                                    {
                                        Position = new Position (left, top),
                                        Size = new Size(width, height)
                                    };
                                    break;

                                case 'f':
                                    this.Friend = (Friend)frientFactory.Create(_friendRace);
                                    this.Friend.Position = new Position(left, top);
                                    this.Friend.Size = new Size(width, height);
                                    break;

                                case 'e':
                                    var enemy = (Enemy)enemyFactory.Create(_enemyRace);
                                    enemy.Position = new Position (left, top);
                                    enemy.Size = new Size(width, height);
                                    this.Enemies.Add(enemy);
                                    break;

                                case 'w':
                                    var mazeElement = new MazeItem()
                                    {
                                        Position = new Position(left, top),
                                        Size = new Size(width, height)
                                    };
                                    this.Maze.Add(mazeElement);
                                    break;

                                case 'b':
                                    var beer = new BeerItem()
                                    {
                                        Position = new Position(left, top),
                                        Size = new Size(width, height)
                                    };
                                    this.ItemToCollect.Add(beer);
                                    break;

                                case 'l':
                                    var itemLife = new LifeItem()
                                    {
                                        Position = new Position(left, top),
                                        Size = new Size(width, height)
                                    };
                                    this.ItemToCollect.Add(itemLife);
                                    break;

                                case 'h':
                                    var itemHealth = new LargeHealthItem()
                                    {
                                        Position = new Position(left, top),
                                        Size = new Size(width, height)
                                    };
                                    this.ItemToCollect.Add(itemHealth);
                                    break;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "BB Game MapLoader");
            }
        }
コード例 #33
0
        private void SpawnBlub(Vector2 position, float radius, GameWorld world)
        {
            var blob = EnemyFactory.KamikazeBlob(position, world.EnemyEmpire, world.PlayerEmpire, radius);

            world.AddEntity(blob);
        }
コード例 #34
0
        private static LevelInfo Level3()
        {
            var levelInfo = new LevelInfo();

            levelInfo.BigWaveStartTimes = new List <float>
            {
                30f
            };

            levelInfo.EstimatedMaxEnemiesOnScreen = new Dictionary <EnemyType, int>
            {
                { EnemyType.SmallSlime, 50 }
            };


            levelInfo.AddEnemySpawnInfo(3f, SpawnPoint.A, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(3f, SpawnPoint.B, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(3f, SpawnPoint.C, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(3f, SpawnPoint.D, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(3f, SpawnPoint.E, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(3f, SpawnPoint.F, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(3f, SpawnPoint.G, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));


            levelInfo.AddEnemySpawnInfo(5f, SpawnPoint.D, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(7f, SpawnPoint.D, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(9f, SpawnPoint.D, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));


            levelInfo.AddEnemySpawnInfo(11f, SpawnPoint.A, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(11f, SpawnPoint.B, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(11f, SpawnPoint.C, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(11f, SpawnPoint.D, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(11f, SpawnPoint.E, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(11f, SpawnPoint.F, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(11f, SpawnPoint.G, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));


            levelInfo.AddEnemySpawnInfo(20f, SpawnPoint.A, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(19f, SpawnPoint.B, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(18f, SpawnPoint.C, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(17f, SpawnPoint.D, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(16f, SpawnPoint.E, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(15f, SpawnPoint.F, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(14f, SpawnPoint.G, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));

            levelInfo.AddEnemySpawnInfo(19f, SpawnPoint.D, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(21f, SpawnPoint.D, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));

            levelInfo.AddEnemySpawnInfo(21f, SpawnPoint.B, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(22f, SpawnPoint.C, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(23f, SpawnPoint.D, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(24f, SpawnPoint.E, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(25f, SpawnPoint.F, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(26f, SpawnPoint.G, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));


            levelInfo.AddEnemySpawnInfo(37f, SpawnPoint.A, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(36f, SpawnPoint.B, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(35f, SpawnPoint.C, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(34f, SpawnPoint.D, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(33f, SpawnPoint.E, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(32f, SpawnPoint.F, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(31f, SpawnPoint.G, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(29f, SpawnPoint.G, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));

            levelInfo.AddEnemySpawnInfo(33f, SpawnPoint.G, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(35f, SpawnPoint.G, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(37f, SpawnPoint.G, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(39f, SpawnPoint.G, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(41f, SpawnPoint.G, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));

            levelInfo.AddEnemySpawnInfo(38f, SpawnPoint.B, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(39f, SpawnPoint.C, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(40f, SpawnPoint.D, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(41f, SpawnPoint.E, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(42f, SpawnPoint.F, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(43f, SpawnPoint.G, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));
            levelInfo.AddEnemySpawnInfo(45f, SpawnPoint.G, EnemyFactory.CreateEnemy(EnemyType.SmallSlime));


            levelInfo.Reward      = 1000;
            levelInfo.LevelNumber = 3;

            return(levelInfo);
        }
コード例 #35
0
 public CoreClient(Engine engine, PlayerFactory playerFactory, EnemyFactory enemyFactory)
 {
     _enemyFactory  = enemyFactory;
     _playerFactory = playerFactory;
     _engine        = engine;
 }
コード例 #36
0
    private void Start()
    {
        worldEnemyFactory = new EnemyFactory(poolsGos);

        gameplayCamera.Follow = Player.Instance.transform;
    }
コード例 #37
0
 public EnemySpawnerEngine(EnemyFactory enemyFactory, IEntityFunctions entityFunctions)
 {
     _entityFunctions      = entityFunctions;
     _enemyFactory         = enemyFactory;
     _numberOfEnemyToSpawn = NUMBER_OF_ENEMIES_TO_SPAWN;
 }
コード例 #38
0
        private void MakeObject(System.Drawing.Color pixel, int x, int y)
        {
            Func <System.Drawing.Color, System.Drawing.Color, bool> sameColor = (c1, c2) => (c1.R == c2.R && c1.G == c2.G && c1.B == c2.B);
            Vector2            position    = new Vector2(x, y);
            AbstractGameObject initializer = null;

            if (!sameColor(pixel, Colors.Empty))
            {
                if (pixel.R == Colors.MarioSpawn.R && pixel.G == Colors.MarioSpawn.G)
                {
                    position = new Vector2(position.X, position.Y - (MarioHeight - 64));
                    Mario mario;
                    if (MarioCloneGame.Player1 == null && pixel.B == 0)
                    {
                        mario = MarioFactory.Create(position);
                        MarioCloneGame.Player1 = mario;
                        MarioCloneGame.HUDs.Add(new HeadsUpDisplay.HUD(mario, MarioCloneGame.Player1Camera));
                        Grid.Add(mario);
                    }
                    else if (MarioCloneGame.Player2 == null && pixel.B == 1 && (MarioCloneGame.Mode == GameMode.MultiPlayer))
                    {
                        mario = MarioFactory.Create(position);
                        MarioCloneGame.Player2 = mario;
                        MarioCloneGame.HUDs.Add(new HeadsUpDisplay.HUD(mario, MarioCloneGame.Player2Camera));
                        Grid.Add(mario);
                    }
                    else if (MarioCloneGame.Player1 != null && pixel.B == 0)
                    {
                        mario = MarioCloneGame.Player1;
                        mario.ResetMario(position);
                        MarioCloneGame.HUDs.Add(new HeadsUpDisplay.HUD(mario, MarioCloneGame.Player1Camera));
                        Grid.Add(mario);
                    }
                    else if (MarioCloneGame.Player2 != null && pixel.B == 1 && (MarioCloneGame.Mode == GameMode.MultiPlayer))
                    {
                        mario = MarioCloneGame.Player2;
                        mario.ResetMario(position);
                        MarioCloneGame.HUDs.Add(new HeadsUpDisplay.HUD(mario, MarioCloneGame.Player2Camera));
                        Grid.Add(mario);
                    }
                }
                else if (sameColor(pixel, Colors.MarioCheckpoint))
                {
                    MarioCloneGame.Player1.Spawns.Add(position);
                    if ((MarioCloneGame.Mode == GameMode.MultiPlayer))
                    {
                        MarioCloneGame.Player2.Spawns.Add(position);
                    }
                }
                else if (sameColor(pixel, Colors.QuestionBlock))
                {
                    initializer          = BlockFactory.Instance.Create(BlockType.QuestionBlock, position);
                    initializer.Position = new Vector2(initializer.Position.X, initializer.Position.Y + initializer.Sprite.SourceRectangle.Height);
                    Grid.Add(initializer);
                }
                else if (sameColor(pixel, Colors.QuestionBlockGreenMushroom))
                {
                    initializer = BlockFactory.Instance.Create(BlockType.QuestionBlock, position);
                    ((AbstractBlock)initializer).ContainedPowerup = PowerUpType.GreenMushroom;
                    initializer.Position = new Vector2(initializer.Position.X, initializer.Position.Y + initializer.Sprite.SourceRectangle.Height);
                    Grid.Add(initializer);
                }
                else if (sameColor(pixel, Colors.QuestionBlockFireFlower))
                {
                    initializer = BlockFactory.Instance.Create(BlockType.QuestionBlock, position);
                    ((AbstractBlock)initializer).ContainedPowerup = PowerUpType.Flower;
                    initializer.Position = new Vector2(initializer.Position.X, initializer.Position.Y + initializer.Sprite.SourceRectangle.Height);
                    Grid.Add(initializer);
                }
                else if (pixel.R == Colors.BrickBlock.R && pixel.G == Colors.BrickBlock.G)
                {
                    initializer = BlockFactory.Instance.Create(BlockType.BreakableBrick, position);
                    ((AbstractBlock)initializer).CoinCount = pixel.B;
                    initializer.Position = new Vector2(initializer.Position.X, initializer.Position.Y + initializer.Sprite.SourceRectangle.Height);
                    Grid.Add(initializer);
                }
                else if (sameColor(pixel, Colors.UsedBlock))
                {
                    initializer          = BlockFactory.Instance.Create(BlockType.UsedBlock, position);
                    initializer.Position = new Vector2(initializer.Position.X, initializer.Position.Y + initializer.Sprite.SourceRectangle.Height);
                    Grid.Add(initializer);
                }
                else if (sameColor(pixel, Colors.FloorBlock))
                {
                    initializer          = BlockFactory.Instance.Create(BlockType.FloorBlock, position);
                    initializer.Position = new Vector2(initializer.Position.X, (initializer.Position.Y + initializer.Sprite.SourceRectangle.Height));
                    Grid.Add(initializer);
                }
                else if (sameColor(pixel, Colors.StairBlock))
                {
                    initializer          = BlockFactory.Instance.Create(BlockType.StairBlock, position);
                    initializer.Position = new Vector2(initializer.Position.X, initializer.Position.Y + initializer.Sprite.SourceRectangle.Height);
                    Grid.Add(initializer);
                }
                else if (sameColor(pixel, Colors.HiddenBlock))
                {
                    initializer          = BlockFactory.Instance.Create(BlockType.HiddenBlock, position);
                    initializer.Position = new Vector2(initializer.Position.X, initializer.Position.Y + initializer.Sprite.SourceRectangle.Height);
                    Grid.Add(initializer);
                }
                else if (sameColor(pixel, Colors.Goomba))
                {
                    position             = new Vector2(position.X, position.Y - (GoombaHeight - 64));
                    initializer          = EnemyFactory.Create(EnemyType.Goomba, position);
                    initializer.Position = new Vector2(initializer.Position.X, initializer.Position.Y + initializer.Sprite.SourceRectangle.Height);
                    Grid.Add(initializer);
                }
                else if (sameColor(pixel, Colors.Piranha))
                {
                    initializer          = EnemyFactory.Create(EnemyType.Piranha, position);
                    initializer.Position = new Vector2(initializer.Position.X + Math.Abs(((initializer.Sprite.SourceRectangle.Width - PipeTopWidth) / 2)),
                                                       initializer.Position.Y +
                                                       (initializer.Sprite.SourceRectangle.Height) + PipeTopHeight);
                    Grid.Add(initializer);
                }
                else if (sameColor(pixel, Colors.GreenKoopa))
                {
                    position             = new Vector2(position.X, position.Y);
                    initializer          = EnemyFactory.Create(EnemyType.GreenKoopa, position);
                    initializer.Position = new Vector2(initializer.Position.X, initializer.Position.Y + initializer.Sprite.SourceRectangle.Height);
                    Grid.Add(initializer);
                }
                else if (sameColor(pixel, Colors.RedMushroom))
                {
                    initializer          = PowerUpFactory.Create(PowerUpType.RedMushroom, position);
                    initializer.Position = new Vector2(initializer.Position.X, initializer.Position.Y + initializer.Sprite.SourceRectangle.Height);
                    Grid.Add(initializer);
                }
                else if (sameColor(pixel, Colors.GreenMushroom))
                {
                    initializer          = PowerUpFactory.Create(PowerUpType.GreenMushroom, position);
                    initializer.Position = new Vector2(initializer.Position.X, initializer.Position.Y + initializer.Sprite.SourceRectangle.Height);
                    Grid.Add(initializer);
                }
                else if (sameColor(pixel, Colors.FireFlower))
                {
                    initializer          = PowerUpFactory.Create(PowerUpType.Flower, position);
                    initializer.Position = new Vector2(initializer.Position.X, initializer.Position.Y + initializer.Sprite.SourceRectangle.Height);
                    Grid.Add(initializer);
                }
                else if (sameColor(pixel, Colors.Coin))
                {
                    initializer = PowerUpFactory.Create(PowerUpType.Coin, position);
                    ((AbstractPowerup)initializer).State = new CoinStaticState((AbstractPowerup)initializer);
                    initializer.Position = new Vector2(initializer.Position.X, initializer.Position.Y + initializer.Sprite.SourceRectangle.Height);
                    Grid.Add(initializer);
                }
                else if (sameColor(pixel, Colors.PipeSegment))
                {
                    initializer          = BlockFactory.Instance.Create(BlockType.PipeSegment, position);
                    initializer.Position = new Vector2(initializer.Position.X, initializer.Position.Y + initializer.Sprite.SourceRectangle.Height);
                    Grid.Add(initializer);
                }
                else if (sameColor(pixel, Colors.Flagpole))
                {
                    if (MarioCloneGame.Mode != GameMode.SinglePlayer)
                    {
                        initializer          = BlockFactory.Instance.Create(BlockType.Flagpole, position);
                        initializer.Position = new Vector2(initializer.Position.X, initializer.Position.Y + initializer.Sprite.SourceRectangle.Height);
                        Grid.Add(initializer);
                    }
                }
                else if (sameColor(pixel, Colors.PipeTop))
                {
                    PipeTop pipeTop = (PipeTop)BlockFactory.Instance.Create(BlockType.PipeTop, position);
                    pipeTop.Position = new Vector2(pipeTop.Position.X, pipeTop.Position.Y + pipeTop.Sprite.SourceRectangle.Height);
                    if (aboveGround)
                    {
                        pipeTop.LevelArea = 0;
                    }
                    else
                    {
                        String temp = Path.GetFileNameWithoutExtension(file);
                        pipeTop.LevelArea = temp[temp.Length - 1] - '0';
                    }

                    for (int i = (y / BlockHeight) - yOffsetFromUnderground - 1; i < _image.Height; i++)
                    {
                        System.Drawing.Color tempPixel = _image.GetPixel((x / BlockWidth) - xOffsetFromUnderground, i);
                        //"false" will be replaced with pixel.R == Colors.WarpSpot.R && pixel.G == Colors.WarpSpot.G
                        if (aboveGround && tempPixel.R == Colors.WarpPoint.R && tempPixel.G == Colors.WarpPoint.G)
                        {
                            if (danglingWarp != null)
                            {
                                danglingWarp.WarpEnd = pipeTop;
                                pipeTop.WarpEnd      = danglingWarp;
                                danglingWarp         = null;
                            }
                            else
                            {
                                danglingWarp = pipeTop;
                                aboveGround  = false;

                                String newFile    = String.Concat(Path.GetFileNameWithoutExtension(file), tempPixel.B, Path.GetExtension(file));
                                String tempHolder = file;
                                newFile = Path.Combine(Path.GetDirectoryName(file), newFile);

                                using (var stream = new FileStream(newFile, FileMode.Open))
                                {
                                    _image = new Bitmap(stream);
                                }

                                file = newFile;
                                LevelAreas.Add(tempPixel.B,
                                               new Microsoft.Xna.Framework.Rectangle(x, (i + 1) * BlockHeight, _image.Width * BlockWidth, MarioCloneGame.ReturnGraphicsDevice.PreferredBackBufferHeight));
                                CurrentArea            = tempPixel.B;
                                xOffsetFromUnderground = x / BlockWidth;
                                yOffsetFromUnderground = i;

                                BlockFactory.SpriteFactory = SubThemedBlockSpriteFactory.Instance;
                                CreationLoop(x / BlockWidth, i + 1);
                                BlockFactory.SpriteFactory = NormalThemedBlockSpriteFactory.Instance;

                                xOffsetFromUnderground = 0;
                                yOffsetFromUnderground = 0;
                                file        = tempHolder;
                                aboveGround = true;
                                CurrentArea = 0;
                                using (var stream = new FileStream(file, FileMode.Open))
                                {
                                    _image = new Bitmap(stream);
                                }
                            }

                            break;
                        }
                        //"false" will be replaced with pixel.R == Colors.WarpSpot.R && pixel.G == Colors.WarpSpot.G
                        else if (tempPixel.R == Colors.WarpPoint.R && tempPixel.G == Colors.WarpPoint.G)
                        {
                            if (danglingWarp != null)
                            {
                                danglingWarp.WarpEnd = pipeTop;
                                pipeTop.WarpEnd      = danglingWarp;
                                danglingWarp         = null;
                            }
                            else
                            {
                                danglingWarp = pipeTop;
                            }
                        }
                    }

                    Grid.Add(pipeTop);
                }
                else if (sameColor(pixel, Colors.QuestionBlockRedMushroom))
                {
                    initializer = BlockFactory.Instance.Create(BlockType.QuestionBlock, position);
                    ((AbstractBlock)initializer).ContainedPowerup = PowerUpType.RedMushroom;
                    initializer.Position = new Vector2(initializer.Position.X, initializer.Position.Y + initializer.Sprite.SourceRectangle.Height);
                    Grid.Add(initializer);
                }
                else if (sameColor(pixel, Colors.BowserObject))
                {
                    position             = new Vector2(position.X, position.Y);
                    initializer          = EnemyFactory.Create(EnemyType.BowserIdle, position);
                    initializer.Position = new Vector2(initializer.Position.X, initializer.Position.Y);
                    Grid.Add(initializer);
                }
                else if (sameColor(pixel, Colors.FireCannonBlock))
                {
                    position             = new Vector2(position.X, position.Y);
                    initializer          = BlockFactory.Instance.Create(BlockType.FireCannon, position);
                    initializer.Position = new Vector2(initializer.Position.X, initializer.Position.Y + initializer.Sprite.SourceRectangle.Height);
                    Grid.Add(initializer);
                }
                else if (pixel.R == Colors.WarpPoint.R && pixel.G == Colors.WarpPoint.G)
                {
                    initializer          = BlockFactory.Instance.Create(BlockType.FloorBlock, position);
                    initializer.Position = new Vector2(initializer.Position.X, (initializer.Position.Y + initializer.Sprite.SourceRectangle.Height));
                    Grid.Add(initializer);
                    //MakeObject(Colors.FloorBlock, (x / BlockWidth) - xOffsetFromUnderground, (y / BlockHeight) - yOffsetFromUnderground - 1);

                    /*if ((x / BlockWidth) - 1 - xOffsetFromUnderground >= 0)
                     * {
                     *  //fill in the blank space with some surrounding to blend in
                     *  MakeObject(_image.GetPixel((x / BlockWidth) - 1 - xOffsetFromUnderground, (y / BlockHeight) - yOffsetFromUnderground - 1), x, y);
                     * }
                     * else if ((x / BlockWidth) + 1 < _image.Width)
                     * {
                     *  MakeObject(_image.GetPixel((x / BlockWidth) + 1 - xOffsetFromUnderground, (y / BlockHeight) - yOffsetFromUnderground - 1), x, y);
                     * }
                     * else
                     * {
                     *  MakeObject(Colors.FloorBlock, (x / BlockWidth) - xOffsetFromUnderground, (y / BlockHeight) - yOffsetFromUnderground - 1);
                     * }*/
                }
            }

            if (initializer != null)
            {
                initializer.LevelArea = CurrentArea;
            }
        }
コード例 #39
0
 public TestExceptions()
 {
     _sut   = new PlayerCharacter();
     _enemy = new EnemyFactory();
 }
コード例 #40
0
 public EnemySpawner(GameplaySettings gameplaySettings, EnemyFactory enemyFactory)
 {
     _gameplaySettings = gameplaySettings;
     _enemyFactory     = enemyFactory;
 }
コード例 #41
0
ファイル: Game1.cs プロジェクト: surfintime0027/ArmorPotion
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            SpriteBatch = new SpriteBatch(GraphicsDevice);
            world = new World(this);

            ItemFactory itemFactory = new ItemFactory(world, @"Items");

            EnemyFactory factory = new EnemyFactory(world, @"Enemy");
            world.EnemyFactory = factory;

            Map dungeonOne = MapLoader.Load("Content/Maps/DungeonOne_top.txt", "Content/Maps/DungeonOne_bottom.txt", "Content/Maps/DungeonOne_enemy.txt", world);
            world.CurrentDungeon = dungeonOne;

            Item item = itemFactory.Create("Super Awesome Potion");
            item.Position = new Vector2(70, 70);
            world.item = item;

            Animation animation = new Animation(1, 32, 32, 0, 0);
            Animation animation2 = new Animation(1, 256, 256, 0, 0);

            AnimatedSprite sprite = new AnimatedSprite(Content.Load<Texture2D>(@"Items\Weapons\Fireball"), new Dictionary<AnimationKey, Animation> { { AnimationKey.Right, animation } });
            AnimatedSprite light = new AnimatedSprite(Content.Load<Texture2D>(@"Enemy\LightBugAttack"), new Dictionary<AnimationKey, Animation> { { AnimationKey.Right, animation2 } });

            world.Player.Inventory.TempaQuips.Add(new Sword(Content.Load<Texture2D>(@"Gui\SwordIcon"), "Sword"));

            world.Player.Inventory.TempaQuips.Add((Gun)itemFactory.Create("Bobs Gun"));
            world.Player.Inventory.SelectRelativeTempaQuip(world.Player, 0);

            world.Player.Inventory.TempaQuips.Add(new Zapper(Content.Load<Texture2D>(@"Gui\GogglesIcon"), "BobsZapper", light));

            world.Player.Inventory.TempaQuips.Add(new SomeConeWeapon(Content.Load<Texture2D>(@"Gui\GravityBootsIcon"), "BobsCone", sprite.Clone()));

            world.Player.Inventory.TempaQuips.Add((EBall)itemFactory.Create("E-Ball Fire"));
            world.Player.Inventory.TempaQuips.Add((EBall)itemFactory.Create("E-Ball Ice"));
            world.Player.Inventory.TempaQuips.Add((EBall)itemFactory.Create("E-Ball Lightning"));
        }
コード例 #42
0
    void Update()
    {
        if (UserData.LevelMaxPoints != null && UserData.LevelMaxPoints.Count > UserData.CurrentLevel)
        {
            GameObject.Find("BestScore").GetComponent <TextMesh>().text = string.Format("Previous\nBest :\n{0}", UserData.LevelMaxPoints[UserData.CurrentLevel]);
        }

        GameDeltaTime = Paused ? 0.0f : Time.deltaTime;

        if (mGameStatus == State.Game)
        {
            GameText.transform.Find("Points").GetComponent <TextMesh>().text = string.Format("{0}", UserData.LevelPoints);

            if (UserData.GetIsTutorialReady()) // Display some tutorials for a few sec depending on state of the game
            {
                UserData.EnableTutorialMovementControl();
                GameText.GetComponent <TextMesh>().text = string.Format("Control your ship by\ndragging it and try to earn as many\npoints as possible!");
            }
            else if (UserData.GetSideLaser() > 0 && UserData.GetIsTutorialSLReady())
            {
                UserData.EnableTutorialSideLaser();
                GameText.GetComponent <TextMesh>().text = string.Format("When your laser is charged,\ntilt your device or\npress Q/E to use it!");
            }
            else if (UserData.CountDownTutorialMovementControl() && UserData.CountDownTutorialSideLaser())//If tutorial has been displayed long enough
            {
                GameText.GetComponent <TextMesh>().text = string.Format("");
            }

            string enemies = mCurrentDifficulty.SpawnCount();
            int    iEnemies;
            if (int.TryParse(enemies, out iEnemies))
            {
                if (enemies == "-2")               // Boss level - boss already spawned
                {
                    if (mActiveEnemies.Count == 0) //Boss Defeated !
                    {
                        mCurrentDifficulty.FinishLevel(8.0f);
                    }
                }
                else if (DifficultyCurve.Levels[UserData.CurrentLevel].Length == 1) // Boss level
                {
                    mActiveEnemies.Add(EnemyFactory.Dispatch(int.Parse(enemies), EnemyFactory.Column.Two, true));
                }
                else if (enemies.Length == 1)
                {
                    mActiveEnemies.Add(EnemyFactory.Dispatch(int.Parse(enemies), (EnemyFactory.Column)Random.Range(0, 3)));
                }
                else if (enemies.Length == 2)
                {
                    int config = Random.Range(0, 3);
                    if (config == 0)
                    {
                        mActiveEnemies.Add(EnemyFactory.Dispatch(int.Parse(enemies[0].ToString()), EnemyFactory.Column.One));
                        mActiveEnemies.Add(EnemyFactory.Dispatch(int.Parse(enemies[1].ToString()), EnemyFactory.Column.Two));
                    }
                    else if (config == 1)
                    {
                        mActiveEnemies.Add(EnemyFactory.Dispatch(int.Parse(enemies[0].ToString()), EnemyFactory.Column.One));
                        mActiveEnemies.Add(EnemyFactory.Dispatch(int.Parse(enemies[1].ToString()), EnemyFactory.Column.Three));
                    }
                    else
                    {
                        mActiveEnemies.Add(EnemyFactory.Dispatch(int.Parse(enemies[0].ToString()), EnemyFactory.Column.Two));
                        mActiveEnemies.Add(EnemyFactory.Dispatch(int.Parse(enemies[1].ToString()), EnemyFactory.Column.Three));
                    }
                }
                else if (enemies.Length == 3)
                {
                    mActiveEnemies.Add(EnemyFactory.Dispatch(int.Parse(enemies.Substring(0, 1)), EnemyFactory.Column.One));
                    mActiveEnemies.Add(EnemyFactory.Dispatch(int.Parse(enemies.Substring(1, 1)), EnemyFactory.Column.Two));
                    mActiveEnemies.Add(EnemyFactory.Dispatch(int.Parse(enemies.Substring(2, 1)), EnemyFactory.Column.Three));
                }
            }
            // Update the position of each active enemy, keep a track of enemies which have gone off screen
            List <GameObject> oldEnemys = new List <GameObject>();
            for (int count = 0; count < mActiveEnemies.Count; count++)
            {
                Vector3 position = mActiveEnemies[count].transform.position;

                if (DifficultyCurve.Levels[UserData.CurrentLevel].Length == 1 && position.y <= ScreenHeight - 25.0f) // If boss, then force him to strafe back and forth after entering the screen
                {
                    position = mActiveEnemies[count].GetComponent <EnemyBehaviour>().StrafeBackAndForth();
                }
                else//If not boss then just go straight down (Could have some more logic here to implement different movement patterns)
                {
                    position.y -= GameDeltaTime * GameSpeed;
                }
                mActiveEnemies[count].transform.position = position;
                mActiveEnemies[count].GetComponent <EnemyBehaviour>().DoAction();
                if (position.y < ScreenHeight * -0.5f)
                {
                    EnemyFactory.Return(mActiveEnemies[count]);
                    oldEnemys.Add(mActiveEnemies[count]);
                    mMissedEnemies++;
                }
            }


            mPowerUpFactory.MovePowerups(GameDeltaTime * GameSpeed);

            /* Mechanic no longer in use - kept here if needed
             *          if( mMissedEnemies >= MaxMissedEnemies )
             *          {
             *  // Too many missed enemies - Game over
             *                  mCurrentDifficulty.Stop();
             *  mGameOverTime = Time.timeSinceLevelLoad;
             *  mGameStatus = State.GameOver;
             *                  GameText.text = string.Format( "You Been Invaded!\nTotal Distance: {0:0.0} m", mDistanceTravelled );
             *          }
             */

            for (int count = 0; count < oldEnemys.Count; count++)
            {
                mActiveEnemies.Remove(oldEnemys[count]);
            }
        }
    }
コード例 #43
0
 public EnemyFactoryShould()
 {
     this.sut = new EnemyFactory();
 }
コード例 #44
0
 protected override void Release()
 {
     EnemyFactory.ReleaseEnemy(this);
 }
コード例 #45
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            AggregateFactory   = new AggregateFactory(this);
            WeaponFactory      = new WeaponFactory(this);
            DoorFactory        = new DoorFactory(this);
            RoomFactory        = new RoomFactory(this);
            CollectableFactory = new CollectibleFactory(this);
            WallFactory        = new WallFactory(this);
            EnemyFactory       = new EnemyFactory(this);
            SkillEntityFactory = new SkillEntityFactory(this);
            NPCFactory         = new NPCFactory(this);

            // Initialize Components
            PlayerComponent          = new PlayerComponent();
            LocalComponent           = new LocalComponent();
            RemoteComponent          = new RemoteComponent();
            PositionComponent        = new PositionComponent();
            MovementComponent        = new MovementComponent();
            MovementSpriteComponent  = new MovementSpriteComponent();
            SpriteComponent          = new SpriteComponent();
            DoorComponent            = new DoorComponent();
            RoomComponent            = new RoomComponent();
            HUDSpriteComponent       = new HUDSpriteComponent();
            HUDComponent             = new HUDComponent();
            InventoryComponent       = new InventoryComponent();
            InventorySpriteComponent = new InventorySpriteComponent();
            ContinueNewGameScreen    = new ContinueNewGameScreen(graphics, this);
            EquipmentComponent       = new EquipmentComponent();
            WeaponComponent          = new WeaponComponent();
            BulletComponent          = new BulletComponent();
            PlayerInfoComponent      = new PlayerInfoComponent();
            WeaponSpriteComponent    = new WeaponSpriteComponent();
            StatsComponent           = new StatsComponent();
            EnemyAIComponent         = new EnemyAIComponent();
            NpcAIComponent           = new NpcAIComponent();

            CollectibleComponent = new CollectibleComponent();
            CollisionComponent   = new CollisionComponent();
            TriggerComponent     = new TriggerComponent();
            EnemyComponent       = new EnemyComponent();
            NPCComponent         = new NPCComponent();
            //QuestComponent = new QuestComponent();
            LevelManager             = new LevelManager(this);
            SpriteAnimationComponent = new SpriteAnimationComponent();
            SkillProjectileComponent = new SkillProjectileComponent();
            SkillAoEComponent        = new SkillAoEComponent();
            SkillDeployableComponent = new SkillDeployableComponent();
            SoundComponent           = new SoundComponent();
            ActorTextComponent       = new ActorTextComponent();
            TurretComponent          = new TurretComponent();
            TrapComponent            = new TrapComponent();
            ExplodingDroidComponent  = new ExplodingDroidComponent();
            HealingStationComponent  = new HealingStationComponent();
            PortableShieldComponent  = new PortableShieldComponent();
            PortableStoreComponent   = new PortableStoreComponent();
            ActiveSkillComponent     = new ActiveSkillComponent();
            PlayerSkillInfoComponent = new PlayerSkillInfoComponent();
            MatchingPuzzleComponent  = new MatchingPuzzleComponent();

            Quests = new List <Quest>();


            #region Initialize Effect Components
            AgroDropComponent          = new AgroDropComponent();
            AgroGainComponent          = new AgroGainComponent();
            BuffComponent              = new BuffComponent();
            ChanceToSucceedComponent   = new ChanceToSucceedComponent();
            ChangeVisibilityComponent  = new ChangeVisibilityComponent();
            CoolDownComponent          = new CoolDownComponent();
            DamageOverTimeComponent    = new DamageOverTimeComponent();
            DirectDamageComponent      = new DirectDamageComponent();
            DirectHealComponent        = new DirectHealComponent();
            FearComponent              = new FearComponent();
            HealOverTimeComponent      = new HealOverTimeComponent();
            PsiOrFatigueRegenComponent = new PsiOrFatigueRegenComponent();
            InstantEffectComponent     = new InstantEffectComponent();
            KnockBackComponent         = new KnockBackComponent();
            TargetedKnockBackComponent = new TargetedKnockBackComponent();
            ReduceAgroRangeComponent   = new ReduceAgroRangeComponent();
            ResurrectComponent         = new ResurrectComponent();
            StunComponent              = new StunComponent();
            TimedEffectComponent       = new TimedEffectComponent();
            EnslaveComponent           = new EnslaveComponent();
            CloakComponent             = new CloakComponent();
            #endregion

            base.Initialize();
        }
コード例 #46
0
 // Use this for initialization
 void Awake()
 {
     factory    = EnemyFactory.getInstance();
     gameFlow   = GameSceneController.getInstance() as GameFlow;
     controller = GameSceneController.getInstance();
 }
コード例 #47
0
ファイル: Enemy.cs プロジェクト: siwenRen/Wolf
	public void SetParent (EnemyFactory factory)
	{
		mParent = factory;
	}
コード例 #48
0
 // Use this for initialization
 void Awake()
 {
     factory = EnemyFactory.Instance;
 }
コード例 #49
0
 EnemyFactory getFactory()
 {
     if (factory == null)
         factory = enemyFactory.GetSingleEntity().enemyFactory.factory;
     return factory;
 }
コード例 #50
0
    //public List<Level> levels;
    //public List<Horda>
    //public int[] lvl1 = new int[9] { 0, 0, 0, 0, 0, 0, 0, 0, 0 };


    private void Awake()
    {
        enemyFactory = new EnemyFactory(this, gw);
        enemyFactory.Initialize();
    }
コード例 #51
0
ファイル: Builder.cs プロジェクト: NaClYen/TheTower
    void Awake()
    {
        this.mRoomSamples[0] = Resources.Load<GameObject>("Room Sample 1");
        this.mRoomSamples[1] = Resources.Load<GameObject>("Room Sample 2");

        this.mRoomGap = this.m_NextRoomPt.transform.localPosition - this.m_FirstRoomPt.transform.localPosition;

        mEnemyFactory = new EnemyFactory(m_EnemyRoot);
    }
コード例 #52
0
        public GameLevel(
            GameLevelSettings settings,
            InputManager inputManager,
            TowerFactory towerFactory,
            GraphicsTracker graphicsTracker,
            MouseDragControl mouseDragControl,
            FontsAndColors fontsAndColors,
            GameBus bus,
            GameMapOverlay gameMapOverlay,
            ApplicationLogger logger,
            EnemyFactory enemyFactory)
        {
            _settings           = settings;
            _towerFactory       = towerFactory;
            _graphicsTracker    = graphicsTracker;
            _fontsAndColors     = fontsAndColors;
            _gameMapOverlay     = gameMapOverlay;
            _logger             = logger;
            _enemyFactory       = enemyFactory;
            _stringFormatCenter = new StringFormat
            {
                LineAlignment = StringAlignment.Center,
                Alignment     = StringAlignment.Center
            };
            _gameMapOverlay.SetMap(settings.Map);

            inputManager.OnMouseDragged  += mouseDragControl.InputManagerOnMouseDrag;
            inputManager.OnMouseReleased += mouseDragControl.InputManagerOnMouseRelease;
            _enemySpawner = new EnemySpawner(_time, settings.SpawnFrequency);

            bus.Subscribe <EnemyReachedGoal>(message =>
            {
                if (IsVisible)
                {
                    _gameState = GameState.Lost;
                }
            });

            bus.Subscribe <GameStateChange>(message =>
            {
                if (IsVisible && message.GameLevel == this)
                {
                    _gameState = message.GameState;
                }
            });

            bus.Subscribe <EnemyDespawned>(message =>
            {
                if (IsVisible)
                {
                    CurrentEnemiesNew.Remove(message.Enemy);
                    if (CurrentEnemiesNew.Count == 0 && _monstersLeftToSpawn.Count == 0)
                    {
                        _gameState = GameState.Won;
                    }
                }
            });

            bus.Subscribe <MouseClicked>(message =>
            {
                if (IsVisible && message.EventArgs.Button == MouseButtons.Left)
                {
                    if (_towerBeingPlaced != null)
                    {
                        // There is a tower being placed and mouse was clicked => place it.
                        PlaceTower(_towerBeingPlaced);
                    }
                }
            });

            bus.Subscribe <KeyReleased>(message =>
            {
                if (IsVisible)
                {
                    if (_gameState == GameState.Won)
                    {
                        bus.Publish(new GameStateChange(GameState.Won, this));
                        CurrentEnemiesNew.Clear();
                        return;
                    }
                    if (_gameState == GameState.Lost)
                    {
                        bus.Publish(new GameStateChange(GameState.Lost, this));
                        CurrentEnemiesNew.Clear();
                        return;
                    }

                    switch (message.Key)
                    {
                    case Keys.Space:
                        TogglePause();
                        break;

                    case Keys.D1:
                        StartPlacingTower();
                        break;
                    }
                }
            });
        }
コード例 #53
0
 // Start is called before the first frame update
 void Start()
 {
     poolDictionary = new Dictionary <string, Queue <GameObject> >();
     enemyFactory   = GetComponent <EnemyFactory>();
     FillPools();
 }
コード例 #54
0
 void Awake()
 {
     enemyFactory = GetComponent<EnemyFactory>();
 }
コード例 #55
0
ファイル: Game.cs プロジェクト: Zanion/Ascent_of_Numrock
    void Start()
    {
        PlayerAutomate = false;

        AutomateSpeed = 0.01f;
        AnswerCount = 0;

        DebugScript = GameObject.Find("DebugObject").GetComponent<GameDebugScript>();

        Basic = GameObject.Find("Basic");
        Strong = GameObject.Find("Strong");
        Special = GameObject.Find("Special");

        NoCombatState   = new NoCombatState(this);
        AttackState     = new AttackState(this);
        DefenseState    = new DefenseState(this);
        AnswerState     = new AnswerState(this);
        AnimatingState  = new AnimatingState(this);

        Camera = new CameraController(GameObject.Find("Main Camera"));
        Waypoint = new Waypoint();
        Waypoint.CurrentPosition = new Vector3(-1.65f, 0.9f, -1.0f);
        Waypoint.WaypointPosition = new Vector3(0.9f, 0.9f, -1.0f);
        MonsterWaypoint = new Vector3(3.1f, 1.05f, -1.0f);
        Camera.WaypointPosition = Waypoint.WaypointPosition + new Vector3(1.1f, 0f, -10.0f);
        WaypointCounter = 0;

        UIView = GameObject.Find("GameController").GetComponent<UIView>();

        PlayerFactory = new PlayerFactory();
        EnemyFactory = new EnemyFactory();

        // Player Factory
        Player = PlayerFactory.CreatePlayer("Wizard", Application.loadedLevel, GameObject.Find("Player"));

        Player.WaypointPosition = Waypoint.WaypointPosition;

        State = NoCombatState;
    }
コード例 #56
0
 public static EnemyFactory EnemyFactory()
 {
     return(_enemyFactory ?? (_enemyFactory = new EnemyFactory()));
 }
コード例 #57
0
        private void CompleteMouseAction()
        {
            if (_activeModalBox != null)
            {
                CheckAndHandleModalAction();
            }
            else if (_controlPanel.Contains(_inputHandler.MousePosition))
            {
                CheckAndHandleCommandChange();
            }
            else if (_selected == null)
            {
                switch (_controlPanel.ActiveOption)
                {
                case "Player":
                    _player.WorldPosition = SnapToGrid(_inputHandler.MousePosition + _cameraController.WorldPosition - new Vector2(Definitions.CellSizeInPixels / 2.0f));
                    _player.Visible       = true;
                    break;

                case "Blocks":
                    if (ModalBoxSelectionCanBePlaced("block-selector"))
                    {
                        AddTerrainObject(BlockFactory.CreateBlockFromTextureName(SelectorValue("block-selector")), _inputHandler.MousePosition);
                    }
                    break;

                case "Candies":
                    if (ModalBoxSelectionCanBePlaced("candy-selector"))
                    {
                        AddTerrainObject(CollectableFactory.CreateCandyFromTextureName(SelectorValue("candy-selector")), _inputHandler.MousePosition);
                    }
                    break;

                case "Signs":
                    if (ModalBoxSelectionCanBePlaced("sign-selector"))
                    {
                        AddTerrainObject(SignpostFactory.CreateSignpostFromTextureName(SelectorValue("sign-selector")), _inputHandler.MousePosition);
                    }
                    break;

                case "Flags":
                    if (ModalBoxSelectionCanBePlaced("flag-selector"))
                    {
                        AddTerrainObject(FlagFactory.CreateFlagFromTextureName(SelectorValue("flag-selector")), _inputHandler.MousePosition);
                    }
                    break;

                case "Enemies":
                    if (EnemySelectionCanBePlaced())
                    {
                        AddEnemy(EnemyFactory.CreateEnemyFromTextureName(SelectorValue("enemy-selector")), _inputHandler.MousePosition);
                    }
                    break;

                case "Route":
                    if (ModalBoxSelectionCanBePlaced("route-selector"))
                    {
                        AddTerrainObject(SignpostFactory.CreateRouteMarkerFromTextureName(SelectorValue("route-selector")), _inputHandler.MousePosition);
                    }
                    break;
                }
            }
            else if (_selected is ObjectBase)
            {
                if (!SnapDraggedObjectToGrid())
                {
                    _selected.ReturningToPreviousLocation = true; _selected.Selected = false; _selected = null;
                }
            }
        }
コード例 #58
0
 private void OnBecameInvisible()
 {
     EnemyFactory.ReleaseEnemy(this);
 }
コード例 #59
0
        public Tuple <GameDirector, Canvas, CollisionManager> makeGame(GraphicsDevice graphicsDevice, Controller controller)
        {
            xmlParser        = new XMLParser("test.xml");
            director         = new GameDirector();
            canvas           = new Canvas(new SpriteBatch(graphicsDevice));
            collisionManager = new CollisionManager();

            Hitbox top    = new CollidingRectangle(new Vector2(-50, -450), Vector2.Zero, graphicsDevice.Viewport.Width + 100, 50);
            Hitbox bottom = new CollidingRectangle(new Vector2(-50, graphicsDevice.Viewport.Height + 50), Vector2.Zero, graphicsDevice.Viewport.Width + 100, 50);
            Hitbox left   = new CollidingRectangle(new Vector2(-100, -450), Vector2.Zero, 50, graphicsDevice.Viewport.Height + 500);
            Hitbox right  = new CollidingRectangle(new Vector2(graphicsDevice.Viewport.Width + 50, -450), Vector2.Zero, 50, graphicsDevice.Viewport.Height + 500);

            BoundingObject bTop    = new BoundingObject(null, Vector2.Zero, canvas);
            BoundingObject bBottom = new BoundingObject(null, Vector2.Zero, canvas);
            BoundingObject bLeft   = new BoundingObject(null, Vector2.Zero, canvas);
            BoundingObject bRight  = new BoundingObject(null, Vector2.Zero, canvas);

            bTop.Hitbox    = top;
            bBottom.Hitbox = bottom;
            bLeft.Hitbox   = left;
            bRight.Hitbox  = right;

            collisionManager.addToTeam(bTop, TEAM.UNASSIGNED);
            collisionManager.addToTeam(bBottom, TEAM.UNASSIGNED);
            collisionManager.addToTeam(bLeft, TEAM.UNASSIGNED);
            collisionManager.addToTeam(bRight, TEAM.UNASSIGNED);

            try
            {
                graphicsLoader = GraphicsLoader.makeGraphicsLoader(graphicsDevice);
            }
            catch (ArgumentException)
            {
                graphicsLoader = GraphicsLoader.getGraphicsLoader();
            }
            EnemyFactory enemyFactory = new EnemyFactory();

            xmlParser.Parse();
            List <Encounter> encounters = xmlParser.getEncounterList();

            foreach (var encounter in encounters)
            {
                EncounterEvent encounterEvent = new EncounterEvent(collisionManager, canvas, encounter, director);
                //Console.WriteLine(encounter.timeInMS);
                director.addEvent(encounter.timeInMS, encounterEvent);
            }


            SCREEN_WIDTH  = graphicsDevice.Viewport.Bounds.Width;
            SCREEN_HEIGHT = graphicsDevice.Viewport.Bounds.Height;


            int     offset    = 50;
            Vector2 topMiddle = new Vector2(SCREEN_WIDTH / 2 - offset, -100);
            Vector2 topLeft   = new Vector2(SCREEN_WIDTH / 4 - offset, -100);
            Vector2 topRight  = new Vector2(3 * SCREEN_WIDTH / 4 - offset, -100);

            // sin.healthbar = new HealthBar(sin.Location, new Vector2(8, 0), 85, 90, sin.Health);

            Player player = MakePlayer(controller);

            player.invulnerable = hasCheatMode;
            director.addEvent(0, new PlayerEnter(canvas, player));
            player.DeathEvent += canvas.OnPlayerDeath;

            return(new Tuple <GameDirector, Canvas, CollisionManager>(director, canvas, collisionManager));
        }
コード例 #60
0
        internal State Play(GameDatabase db, State gameState, Boss boss, bool bossHasInstance,
                            StatsManager statsManager, GameTime gameTime, Random random)
        {
            State state = gameState;

            if (db.Players.GetAll().Any(s => s.Score >= 10000))
            {
                state = this.EnableBossMode(boss, bossHasInstance,
                                            db, gameState, gameTime);
            }
            else
            {
                for (int i = 0; i < db.Enemies.GetCount(); i++)
                {
                    BulletsFactory.EnemyShoot(db.Bullets, db.Enemies.GetAll()[i]);
                }

                //Creating entities
                EnemyFactory.CreateEnemies(db.Enemies, random);
                AsteroidFactory.CreateAsteroids(db.Asteroids, random);

                ItemFactory.CreateItems(db.Items, db.Enemies.GetAll().Cast <IGameObject>().ToList(), random);
                ItemFactory.CreateItems(db.Items, db.Asteroids.GetAll().Cast <IGameObject>().ToList(), random);

                // Handle collisions between players and enemy objects
                CollisionHandler.CheckForCollision(db.Asteroids.GetAll().Cast <IGameObject>().ToList(), db.Players.GetAll(), db.Explosions.GetAll());
                CollisionHandler.CheckForCollision(db.Enemies.GetAll().Cast <IGameObject>().ToList(), db.Players.GetAll(), db.Explosions.GetAll());

                // Handle collisions between players and enemy items
                CollisionHandler.CheckPlayerItemCollisions(db.Items.GetAll(), db.Players.GetAll());

                ExplosionFactory.CreateExplosion(db.Explosions, db.Enemies.GetAll().Cast <IGameObject>().ToList());
                ExplosionFactory.CreateExplosion(db.Explosions, db.Asteroids.GetAll().Cast <IGameObject>().ToList());

                //Updating entities
                db.Enemies.GetAll().ForEach(e => e.Update(gameTime));
                db.Asteroids.GetAll().ForEach(a => a.Update(gameTime));
                db.Items.GetAll().ForEach(i => i.Update(gameTime));

                // Cleaning with mr.Proper
                EntityCleanerHandler.ClearEnemies(db.Enemies);
                EntityCleanerHandler.ClearAsteroids(db.Asteroids);
                EntityCleanerHandler.ClearExplosion(db.Explosions);
                EntityCleanerHandler.ClearPlayers(db.Players);
            }

            //Update
            db.Bullets.GetAll().ForEach(b => b.Update(gameTime));
            db.Explosions.GetAll().ForEach(e => e.Update(gameTime));

            statsManager.UpdatePlayersStats(db.Players.GetAll());

            //Handle collisions between bullets and gameobjects
            CollisionHandler.CheckPlayerBulletsCollisions(db.Enemies.GetAll().Cast <IGameObject>().ToList(), db.Bullets.GetAll(), db.Players.GetAll(), db.Explosions.GetAll());
            CollisionHandler.CheckPlayerBulletsCollisions(db.Asteroids.GetAll().Cast <IGameObject>().ToList(), db.Bullets.GetAll(), db.Players.GetAll(), db.Explosions.GetAll());
            CollisionHandler.CheckEnemiesBulletsCollisions(db.Bullets.GetAll(), db.Players.GetAll());

            EntityCleanerHandler.ClearBullets(db.Bullets);

            return(state);
        }