Exemplo n.º 1
0
        private static void MakeExplosions()
        {
            EntityTemplateManager.AddTemplate(
                new EntityTemplate(
                    "Explosion",
                    new Placement()
            {
                Layer   = 4,
                Visible = true,
            },
                    new Aspect()
            {
                ModelNameId = "Explosion".CRC32Hash(),
                Tint        = Color.White,
                Size        = new Vector2(1.7f),
            },
                    new Explosion()
            {
                Countdown            = GameConstants.ExplosionDuration,
                PropagationCountDown = GameConstants.PropagationTime,
            },
                    new FrameAnimation()
            {
                FrameRate = GameConstants.ExplosionFrameRate,
            }
                    )
                );

            EntityTemplateManager.AddTemplate(
                new EntityTemplate(
                    "ExplosionBlue",
                    new Placement()
            {
                Layer   = 4,
                Visible = true,
            },
                    new Aspect()
            {
                ModelNameId = "ExplosionBlue".CRC32Hash(),
                Tint        = Color.White,
                Size        = new Vector2(1.7f),
            },
                    new Explosion()
            {
                Countdown            = GameConstants.ExplosionDuration,
                PropagationCountDown = GameConstants.PropagationTime,
            },
                    new FrameAnimation()
            {
                FrameRate = GameConstants.ExplosionFrameRate,
            }
                    )
                );
        }
Exemplo n.º 2
0
 private static void MakeCharacter(string name, Color tint, int number, InputMap inputMap)
 {
     EntityTemplateManager.AddTemplate(
         new EntityTemplate(
             name,
             new Placement()
     {
         Layer   = 3,
         Visible = true,
     },
             new Aspect()
     {
         ModelNameId = "Man".CRC32Hash(),
         Tint        = tint,
         Size        = new Vector2(1.1f),
     },
             new Physics()
     {
         BoundingVolumeType = BoundingVolumeType.Circle,
         IsDynamic          = true,
         Size = 0.95f,
         CollisionCategories = CollisionCategory.AllPlayers,
         CollidesWidth       = CollisionCategory.Bricks | CollisionCategory.Bombs,
     },
             inputMap,
             new ExplosionImpact()
     {
         Barrier           = ExplosionBarrier.None,
         ShouldSendMessage = true,
     },
             new InputHandlers("DropBomb", "MovePlayer")
     {
     },
             // TODO: Update with a better handler that does animations, etc...
             new MessageHandler(new MessageAndHandler(Messages.InExplosion, "KillPlayer".CRC32Hash()),
                                new MessageAndHandler(Messages.DirectKill, "KillPlayer".CRC32Hash()))
     {
     },
             new PlayerInfo()
     {
         MaxSpeed = GameConstants.PlayerDefaultSpeed,
         PermittedSimultaneousBombs = 1,
         BombState = new BombState()
         {
             PropagationDirection = PropagationDirection.NESW,
             Range = 1,
         },
         PlayerNumber = number,
     }
             )
         );
 }
Exemplo n.º 3
0
 private static void MakeGame()
 {
     EntityTemplateManager.AddTemplate(
         new EntityTemplate(
             "MainGame",
             new GameState()
     {
         TimeRemaining = GameConstants.GameLength
     },
             new InputMap(
                 new KeyValuePair <Keys, int>[]
     {
         new KeyValuePair <Keys, int>(Keys.Space, InputActions.RestartGame),
     }
                 )
     {
     }
             // We'll add the RestartGame action handler dynamically after
             )
         );
 }
Exemplo n.º 4
0
        private static void MakePowerUp(PowerUpType type, string name, string model, string sound, Color tint)
        {
            ScriptContainer scriptContainer = new ScriptContainer("Wiggle".CRC32Hash())
            {
            };

            Scripts.Scripts.Wiggle_Init(scriptContainer, period: GameConstants.PowerUpWigglePeriod, extent: GameConstants.PowerUpWiggleExtent);

            EntityTemplateManager.AddTemplate(
                new EntityTemplate(
                    name,
                    new Placement()
            {
                Layer   = 2,
                Visible = true,
            },
                    new Aspect()
            {
                ModelNameId = model.CRC32Hash(),
                Tint        = tint,
                Size        = new Vector2(1.12f),
            },
                    new PowerUp()
            {
                Type    = type,
                SoundId = sound.CRC32Hash()
            },
                    new ExplosionImpact()
            {
                Barrier           = ExplosionBarrier.None,
                ShouldSendMessage = true,
            },
                    scriptContainer
                    )
                );
        }
Exemplo n.º 5
0
        private static void MakeBricks()
        {
            // Hard blocks are permanent.
            EntityTemplateManager.AddTemplate(
                new EntityTemplate(
                    "HardBlock",
                    new Placement()
            {
                Layer   = 1,
                Visible = true,
            },
                    new Aspect()
            {
                ModelNameId = "Brick".CRC32Hash(),
                Tint        = new Color(196, 196, 196, 255),
                Size        = new Vector2(1.12f),
            },
                    new ExplosionImpact()
            {
                Barrier = ExplosionBarrier.Hard,
            },
                    new Physics()
            {
                BoundingVolumeType = BoundingVolumeType.Box,
                IsDynamic          = false,
                Size = 1f,
                CollisionCategories = CollisionCategory.Bricks,
                CollidesWidth       = CollisionCategory.AllPlayers,
            }
                    )
                );

            // Soft blocks disintegrate when hit by an explosion.
            EntityTemplateManager.AddTemplate(
                new EntityTemplate(
                    "SoftBlock",
                    new Placement()
            {
                Layer   = 1,
                Visible = true,
            },
                    new Aspect()
            {
                ModelNameId = "SoftBrick".CRC32Hash(),
                Tint        = new Color(128, 128, 128, 255),
                Size        = new Vector2(1.12f),
            },
                    new ExplosionImpact()
            {
                Barrier           = ExplosionBarrier.Soft,
                ShouldSendMessage = true,
            },
                    new Physics()
            {
                BoundingVolumeType = BoundingVolumeType.Box,
                IsDynamic          = false,
                Size = 1f,
                CollisionCategories = CollisionCategory.Bricks,
                CollidesWidth       = CollisionCategory.AllPlayers,
            },
                    new MessageHandler(
                        new MessageAndHandler(Messages.HitByInitialExplosion, "DestroyOnExplosionAndRevealPowerUp".CRC32Hash())
                        )
            {
            }
                    )
                );

            // Death blocks fall from the sky at the end.
            EntityTemplateManager.AddTemplate(
                new EntityTemplate(
                    "DeathBlock",
                    new Placement()
            {
                Layer   = 5,
                Visible = true,
            },
                    new Aspect()
            {
                ModelNameId = "EndBrick".CRC32Hash(),
                Tint        = new Color(196, 196, 196, 255),
                Size        = new Vector2(1.12f),
            },
                    new ExplosionImpact()
            {
                Barrier = ExplosionBarrier.Hard,
            },
                    new Physics()
            {
                BoundingVolumeType = BoundingVolumeType.Box,
                IsDynamic          = false,
                Size = 1f,
                CollisionCategories = CollisionCategory.Bricks,
                CollidesWidth       = CollisionCategory.AllPlayers,
            }
                    )
                );
        }
Exemplo n.º 6
0
        private static void MakeBombs()
        {
            ScriptContainer scriptContainer1 = new ScriptContainer("Pulsate".CRC32Hash())
            {
            };

            Scripts.Scripts.Pulsate_Init(scriptContainer1, period: GameConstants.PulsationPeriod);

            EntityTemplateManager.AddTemplate(
                new EntityTemplate(
                    "BasicBomb",
                    new Placement()
            {
                Layer   = 2,
                Visible = true,
            },
                    new Aspect()
            {
                ModelNameId = "Bomb".CRC32Hash(),                    // Possibly Over-ridden when we create the bomb.
                Tint        = Color.White,
                Size        = new Vector2(1.12f),
            },
                    new ExplosionImpact()
            {
                Barrier           = ExplosionBarrier.None,
                ShouldSendMessage = true,
            },
                    new MessageHandler(
                        new MessageAndHandler(Messages.HitByInitialExplosion, "TriggerOnExplosion".CRC32Hash())
                        )
            {
            },
                    new Bomb()
            {
                Countdown = GameConstants.BombSecondsToExplode,
                // Other things are filled in when we create the bomb.
            },
                    scriptContainer1,
                    new Physics()
            {
                IsSensor           = true,
                BoundingVolumeType = BoundingVolumeType.Box,
                Size                = 1f,
                IsDynamic           = false, // REVIEW: We'll need to modify this in the case of throwing bombs.
                CollisionCategories = CollisionCategory.Bombs,
                CollidesWidth       = CollisionCategory.AllPlayers,
            }
                    )
                );

            // Land mines are different enough that we'll use a different prefab
            ScriptContainer scriptContainer2 = new ScriptContainer("LandMineRiseFall".CRC32Hash())
            {
            };

            Scripts.Scripts.LandMineRiseFall_Init(scriptContainer2, GameConstants.LandMineFuseTime);

            EntityTemplateManager.AddTemplate(
                new EntityTemplate(
                    "LandMineBomb",
                    new Placement()
            {
                Layer   = 2,
                Visible = true,
            },
                    new Aspect()
            {
                ModelNameId = "LandMine".CRC32Hash(),                    // Possibly Over-ridden when we create the bomb.
                Tint        = new Color(196, 196, 196, 255),
                Size        = new Vector2(1.12f),
            },
                    new ExplosionImpact()
            {
                Barrier           = ExplosionBarrier.None,
                ShouldSendMessage = true,
            },
                    new MessageHandler(
                        new MessageAndHandler(Messages.HitByInitialExplosion, "TriggerOnExplosion".CRC32Hash())
                        )
            {
            },
                    new Bomb()
            {
                Countdown = GameConstants.BombSecondsToExplode,
                // Other things are filled in when we create the bomb.
            },
                    scriptContainer2
                    // No physics for land mines, since we can walk over them.
                    )
                );
        }