/// <summary> /// Returns the hero that can be found at the screen position given /// </summary> /// <param name="screenPos">Selection position on screen</param> /// <returns>Hero or Null</returns> public Hero heroAtScreenPos(Vector2 screenPos) { GridSpace gs = spaceAtScreenpos(screenPos); if (gs.IsOccupied && gs.CurrentActor is Hero) { return((Hero)gs.CurrentActor); } return(null); }
/// <summary> /// Returns the person in the grid space currently being moused over. /// </summary> /// <param name="screenPos">Selection position on screen</param> /// <returns>Person or Null</returns> public Person personAtScreenPos(Vector2 screenPos) { GridSpace gs = spaceAtScreenpos(screenPos); if (gs != null && gs.IsOccupied && gs.CurrentActor is Person) { return((Person)gs.CurrentActor); } return(null); }
public void onClick(Vector2 screenPosition) { GridSpace tempGS = spaceAtScreenpos(Controls.MousePosition); Person temp = (Person)tempGS.CurrentActor; switch (gridState) { case GridState.noSelection: if (temp != null) { selectedPerson = temp; foreach (GridSpace space in spaceArray) { space.AvailableFlag = false; } availableSpaces = getAvailableMoveSpaces(selectedPerson.BaseMoveSpeed, tempGS.GridPosition, true, false); foreach (Vector2 v in availableSpaces) { spaceArray[(int)v.X, (int)v.Y].AvailableFlag = true; } changeState(GridState.selectedMotionAvailable); } break; case GridState.castAnimating: break; case GridState.selectedCastAvailable: break; case GridState.selectedMotionAvailable: foreach (GridSpace space in spaceArray) { space.AvailableFlag = false; } currentPath = Dijkstra(selectedPerson.GridPosition, tempGS.GridPosition, true, false); int movesDone = 0; if (currentPath.Count > 0) { LinkedListNode<Vector2> current = currentPath.First; while (movesDone < selectedPerson.BaseMoveSpeed && current.Next != null) { movesDone += movementCosts[(int)current.Value.X, (int)current.Value.Y, (int)current.Next.Value.X, (int)current.Next.Value.Y]; current = current.Next; } while (current.Next != null) { currentPath.Remove(current.Next); } animationFinalGoal = spaceArray[(int)currentPath.Last.Value.X, (int)currentPath.Last.Value.Y]; animationCurrentGoal = currentPath.First.Value; animatingActorScreenPos = selectedPerson.ScreenPosition; currentPath.RemoveFirst(); if ((int)animationCurrentGoal.X % 2 == 1) { animationCurrentGoal.Y += 0.5f; } animationCurrentGoal.X *= 3 * ConstantHolder.HexagonGrid_HexSizeX / 4; animationCurrentGoal.Y *= ConstantHolder.HexagonGrid_HexSizeY; animationCurrentGoal -= originScreenPos; animationCurrentGoal += new Vector2(ConstantHolder.HexagonGrid_HexSizeX / 3, ConstantHolder.HexagonGrid_HexSizeY); animatingActor = selectedPerson; spaceArray[(int)selectedPerson.GridPosition.X, (int)selectedPerson.GridPosition.Y].removeActor(); selectedPerson = null; changeState(GridState.selectedMoving); } break; case GridState.selectedMoving: break; } }
public void onClick(Vector2 screenPosition) { GridSpace tempGS = spaceAtScreenpos(Controls.MousePosition); Person temp = (Person)tempGS.CurrentActor; switch (gridState) { case GridState.noSelection: if (temp != null) { selectedPerson = temp; foreach (GridSpace space in spaceArray) { space.AvailableFlag = false; } availableSpaces = getAvailableMoveSpaces(selectedPerson.BaseMoveSpeed, tempGS.GridPosition, true, false); foreach (Vector2 v in availableSpaces) { spaceArray[(int)v.X, (int)v.Y].AvailableFlag = true; } changeState(GridState.selectedMotionAvailable); } break; case GridState.castAnimating: break; case GridState.selectedCastAvailable: break; case GridState.selectedMotionAvailable: foreach (GridSpace space in spaceArray) { space.AvailableFlag = false; } currentPath = Dijkstra(selectedPerson.GridPosition, tempGS.GridPosition, true, false); int movesDone = 0; if (currentPath.Count > 0) { LinkedListNode <Vector2> current = currentPath.First; while (movesDone < selectedPerson.BaseMoveSpeed && current.Next != null) { movesDone += movementCosts[(int)current.Value.X, (int)current.Value.Y, (int)current.Next.Value.X, (int)current.Next.Value.Y]; current = current.Next; } while (current.Next != null) { currentPath.Remove(current.Next); } animationFinalGoal = spaceArray[(int)currentPath.Last.Value.X, (int)currentPath.Last.Value.Y]; animationCurrentGoal = currentPath.First.Value; animatingActorScreenPos = selectedPerson.ScreenPosition; currentPath.RemoveFirst(); if ((int)animationCurrentGoal.X % 2 == 1) { animationCurrentGoal.Y += 0.5f; } animationCurrentGoal.X *= 3 * ConstantHolder.HexagonGrid_HexSizeX / 4; animationCurrentGoal.Y *= ConstantHolder.HexagonGrid_HexSizeY; animationCurrentGoal -= originScreenPos; animationCurrentGoal += new Vector2(ConstantHolder.HexagonGrid_HexSizeX / 3, ConstantHolder.HexagonGrid_HexSizeY); animatingActor = selectedPerson; spaceArray[(int)selectedPerson.GridPosition.X, (int)selectedPerson.GridPosition.Y].removeActor(); selectedPerson = null; changeState(GridState.selectedMoving); } break; case GridState.selectedMoving: break; } }