Exemplo n.º 1
0
        void CreateEntities()
        {
            Entity playerShipEntity = PlayerShipEntity.Create(Engine,
                                                              Content.Load <Texture2D>(Constants.Resources.TEXTURE_PLAYER_SHIP),
                                                              new Vector2(0, 0));
            Entity playerShieldEntity = PlayerShieldEntity.Create(Engine,
                                                                  Content.Load <Texture2D>(Constants.Resources.TEXTURE_PLAYER_SHIELD), playerShipEntity);

            playerShipEntity.GetComponent <PlayerShipComponent>().shipShield = playerShieldEntity;
            playerShieldEntity.AddComponent(new PlayerComponent(Player));

            Entity topEdge    = EdgeEntity.Create(Engine, new Vector2(0, Constants.Global.WINDOW_HEIGHT / 2), new Vector2(Constants.Global.WINDOW_WIDTH, 1), new Vector2(0, -1));
            Entity leftEdge   = EdgeEntity.Create(Engine, new Vector2(-Constants.Global.WINDOW_WIDTH / 2, 0), new Vector2(1, Constants.Global.WINDOW_HEIGHT), new Vector2(1, 0));
            Entity bottomEdge = EdgeEntity.Create(Engine, new Vector2(0, -Constants.Global.WINDOW_HEIGHT / 2), new Vector2(Constants.Global.WINDOW_WIDTH, 1), new Vector2(0, 1));
            Entity rightEdge  = EdgeEntity.Create(Engine, new Vector2(Constants.Global.WINDOW_WIDTH / 2, 0), new Vector2(1, Constants.Global.WINDOW_HEIGHT), new Vector2(-1, 0));
        }
Exemplo n.º 2
0
        private void SpawnPlayer(Player player, Vector2 position, Color color)
        {
            Entity playerShipEntity = PlayerShipEntity.Create(SharedState.Engine, position, color);

            SuperShieldDisplayEntity.Create(SharedState.Engine, playerShipEntity);

            PlayerShipComponent playerShipComp = playerShipEntity.GetComponent <PlayerShipComponent>();

            // Default
            playerShipComp.AddShield(PlayerShieldEntity.Create(SharedState.Engine, playerShipEntity, MathHelper.ToRadians(0.0f), true));
            // Super shields
            playerShipComp.AddShield(PlayerShieldEntity.Create(SharedState.Engine, playerShipEntity, MathHelper.ToRadians(90.0f), false));
            playerShipComp.AddShield(PlayerShieldEntity.Create(SharedState.Engine, playerShipEntity, MathHelper.ToRadians(180.0f), false));
            playerShipComp.AddShield(PlayerShieldEntity.Create(SharedState.Engine, playerShipEntity, MathHelper.ToRadians(270.0f), false));

            playerShipEntity.AddComponent(new PlayerComponent(player));

            // Queue an event
            EventManager.Instance.QueueEvent(new PlayerShipSpawnEvent(playerShipEntity, position));
        }