Exemple #1
0
        private void DoTurn()
        {
            // cleanup for this turn
            CleanupForTurn();

            // physics pre
            var momentumX = point.x + momentum.x;
            var momentumY = point.y + momentum.y;

            // action
            if (CanMoveTo(momentumX, momentumY))
            {
                point.x = Mathf.RoundToInt(momentumX);
                point.y = Mathf.RoundToInt(momentumY);
                MoveTo(Map.instance.Get(point));
            }
            else
            {
                // todo: if huge momentum then don't zero it, move in direction until hit wall
                // if no move then stop momentum
                momentum = Vector2.zero;
            }

            // scene check
            CheckCurrentTile();

            // physics post
            momentum.x = Mathf.MoveTowards(momentum.x, 0, decelerationPT);
            momentum.y = Mathf.MoveTowards(momentum.y, 0, decelerationPT);

            // highlighting next turn

            // highlighting next possible move
            // todo: this works mostly, but seems to highlight incorrectly for:
            // 1: when moving in the same direction again and again, you get p s . w, and p moves to s?
            // 2: doesn't seem to account for diagonals, maybe another issue

            HighlightNextMovementPoint();
            HighlightNextMovementInputs();

            // camera movement
            // todo: move to script that reacts to player event
            UpdateCamera();

            OnTurnTaken?.Invoke();
        }
    public override void TakeTurn(PartyDetails opponent)
    {
        /*
         * Opponent's attacks are all the same as the Player's attacks, just named differently for theming
         *
         * 0 - Debug        regular attack
         * 1 - Break        healing move
         * 2 - Pop Quiz     bonus damage
         * 3 - Teach        bonus healing
         */
        string abilUsed  = "";
        int    soundUsed = 0;

        int   det  = health - opponent.health;
        float rand = Random.Range(0.0f, 100.0f);

        if (det < -10)
        {
            if (rand <= 30)
            {
                actionOptions[1].UseAbility(this, opponent);
                abilUsed  = actionOptions[1].abilityName;
                soundUsed = actionOptions[1].actionSFX;
            }
            else
            {
                actionOptions[3].UseAbility(this, opponent);
                abilUsed  = actionOptions[3].abilityName;
                soundUsed = actionOptions[3].actionSFX;
            }
        }
        else if (det >= -9 && det <= -4)
        {
            if (rand <= 25)
            {
                actionOptions[1].UseAbility(this, opponent);
                abilUsed  = actionOptions[1].abilityName;
                soundUsed = actionOptions[1].actionSFX;
            }
            else
            {
                actionOptions[3].UseAbility(this, opponent);
                abilUsed  = actionOptions[3].abilityName;
                soundUsed = actionOptions[3].actionSFX;
            }
        }
        else if (det >= 3)
        {
            actionOptions[2].UseAbility(this, opponent);
            abilUsed  = actionOptions[2].abilityName;
            soundUsed = actionOptions[2].actionSFX;
        }
        else
        {
            if (rand <= 30)
            {
                actionOptions[0].UseAbility(this, opponent);
                abilUsed  = actionOptions[0].abilityName;
                soundUsed = actionOptions[0].actionSFX;
            }
            else if (rand <= 60)
            {
                actionOptions[3].UseAbility(this, opponent);
                abilUsed  = actionOptions[3].abilityName;
                soundUsed = actionOptions[3].actionSFX;
            }
            else if (rand <= 80)
            {
                actionOptions[1].UseAbility(this, opponent);
                abilUsed  = actionOptions[1].abilityName;
                soundUsed = actionOptions[1].actionSFX;
            }
            else
            {
                actionOptions[2].UseAbility(this, opponent);
                abilUsed  = actionOptions[2].abilityName;
                soundUsed = actionOptions[2].actionSFX;
            }
        }

        OnTurnTaken.Invoke(partyName, abilUsed, soundUsed);
    }