Exemplo n.º 1
0
        private void OnDisasterTick(object sender, object o)
        {
            if (entityManager.Count < maxEntities)
            {
                // spawn a disaster
                Random randDis = new Random();
                switch (randDis.Next(1, 3))
                {
                case 1:
                    BaseEntity                   enemy      = new Meteor();
                    Systems.SpawnSystem          newSpawn   = new Systems.SpawnSystem();
                    Components.PositionComponent spawnPoint = newSpawn.Spawn(EntityType.Meteor);
                    enemy.sprite.Margin = new Thickness((double)spawnPoint.getXPos(), (double)spawnPoint.getYPos(), 0, 0);
                    Canvas.SetZIndex(enemy.sprite, 7);
                    GameSpace.Children.Add(enemy.sprite);     //ADDING THE ENTITY'S XAML ELEMENT TO THE SCREEN
                    int index = GameSpace.Children.IndexOf(enemy.sprite);
                    entityManager.Add(enemy);
                    break;

                case 2:
                    BaseEntity                   lightningEnemy      = new Lightning();
                    Systems.SpawnSystem          newLightningSpawn   = new Systems.SpawnSystem();
                    Components.PositionComponent lightningSpawnPoint = newLightningSpawn.Spawn(EntityType.Lightning);
                    lightningEnemy.sprite.Margin = new Thickness((double)lightningSpawnPoint.getXPos(), (double)lightningSpawnPoint.getYPos(), 0, 0);
                    Canvas.SetZIndex(lightningEnemy.sprite, 7);
                    GameSpace.Children.Add(lightningEnemy.sprite);     //ADDING THE ENTITY'S XAML ELEMENT TO THE SCREEN
                    int lightningIndex = GameSpace.Children.IndexOf(lightningEnemy.sprite);
                    entityManager.Add(lightningEnemy);
                    break;
                }

                /*
                 * List<BaseEntity> tempList = entityManager;
                 * for (int i = 0; i < tempList.Count; i++)
                 * {
                 *  if (tempList[i].EntType == EntityType.Lightning)
                 *  {
                 *
                 *      BaseEntity newFire = new Fire();
                 *      newFire.sprite.Margin = new Thickness(tempList[i].sprite.Margin.Left, tempList[i].sprite.Margin.Left, 0, 0);
                 *      Canvas.SetZIndex(newFire.sprite, 7);
                 *      GameSpace.Children.Add(newFire.sprite); //ADDING THE ENTITY'S XAML ELEMENT TO THE SCREEN
                 *      int index = GameSpace.Children.IndexOf(newFire.sprite);
                 *      entityManager.Add(newFire);
                 *
                 *  }
                 * }*/


                Components.DamageComponent hostileDamage = new Components.DamageComponent(); //Test Component
                hostileDamage.setInflictableDamage(10);
                InflictVillageDamage(hostileDamage);                                         //Damages Village
            }
        }
Exemplo n.º 2
0
        //Modifies Village's health
        private void InflictVillageDamage(Components.DamageComponent hostileDamage)
        {
            string curHealth = this.HealthBlock.Text;

            this.HealthBlock.Text = damageVillage.InflictDamage(curHealth, hostileDamage);
        }