public void startGame(string mapName, bool[] playersPlaying) { //initialRoundTime = 300; roundTime = initialRoundTime; GameTime gameTime = new GameTime(); roundStartTime = gameTime.TotalGameTime.Seconds; loadMap("Content/maps/" + mapName + ".map"); List<PlayerIndex> playerIndicesPlaying = new List<PlayerIndex>(); for (int i = 0; i < playersPlaying.Length; ++i) if (playersPlaying[i]) playerIndicesPlaying.Add(PlayerIndex.One + i); players = new Player[playerIndicesPlaying.Count]; PlayerIndex[] playerIndices = new PlayerIndex[playerIndicesPlaying.Count]; for (int i = 0; i < players.Length; ++i) { players[i] = new Player(this, playerIndicesPlaying[i], mapEngine.playerPoss[aiEngine.random.Next(mapEngine.playerPoss.Count)]); playerIndices[i] = playerIndicesPlaying[i]; } renderEngine = new RenderEngine(this, playerIndices); //once the map is loaded the player has a position, so take it for the test agent for (int i = 0; i < 2; ++i) aiEngine.agents.Add(new AIAgent(this, players[0].getPosition())); currentState = GameState.GameScreen; }
public void applyBlink(float elapsedTime, Player player, Vector3 move) { BoundingBox playerBoundingBox = player.getBoundingBox(); Vector3 cent = center(playerBoundingBox); //fix the move with a hitscan HitScan hs = hitscan(cent, Vector3.Normalize(move), null); if (hs != null && hs.Distance() < Math.Sqrt(Vector3.Dot(move, move))) move = Vector3.Normalize(move) * hs.Distance() + hs.collisionFace.plane.getNormal()*70; Vector3 offset = center(playerBoundingBox) - player.getPosition(); Vector3 playerRadius = size(playerBoundingBox) * 0.5f; Vector3 basePoint = toESpace(playerRadius, cent); Vector3 evelocity = toESpace(playerRadius, move); Vector3 pos = collideWithWorld(playerRadius, basePoint, evelocity, 0, player); player.setPosition(toWorldSpace(playerRadius, pos) - offset); }