private void OnInitializeAllyComponents(RTSAllyComponentSpecificFields _specificComps, RTSAllyComponentsAllCharacterFields _allAllyComps)
        {
            var _RPGallAllyComps = (AllyComponentsAllCharacterFieldsRPG)_allAllyComps;

            if (_specificComps.bBuildCharacterCompletely)
            {
                var _rpgCharAttr = ((AllyComponentSpecificFieldsRPG)_specificComps).RPGCharacterAttributesObject;
                this.damageSounds               = _rpgCharAttr.damageSounds;
                this.deathSounds                = _rpgCharAttr.deathSounds;
                this.deathVanishSeconds         = _rpgCharAttr.deathVanishSeconds;
                this.animatorController         = _rpgCharAttr.animatorController;
                this.animatorOverrideController = _rpgCharAttr.animatorOverrideController;
                this.characterAvatar            = _rpgCharAttr.characterAvatar;
                this.animatorForwardCap         = _rpgCharAttr.animatorForwardCap;
                this.audioSourceSpatialBlend    = _rpgCharAttr.audioSourceSpatialBlend;
                this.colliderCenter             = _rpgCharAttr.colliderCenter;
                this.colliderRadius             = _rpgCharAttr.colliderRadius;
                this.colliderHeight             = _rpgCharAttr.colliderHeight;
                this.moveSpeedMultiplier        = _rpgCharAttr.moveSpeedMultiplier;

                //RPG Character Moving
                this.MyStationaryTurnSpeed      = _rpgCharAttr.stationaryTurnSpeed;
                this.MyMovingTurnSpeed          = _rpgCharAttr.movingTurnSpeed;
                this.MyMoveThreshold            = _rpgCharAttr.moveThreshold;
                this.MyAnimatorForwardCap       = _rpgCharAttr.animatorForwardCap;
                this.MyAnimationSpeedMultiplier = _rpgCharAttr.animationSpeedMultiplier;
            }

            AddRequiredComponents();
            bInitializedAlly = true;
        }
Esempio n. 2
0
        protected override void OnAllyInitComps(RTSAllyComponentSpecificFields _specific, RTSAllyComponentsAllCharacterFields _allFields)
        {
            //Make Sure Base is Called Before Override
            base.OnAllyInitComps(_specific, _allFields);
            var _RPGallAllyComps = (AllyComponentsAllCharacterFieldsRPG)_allFields;
            var _rpgCharAttr     = ((AllyComponentSpecificFieldsRPG)_specific).RPGCharacterAttributesObject;

            //Set Important NavMeshAgent Attributes
            myNavAgent.speed            = _rpgCharAttr.navMeshAgentSteeringSpeed;
            myNavAgent.stoppingDistance = _rpgCharAttr.navMeshAgentStoppingDistance;
            myNavAgent.autoBraking      = false;
            myNavAgent.updateRotation   = false;
            myNavAgent.updatePosition   = true;
            this.bUseAStarPath          = _RPGallAllyComps.bUseAStarPath;
            //Behavior Tree Init
            MyBehaviourChoice   = _RPGallAllyComps.MyBehaviourChoice;
            bUsingBehaviorTrees = _RPGallAllyComps.bUseBehaviourTrees;
            if (MyBehaviourChoice == BehaviourFrameworkChoice.BehaviorDesigner)
            {
                InitializeBehaviorDesignerTree(_specific, _RPGallAllyComps, _rpgCharAttr);
            }
            else if (MyBehaviourChoice == BehaviourFrameworkChoice.UNode)
            {
                InitializeUNodeTree(_specific, _RPGallAllyComps, _rpgCharAttr);
            }
        }
Esempio n. 3
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());
                }
            }
        }
        protected override void OnAllyInitComponents(RTSAllyComponentSpecificFields _specific, RTSAllyComponentsAllCharacterFields _allFields)
        {
            base.OnAllyInitComponents(_specific, _allFields);
            var _RPGallAllyComps = (AllyComponentsAllCharacterFieldsRPG)_allFields;

            this.bUseAStarPath = _RPGallAllyComps.bUseAStarPath;
        }
        void InitializeAllyWeaponItems(RTSAllyComponentSpecificFields _specific, RTSAllyComponentsAllCharacterFields _allFields)
        {
            var _tpcAllyCompsToInit = (RTSAllyComponentsAllCharacterFieldsWrapper)_allFields;

            AssualtRifleType = _tpcAllyCompsToInit.AssualtRifleType;
            PistolType       = _tpcAllyCompsToInit.PistolType;
            ShotgunType      = _tpcAllyCompsToInit.ShotgunType;
            SniperRifleType  = _tpcAllyCompsToInit.SniperRifleType;
            FistType         = _tpcAllyCompsToInit.FistType;
            KnifeType        = _tpcAllyCompsToInit.KnifeType;
            AxeType          = _tpcAllyCompsToInit.AxeType;
            CrossbowType     = _tpcAllyCompsToInit.CrossbowType;
            KatanaType       = _tpcAllyCompsToInit.KatanaType;
        }
        protected override void InitializeAlly(RTSAllyComponentSpecificFields _specific, RTSAllyComponentsAllCharacterFields _allFields)
        {
            AllyFaction      = _specific.AllyFaction;
            GeneralCommander = _specific.GeneralCommander;
            if (_allFields.bBuildLOSChildObject)
            {
                LOSTransform = _specific.LOSChildObjectTransform;
            }

            if (gamemode == null)
            {
                Debug.LogError("No gamemode on ai player!");
            }

            //Adding To PartyMan Is Delayed Because AllyStatController
            //Is Not Added Before AllyMember
            StartCoroutine(InitializeAllyCoroutine());
            //Create Overrideable Late Start to Accommodate
            //Assets Having Long StartUp
            Invoke("OnDelayStart", 0.5f);
        }
Esempio n. 7
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");
            }
        }
        private void OnInitializeAllyComponents(RTSAllyComponentSpecificFields _specificComps, RTSAllyComponentsAllCharacterFields _allAllyComps)
        {
            var _RPGallAllyComps = (AllyComponentsAllCharacterFieldsRPG)_allAllyComps;

            if (_specificComps.bBuildCharacterCompletely)
            {
                var _rpgCharAttr = _RPGallAllyComps.bUseAStarPath == false ?
                                   ((AllyComponentSpecificFieldsRPG)_specificComps).RPGCharacterAttributesObject :
                                   ((AllyComponentSpecificFieldsRPG)_specificComps).ASTAR_RPGCharacterAttributesObject;
                this.abilities = _rpgCharAttr.abilities;
                if (_rpgCharAttr.energyBar != null)
                {
                    this.energyBar = _rpgCharAttr.energyBar;
                }
                if (_rpgCharAttr.outOfEnergy != null)
                {
                    this.outOfEnergy = _rpgCharAttr.outOfEnergy;
                }
            }
            audioSource = GetComponent <AudioSource>();
            InitializeAbilityDictionary();
            InvokeRepeating("SE_AddEnergyPoints", 1f, addStaminaRepeatRate);
        }
        //void Update()
        //{
        //    //SE_CheckForAttack();
        //}
        #endregion

        #region Handlers
        private void OnInitializeAllyComponents(RTSAllyComponentSpecificFields _specificComps, RTSAllyComponentsAllCharacterFields _allAllyComps)
        {
            var _RPGallAllyComps = (AllyComponentsAllCharacterFieldsRPG)_allAllyComps;

            if (_specificComps.bBuildCharacterCompletely)
            {
                var _rpgCharAttr = _RPGallAllyComps.bUseAStarPath == false ?
                                   ((AllyComponentSpecificFieldsRPG)_specificComps).RPGCharacterAttributesObject :
                                   ((AllyComponentSpecificFieldsRPG)_specificComps).ASTAR_RPGCharacterAttributesObject;

                this.baseDamage = _rpgCharAttr.baseDamage;
                if (_rpgCharAttr.currentWeaponConfig != null)
                {
                    this.currentWeaponConfig = _rpgCharAttr.currentWeaponConfig;
                }
            }
            animator  = GetComponent <Animator>();
            character = GetComponent <RPGCharacter>();

            PutWeaponInHand(currentWeaponConfig);
            SetAttackAnimation();

            //InvokeRepeating("SE_CheckForAttack", 1f, checkForAttackRate);
        }