コード例 #1
0
ファイル: Program.cs プロジェクト: thilianny/GameSimulate
        private static void Main(string[] args)
        {
            var cristiano = PlayerCreator.Create(Sport.Football, "Cristiano", 93);

            var real  = TeamCreator.Create(Sport.Football, "Real Madrid FC", 92);
            var barca = TeamCreator.Create(Sport.Football, "FC Barcelona", 90);

            var clasico = GameCreator.TeamGame.Create(real, barca);

            clasico.Simulate();
        }
コード例 #2
0
        public GamePlayState(GameState gameState)
        {
            _gameState = gameState;

            // setup components
            _gameState = new GameState();

            // setup systems
            var systems = new Systems.System[]
            {
                new PlayerInputSystem("PlayerInput", _gameState),
                new MovementSystem("Movement", _gameState),
                new ClampToViewportSystem("ClampToViewport", _gameState),
                new DestroyIfOutsideViewportSystem("DestroyIfOutsideViewport", _gameState),
                new SetBoundingBoxSystem("SetBoundingBox", _gameState),
                new PlayerFireProjectileSystem("FireProjectile", _gameState),
                new EnemyFireProjectileSystem("EnemyFireProjectile", _gameState),
                new EnemyChaseSystem("EnemyChase", _gameState),
                new AnimationSystem("Animation", _gameState),
                new PlayerCollisionDetectionSystem("PlayerCollisionDetection", _gameState),
                new ProjectileCollisionDetectionSystem("ProjectileCollisionDetection", _gameState),
                new RestorePlayerSystem("KillPlayer", _gameState),
                new CollisionResolutionSystem("CollisionResolution", _gameState),
                new EnemySpawnSystem("EnemySpawn", _gameState),
                new IsGameOverSystem("IsGameOver", _gameState),
                new RenderingSystem("Rendering", _gameState)
            };

            _systems = new Systems.Systems(_gameState, systems);

            _hud = new Hud(_gameState);

            _soundEffectPlayer = new SoundEffectPlayer();
            _renderer          = new Renderer();

            PlayerCreator.Create(_gameState, 0, 3);
            EnemySpawnerCreator.Create(_gameState);
        }
コード例 #3
0
        protected override void ProcessOneEntity(int entityId, float deltaTime)
        {
            // gather data for selection
            var player = GameState.GameData.Players[entityId];

            // selection
            if (player == null || player.Value.Status != PlayerStatus.Destroyed)
            {
                return;
            }

            // process data
            var transform = GameState.GameData.Transforms[entityId].Value;

            transform.Rotation += _deathRotationSpeed * deltaTime;

            var p = player.Value;

            if (!p.DeathOnCooldown)
            {
                p.DeathCooldownTime = 0.0f;
                p.Lives--;
                transform.Rotation = 0.0f;
                p.Status           = PlayerStatus.Alive;

                GameState.ClearState();

                PlayerCreator.Create(GameState, p.Score, p.Lives.GetValueOrDefault());
                EnemySpawnerCreator.Create(GameState);
            }

            p.DeathCooldownTime -= deltaTime;

            // update data
            GameState.GameData.Players[entityId]    = p;
            GameState.GameData.Transforms[entityId] = transform;
        }