//creates a new AI of given level public AI(int lvl, Pills p) { level = lvl; counter = 0; random = new Random(); targetAcquired = false; pills = p; hardIsUsingMedium = false; wallHitCounter = 0; moveToRandomDirection = false; yetAnotherCounter = 0; }
//creates a new player to a given (x,y) position public Player(int x, int y, int width, int height, string n, Map m, bool computer, int aiLevel, Pills pills) { position = new Rectangle(x, y, 32, 32); startPosition = position; direction = new Vector2(x, y); map = m; name = n; screenWidth = width; screenHeight = height; score = 0; speed = 8; stuckTimer = 0; inputEnabled = true; towardsOneWay = false; playerIsAI = computer; ai = new AI(aiLevel, pills); }
//creates a new gameplay screen public GameplayScreen(string player1Name, string player2Name, string nameOfTheMap, bool player1IsAI, bool player2IsAI, int player1AILevel, int player2AILevel) { //times for the transition TransitionOnTime = TimeSpan.FromSeconds(0.5); TransitionOffTime = TimeSpan.FromSeconds(0.5); //sets the escape-key as the pause button and enter as the restart game button pauseAction = new InputAction(new Keys[] { Keys.Escape }, true); endGameAction = new InputAction(new Keys[] { Keys.Enter }, true); screenWidth = 1024; screenHeight = 768; p1name = player1Name; p2name = player2Name; mapName = nameOfTheMap; p1ai = player1IsAI; p2ai = player2IsAI; p1aiLevel = player1AILevel; p2aiLevel = player2AILevel; clock = new Timer(20.0f); //fps = new FPS(screenWidth); map = new Map(mapName); pills = new Pills(map, 100, screenWidth, screenHeight, 32); player1 = new Player(0, 0, screenWidth, screenHeight, p1name, map, p1ai, p1aiLevel, pills); player2 = new Player(screenWidth - 32, screenHeight - 32, screenWidth, screenHeight, p2name, map, p2ai, p2aiLevel, pills); scores = new Scores(screenWidth); controls = new PlayerControls(); gameEnds = false; }