void Start() { currentHealth = MaxHealth; currentMovePoint = MaxMovePoints; currentIndice = StartIndice; prevIndice = currentIndice; selfTrans = transform; MoveToTile(GlobalMap.GetTile(currentIndice)); if (PlayerTileData.filter == PlayerFilter.PLAYER_ONE) { GlobalMap.SetPointTile(StarData); } }
public override void TakeAction(PlayerController ctrl) { Tile tile = GlobalMap.GetTile(ctrl.currentIndice + Direction); ctrl.prevIndice = ctrl.currentIndice; ctrl.currentIndice = tile.Indice; ctrl.selfTrans.position = tile.Position; tile.RefreshData(ctrl.PlayerTileData); tile.UpdateTile(); GlobalMap.GetTile(ctrl.prevIndice).ResetTile(); TurnTimer.SwitchPlayers(ctrl.PlayerTileData.filter); Debug.Log("Move Tile move " + ctrl.name + " to indice: " + (tile.Indice)); }
void Update() { if (Input.GetKeyDown(KeyCode.Space) && GlobalMap.Map != null) { tile = GlobalMap.GetTile(SwitchIndice); if (tile != null) { tile.RefreshData(ReplaceData); tile.UpdateTile(); } Debug.Log("Tile type: " + tile.Data.type); } if (Input.GetKeyUp(KeyCode.Space) && GlobalMap.Map != null && tile != null) { tile.ResetTile(); tile = null; } }
private void Turn() { if (Input.GetMouseButtonUp(0) && Vector2.Distance(currentIndice, IndiceSelector.Indice) < 1.5f) { // Debug.Log(gameObject.name); Tile tile = GlobalMap.GetTile(IndiceSelector.Indice); switch (tile.Data.type) { case TileType.NEUTRAL: MoveToTile(tile); ResetPrevTile(prevIndice); // Debug.Log("Moved!"); break; case TileType.BLOCKING: // Debug.Log("Blocked!"); break; case TileType.HEALTH: MoveToTile(tile); ResetPrevTile(prevIndice); // Debug.Log("Picked up health!"); break; case TileType.POINT: if (Score < maxScore) { Score++; } else { SceneManager.LoadSceneAsync(0, LoadSceneMode.Single); } MoveToTile(tile); ResetPrevTile(prevIndice); // Debug.Log("Picked up POINT!"); break; case TileType.MOVE: // Debug.Log("Moved Extra Spaces!"); break; case TileType.PLAYER: if (PlayerTileData.filter != tile.Data.filter) { if (DirectionalityCheck.Check(currentIndice, IndiceSelector.Indice) == Directionality.Orthogonal) { /* Debug.Log("Blocked by another player!");*/ } else if (GlobalMap.IsEdge(IndiceSelector.Indice) == false) { tile = GlobalMap.GetTile(IndiceSelector.Indice + (IndiceSelector.Indice - currentIndice)); if (tile.Data.type != TileType.BLOCKING) { if (tile.Data.type == TileType.POINT) { if (Score < maxScore) { Score++; } else { SceneManager.LoadSceneAsync(0, LoadSceneMode.Single); } } MoveToTile(tile); ResetPrevTile(prevIndice); // Debug.Log("Jumped over another player!"); } else { // Debug.Log("Blocked!"); } } else { /* Debug.Log("Cannot jump a player if they are on the edge!"); */ } } else { /* Debug.Log("Tried to move to your own tile!");*/ } break; default: MoveToTile(tile); ResetPrevTile(prevIndice); break; } } }
private void ResetPrevTile(Vector2Int _indice) { GlobalMap.GetTile(_indice).ResetTile(); TurnTimer.SwitchPlayers(PlayerTileData.filter); }