public void DoAction() { PlayerProperties targetPlayer; if (player.IsAiPlayer) { print("Player is an AI, selecting random weapon and target now"); // won't set the targetRow/Weapon in PlayerProperties, but will attack the correct random player with the random weapon //var decisionPhase = gameObject.GetComponent<DecisionPhase>(); //var actionPhase = gameObject.GetComponent<ActionPhase>(); // choose a random valid(!) target player var randomTargetRow = GetRandomTargetRow(); targetPlayer = GetTargetPlayer(randomTargetRow); // and a random weapon ChangeLeftHandWeapon(randomTargetRow, GetRandomWeapon()); } else { targetPlayer = GetTargetPlayer(); } // checks for restrictions before attacking if (CanPlayerAttack(targetPlayer)) { // TODO check if player is front or back row to choose whether player should move or throw weapon // -> front should move and swing weapon, back should throw weapon if (player.CurrentRowPosition == PhaseHandler.RowPosition.Back) { Coroutine throwWeaponCoroutine = StartCoroutine(ThrowWeapon(targetPlayer, onComplete: () => { DealDamage(targetPlayer); LoadNewEffect(new Vector3(2f, 2f, 2f), targetPlayer); PhaseHandler.SetNextActivePlayer(); })); } else { MoveToAttackTarget(targetPlayer); } } else { print($"target ({targetPlayer.playerName}) can currently not be attacked. Switching to next player now."); // somehow this has to be done via callback, otherwise the next phase won't be triggered // PhaseHandler.SetNextActivePlayer(); // StartCoroutine(SetNextActivePlayer(onComplete: () => { PhaseHandler.SetNextActivePlayer(); })); MinifigControllerGroupW.SpecialAnimation specialAnimation = player.currentHp <= 0 ? MinifigControllerGroupW.SpecialAnimation.LookingDown : MinifigControllerGroupW.SpecialAnimation.IdleImpatient; playerMinifigController.PlaySpecialAnimation(specialAnimation, onSpecialComplete: (x) => { PhaseHandler.SetNextActivePlayer(); }); } }
void RotateBack(PlayerProperties activePlayer, PlayerProperties targetPlayer) { // TODO player hp bar should stay on top of player instead of rotating with him // face to the correct direction again (change rotation) print("now rotating back"); Vector3 originalRotation = targetPlayer.transform.position; // when the animation is finished, it's the next players turn playerMinifigController.TurnTo(originalRotation, onComplete: () => { PhaseHandler.SetNextActivePlayer(); }); }