public void AddMotion(int playerId, int copyId, int AP, Vector3 TargetPosition, ActionMarker marker) { Vector3 from = GetLastPlayerPosition(playerId, copyId); _localgameStateData.PlayerTurns[_localgameStateData.CurrentTurn].Actions.Add(new MoveAction() { Direction = RoundVector3ToFraction((TargetPosition - from)).ToWrapper(), CopyId = copyId, PlayerId = playerId, ActionPointsPrice = AP, ActionPointsInitial = ActionPointsPerTurn - _currentActionPoints, }); _currentActionPoints -= AP; OnActionsChanged(); }
public void AddAttack(int playerId, int copyId, int AP, Vector3 TargetPosition, ActionMarker marker) { Vector3 from = GetLastPlayerPosition(playerId, copyId); _localgameStateData.PlayerTurns[_localgameStateData.CurrentTurn].Actions.Add(new AttackAction() { CopyId = copyId, PlayerId = playerId, Direction = (TargetPosition - from).normalized.ToWrapper(), ActionPointsPrice = ActionPointsPerAttack, ActionPointsInitial = ActionPointsPerTurn - _currentActionPoints, }); _currentActionPoints -= AP; OnActionsChanged(); }
public IEnumerator ParentDiscardCardsToDeckObject(GameObject playerAreas, ActionMarker.ActionSprite action) { GameObject deckObject = playerAreas.transform.Find("Deck").gameObject; GameObject discardObject = playerAreas.transform.Find("Discard").gameObject; ActionMarker actionMarker = playerAreas.GetComponentInChildren <ActionMarker> (); actionMarker.SetMarker(action); yield return(new WaitForSeconds(1)); bool showFace = false; float xOffset = 0; float yOffset = 0.5f; yield return(MoveCardsAnimation(discardObject, deckObject, showFace, xOffset, yOffset)); yield return(new WaitUntil(() => discardObject.transform.childCount == 0)); actionMarker.RemoveMarker(); }
public void OnClickOnAction(ActionMarker button) { if (_state == GameState.Move) { OnCalculateMoveAction(button.Position); } if (_state == GameState.Attack) { OnCalculateAttackAction(button.Position); } if (_state == GameState.Flashback) { OnCalculateFlashbackAction(button.Position); } if (_state == GameState.Push) { OnCalculatePushAction(button.Position); } UpdatePossibleActions(); }
// This function is an asynchronous coRoutine because all the animations need to finish before the code resumes public IEnumerator MoveBallAction(GameManager.Player movingPlayer, ActionMarker.ActionSprite action) { float ballAnimationTime = settingController.GetAnimationSpeed(); float moveBy = 2.1f; // Move only if the controlling team is the one moving if (movingPlayer == controllingTeam) { if (movingPlayer == GameManager.Player.A) { ActionMarker actionMarker = GameObject.Find("Player A Areas").GetComponentInChildren <ActionMarker> (); actionMarker.SetMarker(action); if (ballPosition == BallPosition.PlayerAField) { iTween.MoveBy(gameObject, iTween.Hash("y", moveBy, "time", ballAnimationTime, "easeType", "easeInOutQuad")); ballPosition = BallPosition.Middle; yield return(new WaitForSeconds(ballAnimationTime)); } else if (ballPosition == BallPosition.Middle) { iTween.MoveBy(gameObject, iTween.Hash("y", moveBy, "time", ballAnimationTime, "easeType", "easeInOutQuad")); ballPosition = BallPosition.PlayerBField; yield return(new WaitForSeconds(ballAnimationTime)); } else if (ballPosition == BallPosition.PlayerBField) { iTween.MoveBy(gameObject, iTween.Hash("y", moveBy / 2, "time", ballAnimationTime, "easeType", "easeInOutQuad")); ballPosition = BallPosition.PlayerBGoal; yield return(new WaitForSeconds(ballAnimationTime)); } actionMarker.RemoveMarker(); } else // movingPlayer == PlayerB { ActionMarker actionMarker = GameObject.Find("Player B Areas").GetComponentInChildren <ActionMarker> (); actionMarker.SetMarker(action); if (ballPosition == BallPosition.PlayerBField) { iTween.MoveBy(gameObject, iTween.Hash("y", -moveBy, "time", ballAnimationTime, "easeType", "easeInOutQuad")); ballPosition = BallPosition.Middle; yield return(new WaitForSeconds(ballAnimationTime)); } else if (ballPosition == BallPosition.Middle) { iTween.MoveBy(gameObject, iTween.Hash("y", -moveBy, "time", ballAnimationTime, "easeType", "easeInOutQuad")); ballPosition = BallPosition.PlayerAField; yield return(new WaitForSeconds(ballAnimationTime)); } else if (ballPosition == BallPosition.PlayerAField) { iTween.MoveBy(gameObject, iTween.Hash("y", -(moveBy / 2), "time", ballAnimationTime, "easeType", "easeInOutQuad")); ballPosition = BallPosition.PlayerAGoal; yield return(new WaitForSeconds(ballAnimationTime)); } actionMarker.RemoveMarker(); } } else { yield return(SetControllingTeamAnimation(movingPlayer, action)); } }