public void MoveHero(LocationInMaze positionToMove) { var curentPlayer = GameState.CurrentPlayer; var heroToMove = GameState.Heroes.First(h => h.OwnerId == curentPlayer.Id); if (curentPlayer.ActionPoints <= 0) { return; } //We dont validate here var cellToGo = GameState.Path.FirstOrDefault(node => node.Cell.Equals(positionToMove)); if (cellToGo == null) { return; } var objectsOnCell = GameState.Maze.GetObjects(positionToMove); var chests = new List <Chest>(); foreach (var mo in objectsOnCell) { if (mo as Chest != null) { chests.Add((Chest)mo); } } var chest = chests.FirstOrDefault(); if (chest != null && chest.OwnerId != GameState.CurrentPlayer.Id) { var openChestResult = chest.OpenChest(); GameState.Chests.Remove(chest); GameState.Maze.RemoveObject(chest); if (openChestResult.Rubys > 0) { GameState.CurrentPlayer.RubyAmmount += openChestResult.Rubys; GameState.Message = "You got some rubys. OMG WTF"; } if (openChestResult.Weapon != null) { GameState.CurrentPlayer.Slot = new ItemSlot(openChestResult.Weapon); GameState.Message = "Now you have weapon. KILL THEM ALL! (weapon can be used once lol)"; } if (openChestResult.Anh != null) { GameState.CurrentPlayer.Slot = new ItemSlot(openChestResult.Anh); GameState.Message = "Now you are immortal!!! Well no but something like that"; } } heroToMove.Move(positionToMove); OnAction(cellToGo.StepsToGet); //var objectsStandsOn = GameState.Maze.GetObjects(heroToMove.CurrentPositionInMaze); //if (objectsStandsOn != null && objectsStandsOn.Any(o => o.GetType().IsAssignableFrom(typeof(Chest)))) // return; //return HeroMoveResult.Default; }
public void Move(LocationInMaze positionToMove) { if (OnMove != null) { OnMove(positionToMove); } CurrentPositionInMaze = positionToMove; }
public void ApplyAction(GameState state, MazeActionType actionType) { if (actionType != MazeActionType.Teleport) { return; } var random = new Random(); var locationToTeleport = new LocationInMaze { SegmentId = random.Next(0, state.Maze.Segments.Count), CoordsInSegment = new Point(random.Next(0, 5), random.Next(0, 5)), }; var heroVictim = state.Heroes[random.Next(0, state.Heroes.Count)]; heroVictim.Move(locationToTeleport); }
public static Vector2 GetUiPosition(LocationInMaze locationInMaze) { //locationInMaze = new LocationInMaze //{ // SegmentId = 0, // CoordsInSegment = new Point(2, 2) //}; var xFinal = 0; var yFinal = 0; const int halfOfLavaWidth = 15; const int segmentWidth = 14 * 30; var xSegmentOffset = 0; if (locationInMaze.SegmentId % 2 == 0) { xSegmentOffset = -1 * (segmentWidth + halfOfLavaWidth); //14 tiles by 30 pix } else { xSegmentOffset = halfOfLavaWidth; } var ySegmentOffset = 0; if (locationInMaze.SegmentId / 2 == 0) { ySegmentOffset = segmentWidth + halfOfLavaWidth; } else { ySegmentOffset = -halfOfLavaWidth; } var xCellsOffset = 30 + (locationInMaze.CoordsInSegment.X * 60 + locationInMaze.CoordsInSegment.X * 30); var yCellsOffset = -30 - (locationInMaze.CoordsInSegment.Y * 60 + locationInMaze.CoordsInSegment.Y * 30); xFinal += xSegmentOffset; xFinal += xCellsOffset; yFinal += ySegmentOffset; yFinal += yCellsOffset; //var xCellOffset = locationInMaze.CoordsInSegment.X*30 + 30; return(new Vector2(xFinal, yFinal)); }
public void Move(LocationInMaze newLocation) { transform.localPosition = CoordsUtility.GetUiPosition(newLocation); }