示例#1
0
        /// <summary>
        /// Constructs a new PacMan
        /// </summary>
        /// <param name="textureAsset">The path to the texture of this pacman</param>
        /// <param name="startCell">the starting cell of this  player</param>
        /// <param name="level">Reference to the level</param>
        /// <param name="controller">The controller for this player</param>
        /// <param name="startDirection">The start heading</param>
        /// <param name="speed">Defines how fast this player can move in cells per second</param>
        /// <param name="frameSize">Sets the framesize for the players texture</param>
        public PacMan(String textureAsset, Cell startCell, Level level, Controller
            controller, Direction startDirection, float speed,
                      Point frameSize)
            : base(textureAsset, startCell, level, startDirection, speed, controller, frameSize)
        {
            framePosition = new Point(0, 0);

            position = base.CurrentCell.Position;
            this.lives = 5;
        }
示例#2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="textureAsset">The path to the texture of this ghost</param>
        /// <param name="startCell">The starting cell for this ghost</param>
        /// <param name="level">The level</param>
        /// <param name="startDirection">The starting direction for this ghost</param>
        /// <param name="speed">The speed in cells per secon</param>
        /// <param name="frameSize">The framesize of a frame from the texture</param>
        /// <param name="color">The default color of this ghost</param>
        /// <param name="controller">A controller for this ghost</param>
        public Ghost(String textureAsset, Cell startCell, Level level, Direction startDirection, float speed, Point frameSize, Color color, Controller controller)
            : base(textureAsset, startCell, level, startDirection, speed, controller, frameSize)
        {
            framePosition = new Point(1, 1);
            position = startCell.Position;
            this.color = color;
            this.defaultColor = this.color;

            GhostBehaviour = EGhostBehaviour.Hunt;
        }
示例#3
0
        public GhostController(Level level, GhostAi ghostAi, int id)
            : base(id)
        {
            this.level = level;
            Name = ghostAi.Name;
            this.ghostAi = ghostAi;

            currentCell = Cell.Empty;
            lastCell = Cell.Empty;

            possibleMoves = new List<Cell>();
        }
示例#4
0
        /// <summary>
        /// Parses a level from a list of stringarrays
        /// </summary>
        /// <param name="parsedData">the stringarrays to parse</param>
        /// <returns>A generated level</returns>
        private Level parseLevel(List<string[]> parsedData)
        {
            int height = parsedData.Count;
            int width = parsedData[0].Length;

            Level level = new Level(width, height, new Vector2(0, 0));

            CellFactory.CellFactory cellFactory = new CellFactory.CellFactory();

            for(int i=0; i<height; i++)
            {
                for(int j=0; j<width; j++)
                {
                    Cell setcell = cellFactory.CreateCell(j, i, parsedData[i].ElementAt(j));
                    level.setCell(setcell, i, j);
                }
            }

            return level;
        }
示例#5
0
        /// <summary>
        /// Constructor for a movable object
        /// </summary>
        /// <param name="textureAsset">The path to the texture that this object has to load</param>
        /// <param name="startCell">The starting cell of this MO</param>
        /// <param name="level">Reference to the level</param>
        /// <param name="startDirection">The direction this MO is facing at startup</param>
        /// <param name="cellsPerSecond">How many cells per second this MO should pass</param>
        /// <param name="controller">The controller for this object</param>
        /// <param name="frameSize">The size of the frame of this MO</param>
        public MovableObject(String textureAsset, Cell startCell, Level level, Direction startDirection, float cellsPerSecond, Controller controller, Point frameSize)
            : base(textureAsset)
        {
            currentDirection = startDirection;
            lastDirection = startDirection;

            currentCell = startCell;
            this.startCell = startCell;

            this._cellsPerSecond = CalculateSpeedFactor(cellsPerSecond);
            this._defaultCellsPerSecond = this._cellsPerSecond;
            this.level = level;

            this.frameSize = frameSize;

            speedVector = Vector2.Zero;
            lastSpeedVector = Vector2.Zero;

            soundEffects = new Dictionary<string, Cue>();

            this.PowerUpTimer = 0;
            this.controller = controller;
        }
示例#6
0
        public override void Initialize()
        {
            levelParser = new LevelParser();
            level = levelParser.generateLevel(@"Content\Level1.csv", 1);

            camera = new Camera(1, Vector2.Zero, 0, false, Game.GraphicsDevice);

            //pacman = new PacMan(level.getCell(1, 1), level,
            //                                                new PlayerController(Direction.Down, "Player 1", PlayerIndex.One, ), Direction.None, 2f,
            //                                                new Point(50, 50));
            //pacman.Scale = 1;

            base.Initialize();
        }
示例#7
0
 /// <summary>
 /// Creates a new Ghost
 /// </summary>
 /// <param name="textureAsset">The path to the texture of this ghost</param>
 /// <param name="startCell">The starting cell for this ghost</param>
 /// <param name="level">The level</param>
 /// <param name="startDirection">The starting direction for this ghost</param>
 /// <param name="speed">The speed in cells per secon</param>
 /// <param name="frameSize">The framesize of a frame from the texture</param>
 /// <param name="color">The default color of this ghost</param>
 /// <param name="ghostAi">The ghostAi for this ghost</param>
 public Ghost(String textureAsset, Cell startCell, Level level, Direction startDirection, float speed, Point frameSize, Color color, GhostAi ghostAi)
     : this(textureAsset, startCell, level, startDirection, speed, frameSize, color, new GhostController(level, ghostAi, 1))
 {
 }
示例#8
0
 public void LoadEffect(Level level)
 {
     //load nothing
 }