// Use this for initialization void Start() { cam = GameObject.Find("Main Camera").GetComponent <Camera>(); marker = GameObject.Find("MouseMarkerSphere"); playerCharacter = GameObject.Find("PlayerCharacter"); markerScript = marker.GetComponent <MouseMarker>(); playerScript = playerCharacter.GetComponent <PlayerController>(); }
public Mouse(int graphicX, int graphicY, int x, int y, int width, int height, char marker) { this.graphicX = graphicX; this.graphicY = graphicY; this.X = x; this.Y = y; this.newX = this.X; this.newY = this.Y; this.Width = width; this.Height = height; this.Bounds = new Rectangle(this.graphicX, this.graphicY, this.Width, this.Height); this.marker = marker; this.direction = (MouseMarker)marker; this.mouseImage = GraphicMazeGame.Properties.Resources.mouseRight; }
public void move(MouseMarker newDirection) { this.direction = newDirection; this.marker = (char) this.direction; switch (this.direction) { case MouseMarker.LEFT: this.newX--; break; case MouseMarker.UP: this.newY--; break; case MouseMarker.RIGHT: this.newX++; break; case MouseMarker.DOWN: this.newY++; break; } }
/// <summary> /// Public method of maze to move the internal mouse /// An enum of directionality is used to seperate keyboard /// </summary> /// <param name="newDirection"></param> public void moveMouse(MouseMarker newDirection) { //set newX and newY this.mouse.move(newDirection); if(this.mouse.getNewY() >= 0 && this.mouse.getNewY() < this.mazeHeight && this.mouse.getNewX() >= 0 && this.mouse.getNewX() < this.mazeWidth) { char mazeCell = this.maze[this.mouse.getNewY()][this.mouse.getNewX()]; if (mazeCell == ' ') { StringBuilder temp = new StringBuilder(this.maze[this.mouse.Y]); temp[this.mouse.X] = ' '; this.maze[this.mouse.Y] = temp.ToString(); //update X and Y internally this.mouse.confirmMove(); } else if (mazeCell == 'E') { this.GameOver = true; } else { //reset newX and newY this.mouse.failedMove(); } } else { this.mouse.failedMove(); } this.refreshMouseDirection(); }