private void BounceTiles(FenceLocation fenceLocation, TileState tileState, PlayerInput playerInput) { var animationTime = 0.3f; var offsetMagnitude = 0.5f; if (playerInput.Left || playerInput.Right) { Rotating = true; Vector3 offset = ((playerInput.Left) ? new Vector3(-1, 0, 0) : new Vector3(0, 0, -1)) * offsetMagnitude; var playerTileTransform = tileState.Player.transform; var tileTryingToReachTransform = (playerInput.Left) ? tileState.Left.transform : tileState.Right.transform; var otherTileTransform = (playerInput.Left) ? tileState.Right.transform : tileState.Left.transform; var oldRotation = (playerInput.Left) ? tileState.RightRotation : tileState.LeftRotation; float angle = (playerInput.Left) ? 30 : -30; var newRotation = oldRotation + angle; StartCoroutine( TransitionTileBackAndForth( playerTileTransform, playerTileTransform.position, playerTileTransform.position + offset, animationTime)); StartCoroutine( TransitionTileBackAndForth( tileTryingToReachTransform, tileTryingToReachTransform.position, tileTryingToReachTransform.position + offset, animationTime)); StartCoroutine(WobbleTile(otherTileTransform, oldRotation, newRotation, animationTime)); } }
public void OnFence(FenceLocation fenceLocation) { if (numFences > 0) { Button fence; KeyValuePair <int, int>[] affectedPens; if (fenceLocation.fenceType == FenceLocation.Type.Horizontal) { fence = horiz[fenceLocation.row, fenceLocation.col]; affectedPens = GameController.AddHorizFence(fenceLocation.row, fenceLocation.col); } else { fence = verts[fenceLocation.row, fenceLocation.col]; affectedPens = GameController.AddVertFence(fenceLocation.row, fenceLocation.col); } fence.interactable = false; bool isPigPenned = false; foreach (KeyValuePair <int, int> k in affectedPens) { if (k.Key != -1) { isPigPenned = true; pens[k.Key, k.Value].SetPigColor(activePlayer, true); SetPigCount(activePlayer); if (GameController.GetPlayerData(activePlayer).numPigs <= 0) { DOTween.Sequence().AppendInterval(PENNED_PIG_DELAY).AppendCallback(ToOver); numFences = 0; return; } } } GameState nextState; if (currentState == GameState.FENCE2) { nextState = GameState.FENCE; } else { nextState = GameState.SPIN; } if (isPigPenned && nextState == GameState.SPIN) { DOTween.Sequence().AppendInterval(PENNED_PIG_DELAY).AppendCallback(ToSpin); } else { GameController.StateChange(nextState); } } }
private static void AddFenceToLocations(FenceLocation.Type fenceType, int row, int col, int count) { switch (count) { case 3: // find the unset fence and add it to single singleFenceLocations.Add(new FenceLocation(fenceType, row, col)); return; case 2: FenceLocation newFence = new FenceLocation(fenceType, row, col); doubleFenceLocations.Add(newFence); unsafeFenceLocations.Add(newFence); return; case 1: safeDoubleFenceLocations.Add(new FenceLocation(fenceType, row, col)); return; case 0: safeSingleFenceLocations.Add(new FenceLocation(fenceType, row, col)); return; } }
public void OnFence() { FenceLocation fence = ExtractFenceLocation(EventSystem.current.currentSelectedGameObject.name); OnFence(fence); }
private static void PlaceFence(FenceLocation fence) { firedFenceLocation = fence; DOTween.Sequence().AppendInterval(BORG_DELAY).AppendCallback(BorgPlayer.FireButton); }