Пример #1
0
        //todo : place these in a strategy pattern
        protected virtual SinglePlayerInputs GetInputs(GameplayState gameState)
        {
            //1. tries to maintain a distance of attack range +50%
            //2. if opponent whiffs an attack. hit him
            //3. if opponent is in throw range. throw

            var inputs    = new SinglePlayerInputs();
            var pastState = gameState.GetPastState(0);
            var distanceBetweenCharacters = Math.Abs(pastState.P1_Position - pastState.P2_Position);
            var attackRangeAndAHalf       = GameplayConstants.HITBOX_ACTIVE_LATE * 3 / 2;

            GameplayEnums.CharacterState opponentState;
            if (p1)
            {
                opponentState = pastState.P2_CState.State;
            }
            else
            {
                opponentState = pastState.P1_CState.State;
            }

            if (distanceBetweenCharacters > attackRangeAndAHalf)
            {
                //move forward
                inputs.JoystickDirection = 6;
            }
            else
            {
                if (opponentState == GameplayEnums.CharacterState.AttackRecovery)
                {
                    inputs.A = true;
                }
                inputs.JoystickDirection = 4;
            }
            if (distanceBetweenCharacters < GameplayConstants.THROW_ACTIVE_RANGE + GameplayConstants.CHARACTER_HURTBOX_WIDTH)
            {
                inputs.B = true;
            }
            return(inputs);
        }
Пример #2
0
        protected override SinglePlayerInputs GetInputs(GameplayState gameState)
        {
            timeSinceLastStanceChange += Time.deltaTime;
            if (timeSinceLastStanceChange > timeBetweenStanceChange)
            {
                aggroMode = !aggroMode;
                timeSinceLastStanceChange = 0f;
            }
            //1. tries to maintain a distance of attack range +50%
            //2. if opponent whiffs an attack. hit him
            //3. if opponent is in throw range. throw

            var inputs    = new SinglePlayerInputs();
            var pastState = gameState.GetPastState(framesDelay);
            var distanceBetweenCharacters = Math.Abs(pastState.P1_Position - pastState.P2_Position);
            var actualAttackRange         = GameplayConstants.HITBOX_ACTIVE_LATE + GameplayConstants.CHARACTER_HURTBOX_WIDTH;

            GameplayEnums.CharacterState opponentState;
            if (p1)
            {
                opponentState = pastState.P2_CState.State;
            }
            else
            {
                opponentState = pastState.P1_CState.State;
            }

            if (aggroMode)
            {
                //move forward
                if (!p1)
                {
                    inputs.JoystickDirection = 6;
                }
                else
                {
                    inputs.JoystickDirection = 4;
                }

                int timeBeforeAttackFullyExtends_DelayConsidered   = framesDelay + GameplayConstants.ATTACK_STARTUP + GameplayConstants.ATTACK_FULL_EXTEND;
                int distanceOpponentCanCoverBeforeAttackReachesHim = -(timeBeforeAttackFullyExtends_DelayConsidered * GameplayConstants.WALK_B_SPEED);

                if (distanceOpponentCanCoverBeforeAttackReachesHim + distanceBetweenCharacters < actualAttackRange)
                {
                    inputs.A = true;
                }
            }
            else
            {
                if (distanceBetweenCharacters > actualAttackRange)
                {
                    //move forward
                    if (!p1)
                    {
                        inputs.JoystickDirection = 6;
                    }
                    else
                    {
                        inputs.JoystickDirection = 4;
                    }
                }
                else
                {
                    if (opponentState == GameplayEnums.CharacterState.AttackRecovery)
                    {
                        inputs.A = true;
                    }
                    if (p1)
                    {
                        inputs.JoystickDirection = 6;
                    }
                    else
                    {
                        inputs.JoystickDirection = 4;
                    }
                }
            }
            if (distanceBetweenCharacters < GameplayConstants.THROW_ACTIVE_RANGE + GameplayConstants.CHARACTER_HURTBOX_WIDTH)
            {
                inputs.B = true;
            }
            return(inputs);
        }