Пример #1
0
        void InitializeBehaviorDesignerTree(RTSAllyComponentSpecificFields _specific, AllyComponentsAllCharacterFieldsRPG _RPGallAllyComps, RPGAllySpecificCharacterAttributesObject _rpgCharAttr)
        {
            if (_RPGallAllyComps.bUseBehaviourTrees && _RPGallAllyComps.allAlliesDefaultBehaviourTree != null)
            {
                BehaviorTree _behaviourtree;
                if (GetComponent <BehaviorTree>() == null)
                {
                    //If BehaviorTree Can't Be Found, Add One And Initialize It Manually
                    _behaviourtree = gameObject.AddComponent <BehaviorTree>();
                    _behaviourtree.StartWhenEnabled = false;
                    _behaviourtree.ExternalBehavior = _RPGallAllyComps.allAlliesDefaultBehaviourTree;
                    _behaviourtree.BehaviorName     = $"{_specific.CharacterType.ToString()} Behavior";
                }
                else
                {
                    //BehaviorTree Already Exists, Not Need To Manually Set it Up
                    _behaviourtree = AllyBehaviorTree;
                }
                //Active Time Bar
                _behaviourtree.SetVariableValue(BBName_bUpdateActiveTimeBar, false);
                _behaviourtree.SetVariableValue(BBName_ActiveTimeBarRefillRate, 5);
                //Abilities and Energy Bar
                _behaviourtree.SetVariableValue(BBName_EnergyRegenPointsPerSec, 10);
                _behaviourtree.SetVariableValue(BBName_bTryUseAbility, false);
                _behaviourtree.SetVariableValue(BBName_AbilityToUse, null);
                _behaviourtree.SetVariableValue(BBName_bIsPerformingAbility, false);

                if (_behaviourtree.StartWhenEnabled == false)
                {
                    //Only Manually Start Tree if It Doesn't Start On Enable
                    StartCoroutine(StartDefaultBehaviourTreeAfterDelay());
                }
            }
        }
Пример #2
0
        //protected override void UpdateBattleBehavior()
        //{
        //    RPGUpdateBattleBehaviorOLD();
        //}

        //private void RPGUpdateBattleBehaviorOLD()
        //{
        //    // Pause Ally Tactics If Ally Is Paused
        //    // Due to the Game Pausing Or Control Pause Mode
        //    // Is Active
        //    if (myEventHandler.bAllyIsPaused) return;

        //    if (currentTargettedEnemy == null ||
        //        currentTargettedEnemy.IsAlive == false ||
        //        myEventHandler.bIsFreeMoving)
        //    {
        //        myEventHandler.CallEventStopTargettingEnemy();
        //        myEventHandler.CallEventFinishedMoving();
        //        return;
        //    }

        //    if (IsTargetInRange(currentTargettedEnemy.gameObject))
        //    {
        //        if (bIsMeleeing == false)
        //        {
        //            //myEventHandler.CallAttackRPGTarget(currentTargettedEnemy.gameObject);
        //            myEventHandler.CallEventFinishedMoving();
        //            StartMeleeAttackBehavior();
        //        }
        //    }
        //    else
        //    {
        //        if (bIsMeleeing == true)
        //        {
        //            //myEventHandler.CallStopAttackingRPGTarget();
        //            StopMeleeAttackBehavior();
        //        }

        //        myEventHandler.CallEventAIMove(currentTargettedEnemy.transform.position);
        //    }
        //}

        ////Probably Won't Use, From RTSCoreFramework AIController
        //private void RPGUpdateBattleBehaviorNEW()
        //{
        //    // Pause Ally Tactics If Ally Is Paused
        //    // Due to the Game Pausing Or Control Pause Mode
        //    // Is Active
        //    if (myEventHandler.bAllyIsPaused) return;

        //    if (bStopUpdatingBattleBehavior)
        //    {
        //        myEventHandler.CallEventStopTargettingEnemy();
        //        myEventHandler.CallEventFinishedMoving();
        //        return;
        //    }

        //    //Melee Behavior
        //    if (IsTargetInMeleeRange(currentTargettedEnemy.gameObject))
        //    {
        //        if (bIsMeleeing == false)
        //        {
        //            StartMeleeAttackBehavior();
        //            myEventHandler.CallEventFinishedMoving();
        //        }
        //    }
        //    else
        //    {
        //        if (bIsMeleeing == true)
        //        {
        //            StopMeleeAttackBehavior();
        //        }

        //        myEventHandler.CallEventAIMove(currentTargettedEnemy.transform.position);
        //    }
        //}
        #endregion

        #region Initialization
        //Behavior Tree Init
        void InitializeUNodeTree(RTSAllyComponentSpecificFields _specific, AllyComponentsAllCharacterFieldsRPG _RPGallAllyComps, RPGAllySpecificCharacterAttributesObject _rpgCharAttr)
        {
            if (_RPGallAllyComps.uNodeGraphSpawnerPrefab != null)
            {
                var _spawner = GameObject.Instantiate
                                   (_RPGallAllyComps.uNodeGraphSpawnerPrefab, transform)
                               .GetComponent <MaxyGames.uNode.uNodeSpawner>();
                _spawner.transform.name = $"{_specific.CharacterType.ToString()} Behavior";
                //Assign Vars
                //Active Time Bar
                _spawner.SetVariable(BBName_bUpdateActiveTimeBar, false);
                _spawner.SetVariable(BBName_ActiveTimeBarRefillRate, 5);
                //Abilities and Energy Bar
                _spawner.SetVariable(BBName_EnergyRegenPointsPerSec, 10);
                _spawner.SetVariable(BBName_bTryUseAbility, false);
                _spawner.SetVariable(BBName_AbilityToUse, null);
                _spawner.SetVariable(BBName_bIsPerformingAbility, false);
            }
            else
            {
                Debug.LogWarning("No UNode Tree Has Been Set, Cannot Init Tree");
            }
        }