void Start() { if (GamePlayer.IsNetworked()) { gameEntityFactory = GameEntityFactory.instance; } }
void Awake() { instance = this; IGameEntity gameEntity = Create(); if (gameEntity != null) { GameEntityManager.SetPlayerEntity(gameEntity); } }
private GameEntity StartNewGameOrGetExisting(int userId) { GameEntity lastGame = _gameRepository.GetLatestGameForUser(userId); // When a user never has played a game before, it'll be null if (null == lastGame || !MayTheGameHaveMoreRounds(lastGame.Id)) { lastGame = GameEntityFactory.Create(userId, DateTime.Now); _gameRepository.Create(lastGame); } return(lastGame); }
/* Turns a random tile on the row into a block to prevent large gaps in the level. */ private void FillOpenRow(int currentColumn, int row) { Random rnd; if (seed.Equals("")) { rnd = new Random(); } else { rnd = new Random(seed.GetHashCode()); } int selectedColumn = rnd.Next(0, world.GetLength(0)); GameService.Instance.EntityGameWorld[selectedColumn, row] = GameEntityFactory.NewBlock(new Vector3((selectedColumn * distanceBetweenColumns), (0), (row * distanceBetweenRows)), AssetManager.Instance.CreateTexture(Color.BlueViolet, gameManager.game.GraphicsDevice), GameEntityFactory.BLOCK); world[selectedColumn, row] = 1; }
/* * For all columns and rows, selects and creates worldgen entities for the world matrix */ private void PopulateWorld(int nColumns, int nRows) { Random rnd; int weightTotal = GetWeightTotal(); WorldgenEntities = WorldgenEntities.OrderBy(o => o.SelectionValue).ToList(); GameService.Instance.EntityGameWorld = new Entity[nColumns, nRows]; if (seed.Equals("")) { rnd = new Random(); } else { rnd = new Random(seed.GetHashCode()); } for (int column = 0; column < nColumns; column++) { for (int row = 0; row < nRows; row++) { if (row == 0) //First row is always filled with blocks as the players start there { GameService.Instance.EntityGameWorld[column, row] = GameEntityFactory.NewBlock(new Vector3((column * distanceBetweenColumns), (0), (row * distanceBetweenRows)), AssetManager.Instance.CreateTexture(Color.BlueViolet, gameManager.game.GraphicsDevice), GameEntityFactory.BLOCK); world[column, row] = 1; } else if (row == nRows - 1) //Last row should always be the goal { GameService.Instance.EntityGameWorld[column, row] = GameEntityFactory.NewGoalBlock(new Vector3((column * distanceBetweenColumns), (0), (row * distanceBetweenRows)), AssetManager.Instance.CreateTexture(Color.Gold, gameManager.game.GraphicsDevice)); world[column, row] = 2; } else { //Create a new random entity for the tile CreateSelectedWorldEntity((float)rnd.NextDouble(), column, row, new Vector3((column * distanceBetweenColumns), (0), (row * distanceBetweenRows))); } } } }
/// <summary> /// The host is always the red player and always on the left side /// </summary> public void Initialize() { Entity local; Entity remote; this.connectionManager = gameManager.NetworkConnectionManager; var HostPosition = new Vector3(10, 45, -10); var ClientPosition = new Vector3(-100, 45, 10); if (connectionManager.IsHost) { local = GameEntityFactory.NewLocalPlayer("Models/Blob", 0, HostPosition, new Vector3(0, 0, -150), viewport.AspectRatio, true, AssetManager.Instance.CreateTexture(Color.Red, gameManager.game.GraphicsDevice)); GameEntityFactory.NewParticleSettingsEntity(local, 10, 1, "smoke"); remote = GameEntityFactory.NewBasePlayer("Models/Blob", 1, ClientPosition, AssetManager.Instance.CreateTexture(Color.Blue, gameManager.game.GraphicsDevice), GameEntityFactory.REMOTE_PLAYER); } else { local = GameEntityFactory.NewLocalPlayer("Models/Blob", 0, ClientPosition, new Vector3(0, 0, -150), viewport.AspectRatio, true, AssetManager.Instance.CreateTexture(Color.Blue, gameManager.game.GraphicsDevice)); GameEntityFactory.NewParticleSettingsEntity(local, 10, 1, "smoke"); remote = GameEntityFactory.NewBasePlayer("Models/Blob", 1, HostPosition, AssetManager.Instance.CreateTexture(Color.Red, gameManager.game.GraphicsDevice), GameEntityFactory.REMOTE_PLAYER); } GameEntityFactory.NewOutOfBounds(new Vector3(-10000, -1000, -10000), new Vector3(10000, -50, 10000)); NetworkHandlingSystem networkSystem = new NetworkHandlingSystem(connectionManager.GetPeer()); networkSystem.InitPlayers(); SystemManager.Instance.AddToUpdateables(networkSystem); particleSystem = new ParticleSystem(gameManager.game.GraphicsDevice); particleSystem.InitializeParticleSystem(ComponentManager.Instance.ConcurrentGetComponentOfEntity <ParticleSettingsComponent>(local)); particleCreationSystem = new ParticleCreationSystem(particleSystem); SystemManager.Instance.AddToDrawables(particleSystem); SystemManager.Instance.AddToUpdateables(particleSystem, particleCreationSystem); AudioManager.Instance.ClearSongs(); AudioManager.Instance.EnqueueSongs("playMusic1", "playMusic2"); InitWorld(); }
public void Initialize() { var playerEntity = GameEntityFactory.NewLocalPlayer("Models/Blob", 0, new Vector3(10, 45, 0), new Vector3(0, 500, -100), viewport.AspectRatio, true, AssetManager.Instance.CreateTexture(Color.Red, gameManager.game.GraphicsDevice)); //GameEntityFactory.NewParticleSettingsEntity(playerEntity, 100, 2, "fire"); GameEntityFactory.NewParticleSettingsEntity(playerEntity, 10, 1, "smoke"); GameEntityFactory.NewAiPlayer("Models/Blob", new Vector3(-100, 45, 0), AssetManager.Instance.CreateTexture(Color.Honeydew, gameManager.game.GraphicsDevice)); GameEntityFactory.NewOutOfBounds(new Vector3(-10000, -1000, -10000), new Vector3(10000, -50, 10000)); InitWorld(); particleSystem = new ParticleSystem(gameManager.game.GraphicsDevice); particleSystem.InitializeParticleSystem(ComponentManager.Instance.ConcurrentGetComponentOfEntity <ParticleSettingsComponent>(playerEntity)); particleCreationSystem = new ParticleCreationSystem(particleSystem); SystemManager.Instance.AddToDrawables(particleSystem); SystemManager.Instance.AddToUpdateables(particleSystem, particleCreationSystem); AudioManager.Instance.ClearSongs(); AudioManager.Instance.EnqueueSongs("playMusic1", "playMusic2"); }
public Entity RunWorldGenEntityCreator(GameManager gameManager, Vector3 position) { return(GameEntityFactory.NewBlock(position, AssetManager.Instance.CreateTexture(Color.BlueViolet, gameManager.game.GraphicsDevice), GameEntityFactory.BLOCK)); }