public LevelTile(Point twoDimPoint, int textureIndex, TileType type, IndexPair tileIndecies) { if (floorTexture == null) { floorTexture = Model.TileTextures[0]; } if (type == TileType.Corner) { dimensions = new Size(64, 128); twoDimPoint.Y -= 64; twoDimPoint.X -= 64; } else { dimensions = new Size(64, 64); } if (type == TileType.Floor) { this.texture = null; // Floor tiles are the first to be drawn, they cause no problems this.ZOrder = 0; } else { this.texture = Model.TileTextures[textureIndex]; Point temp = tileIndecies.IndexesToCoordinates(); this.ZOrder = temp.X + temp.Y; } this.type = type; this.twoDimPoint = twoDimPoint; this.tileIndecies = tileIndecies; }
public void Initialize() { playerCoordinates = MapLoader.WalkableTiles[0].TileIndecies; playerAnimation = (PlayerAnimation)AnimationFactory.CreateEmpyAnimation(AnimationType.PlayerAnimation); // Initialize the player location to the top of the screen Point tempConverted = playerCoordinates.IndexesToCoordinates(); playerAnimation.AnimationPosition = tempConverted; ZOrder = tempConverted.X + tempConverted.Y; playerAnimation.Collider.Collided += Collider_Collided; Direction = Directions.Right; }
/// <summary> /// Moves on the 2D Cartesian coordinates, conversion is on checking and drawing only /// </summary> /// <param name="direction"></param> /// <param name="deltaHorizontal"></param> /// <param name="deltaVertical"></param> private void Move(Directions direction) { IndexPair temp = playerCoordinates; switch (direction) { case Directions.Up: temp.I--; break; case Directions.Down: temp.I++; break; case Directions.Left: temp.J--; break; case Directions.Right: temp.J++; break; default: break; } // Wall detection if (MapLoader.IsWalkable(temp) || MapLoader.Level[temp.I, temp.J] == 6 || MapLoader.Level[temp.I, temp.J] == 7) { playerCoordinates = temp; Point tempConverted = temp.IndexesToCoordinates(); playerAnimation.AnimationPosition = tempConverted; playerInstance.ZOrder = tempConverted.X + tempConverted.Y; Direction = direction; if (MapLoader.Level[temp.I, temp.J] == 6) { Controller.GameOver(2); } } }
public Monster(IndexPair startPoint, IndexPair endPoint) { increasing = true; counter = 0; AnimationFactory factory = new AnimationFactory(); PathFinder myPath = new PathFinder(new RouteInformation(startPoint, endPoint)); monsterPath = myPath.FindPath(); makeStepTimer.Elapsed += Timer_Elapsed; makeStepTimer.Enabled = true; makeStepTimer.Interval = 250; Alive = true; monsterAnimation = (MonsterAnimation)factory.CreateAnimation(AnimationType.MonsterAnimation, monsterPath[0]); monsterAnimation.AnimationPosition = startPoint.IndexesToCoordinates(); // TODO set Monster start position at game start. TODO set Monster Direction at game start. monsterAnimation.Collider.Collided += Monster_Collided; }