示例#1
0
 protected override void OnRegisterUiTarget(AllyMember _target, AllyEventHandler _handler, PartyManager _party)
 {
     base.OnRegisterUiTarget(_target, _handler, _party);
     _handler.OnAmmoChanged   += OnAmmoChanged;
     _handler.OnWeaponChanged += OnWeaponChanged;
     UpdateWeaponUiGameObjects(uiTargetHandler.MyEquippedType);
 }
 protected virtual void CallEventCommandAttackEnemy(AllyMember ally)
 {
     if (EventCommandAttackEnemy != null)
     {
         EventCommandAttackEnemy(ally);
     }
 }
 public void CallEventNoPartyMembers(PartyManager partyMan, AllyMember lastMember, bool onDeath)
 {
     if (EventNoPartyManagers != null)
     {
         EventNoPartyManagers(partyMan, lastMember, onDeath);
     }
 }
        protected virtual bool hasLOSWithinRange(AllyMember _enemy, out RaycastHit _hit)
        {
            RaycastHit _myHit;
            bool       _bHit = Physics.Linecast(losTransform.position,
                                                _enemy.ChestTransform.position, out _myHit);

            _hit = _myHit;
            bool _valid = _bHit && _myHit.transform != null &&
                          _myHit.transform.root.tag == gamemode.AllyTag;

            if (_valid)
            {
                AllyMember _hitAlly = _myHit.transform.root.GetComponent <AllyMember>();
                if (_hitAlly == allyMember)
                {
                    Debug.Log(allyMember.CharacterName +
                              " Has LOS With Himself.");
                }
                //TODO: RTSPrototype Fix hasLosWithinRange() hitting self instead of enemy
                return(_hitAlly != null &&
                       (_hitAlly == allyMember ||
                        _hitAlly.IsEnemyFor(allyMember)));
            }
            return(false);
        }
 /// <summary>
 /// Compares Current To Previous Tactics Item To Determine If New Tactics Item Was Obtained.
 /// If Current Tactics Equal Past Tactics, Condition Will Fail.
 /// CheckPreviousNullInstead Boolean Will Check Previous Tactics Instead.
 /// </summary>
 public bool HasNewTacticsItem(ref AllyTacticsItem CurrentExecutionItem,
                               ref AllyMember CurrentExecutionTarget,
                               ref AllyTacticsItem PreviousExecutionItem,
                               ref AllyMember PreviousExecutionTarget, bool CheckPreviousNullInstead)
 {
     if (CheckPreviousNullInstead == false)
     {
         if (CurrentExecutionItem == PreviousExecutionItem &&
             CurrentExecutionTarget == PreviousExecutionTarget)
         {
             return(false);
         }
         else
         {
             return(true);
         }
     }
     else
     {
         if (PreviousExecutionItem != null && PreviousExecutionTarget != null)
         {
             return(true);
         }
         return(false);
     }
 }
示例#6
0
        protected virtual void SubscribeToUiTargetHandlers(AllyMember _target)
        {
            if (_target == null)
            {
                return;
            }
            var _handler = _target.allyEventHandler;

            SetAllyIsUiTarget(_target, true);
            //Sub to Current UiTarget Handlers
            _handler.OnHealthChanged       += UiTargetHandle_OnHealthChanged;
            _handler.OnStaminaChanged      += UiTargetHandle_OnStaminaChanged;
            _handler.OnActiveTimeChanged   += UiTargetHandle_OnActiveTimeChanged;
            _handler.EventAllyDied         += UiTargetHandle_OnAllyDeath;
            _handler.EventSetAsCommander   += UiTargetHandle_SetAsCommander;
            _handler.EventSwitchingFromCom += UiTargetHandle_SwitchFromCommander;
            _handler.OnHoverOver           += UiTargetHandle_OnHoverOver;
            _handler.OnHoverLeave          += UiTargetHandle_OnHoverLeave;
            //Notify Character Actions
            //_handler.EventCommandAttackEnemy += UiTargetHandle_Attacking;
            //_handler.OnTryUseWeapon += UiTargetHandle_Attacking;
            //_handler.EventStopTargettingEnemy += UiTargetHandle_Nothing;
            //_handler.EventCommandMove += UiTargetHandle_CommandMove;
            //_handler.EventFinishedMoving += UiTargetHandle_Nothing;
        }
示例#7
0
        protected virtual void UnsubscribeFromUiTargetHandlers(AllyMember _target)
        {
            if (_target == null)
            {
                return;
            }
            var _handler = _target.allyEventHandler;

            SetAllyIsUiTarget(_target, false);
            //Unsub From Previous UiTarget Handlers
            _handler.OnHealthChanged       -= UiTargetHandle_OnHealthChanged;
            _handler.OnStaminaChanged      -= UiTargetHandle_OnStaminaChanged;
            _handler.OnActiveTimeChanged   -= UiTargetHandle_OnActiveTimeChanged;
            _handler.EventAllyDied         -= UiTargetHandle_OnAllyDeath;
            _handler.EventSetAsCommander   -= UiTargetHandle_SetAsCommander;
            _handler.EventSwitchingFromCom -= UiTargetHandle_SwitchFromCommander;
            _handler.OnHoverOver           -= UiTargetHandle_OnHoverOver;
            _handler.OnHoverLeave          -= UiTargetHandle_OnHoverLeave;
            //Notify Character Actions
            //_handler.EventCommandAttackEnemy -= UiTargetHandle_Attacking;
            //_handler.OnTryUseWeapon -= UiTargetHandle_Attacking;
            //_handler.EventStopTargettingEnemy -= UiTargetHandle_Nothing;
            //_handler.EventCommandMove -= UiTargetHandle_CommandMove;
            //_handler.EventFinishedMoving -= UiTargetHandle_Nothing;
        }
示例#8
0
 public void CallOnDeregisterUiTarget(AllyMember _target, AllyEventHandler _eventHandler, PartyManager _party)
 {
     if (OnDeregisterUiTarget != null)
     {
         OnDeregisterUiTarget(_target, _eventHandler, _party);
     }
 }
 public virtual void CallEventAICommandAttackEnemy(AllyMember ally)
 {
     bIsAIMoving         = bIsCommandMoving = false;
     bIsAiAttacking      = true;
     bIsCommandAttacking = false;
     CallEventCommandAttackEnemy(ally);
 }
示例#10
0
 /// <summary>
 /// Called Before The AllyInCommand has been set by RTSGameMaster
 /// </summary>
 /// <param name="_party"></param>
 /// <param name="_toSet"></param>
 /// <param name="_current"></param>
 public void CallOnAllySwitch(PartyManager _party, AllyMember _toSet, AllyMember _current)
 {
     if (OnAllySwitch != null)
     {
         OnAllySwitch(_party, _toSet, _current);
     }
 }
        public void SetAllyInCommand(AllyMember _setToCommand)
        {
            bool _validSet = _setToCommand != null &&
                             _setToCommand.GetComponent <AllyMember>() != null &&
                             PartyMembers.Contains(_setToCommand);

            if (_validSet)
            {
                gamemaster.CallOnAllySwitch(this, _setToCommand, AllyInCommand);
                if (AllyInCommand != null)
                {
                    AllyInCommand.GetComponent <AllyEventHandler>().CallEventSwitchingFromCom();
                }

                AllyInCommand = _setToCommand;
                AllyInCommand.GetComponent <AllyEventHandler>().CallEventSetAsCommander();
                //Set PartySwitching Event Afterwards for more accurate party data retreival
                foreach (var _ally in PartyMembers)
                {
                    //TODO: RTSPrototype Fix null exception from foreach loop, this should not happen
                    if (_ally != null)
                    {
                        _ally.allyEventHandler.CallEventPartySwitching();
                    }
                }
            }
        }
 //ExecuteTacticsItem
 protected void ResetPreviousTacticsItem(ref AllyTacticsItem PreviousExecutionItem,
                                         ref AllyMember PreviousExecutionTarget)
 {
     //Do not reset current, only past tactics item.
     PreviousExecutionItem   = null;
     PreviousExecutionTarget = null;
 }
        public void SetAllyInCommand(AllyMember _setToCommand)
        {
            bool _validSet = _setToCommand != null &&
                             _setToCommand.GetComponent <AllyMember>() != null &&
                             PartyMembers.Contains(_setToCommand);

            if (_validSet)
            {
                gamemaster.CallOnAllySwitch(this, _setToCommand, AllyInCommand);
                if (AllyInCommand != null)
                {
                    AllyInCommand.allyEventHandler.CallEventSwitchingFromCom();
                }

                AllyInCommand = _setToCommand;
                AllyInCommand.allyEventHandler.CallEventSetAsCommander();
                //Set PartySwitching Event Afterwards for more accurate party data retreival
                foreach (var _ally in PartyMembers)
                {
                    if (_ally != null && _ally.IsAlive)
                    {
                        _ally.allyEventHandler.CallEventPartySwitching();
                    }
                }
            }
        }
 protected virtual void OnCheckToDeregisterUiTarget(AllyMember _target, AllyEventHandler _handler, PartyManager _party)
 {
     if (_target == currentUiTarget && bHasRegisteredTarget)
     {
         OnDeregisterUiTarget(_target, _handler);
     }
 }
示例#15
0
 void SetThirdPersonCam(PartyManager _party, AllyMember _toSet, AllyMember _current)
 {
     if (!_party.bIsCurrentPlayerCommander)
     {
         return;
     }
     SetCameraCharacter(_toSet);
 }
示例#16
0
 public virtual void ProcessAllySwitch(PartyManager _party, AllyMember _toSet, AllyMember _current)
 {
     if (_toSet != null && _party.bIsCurrentPlayerCommander)
     {
         SetThirdPersonCam(_party, _toSet, _current);
         SetUiTargetAlly(_toSet);
     }
 }
        /// <summary>
        /// Damages The Ally Target. Doesn't Use Any Animations.
        /// </summary>
        public bool DamageTarget(ref Transform CurrentTargettedEnemy)
        {
            int        _damage = allyMember.GetDamageRate();
            AllyMember _ally   = CurrentTargettedEnemy.GetComponent <AllyMember>();

            _ally.AllyTakeDamage(_damage, allyMember);
            return(true);
        }
示例#18
0
 public void CallRegisterAllyToCharacterStatMonitor(PartyManager _party, AllyMember _ally)
 {
     //Only Call if PartyManager is the Current Player's General
     if (RegisterAllyToCharacterStatMonitor != null &&
         _party && _party.bIsCurrentPlayerCommander)
     {
         RegisterAllyToCharacterStatMonitor(_party, _ally);
     }
 }
 /// <summary>
 /// Resets Execution Items And Targets, Previous and Current.
 /// </summary>
 public bool ResetTacticsItems(ref AllyTacticsItem CurrentExecutionItem, ref AllyMember CurrentExecutionTarget,
                               ref AllyTacticsItem PreviousExecutionItem, ref AllyMember PreviousExecutionTarget)
 {
     CurrentExecutionItem    = null;
     CurrentExecutionTarget  = null;
     PreviousExecutionItem   = null;
     PreviousExecutionTarget = null;
     return(true);
 }
示例#20
0
 protected void SetUiTargetAlly(AllyMember _allyToSet)
 {
     if (_allyToSet != null)
     {
         SetupUITargetHandlers(UiTargetAlly, _allyToSet);
         //Set to Command
         UiTargetAlly = _allyToSet;
     }
 }
示例#21
0
 rtsHitType CheckAllyObject(GameObject gObjectRoot)
 {
     hitAlly = gObjectRoot.GetComponent <AllyMember>();
     if (hitAlly == null)
     {
         return(rtsHitType.Unknown);
     }
     return(gamemode.AllyIsGenCommanderMember(hitAlly) ?
            rtsHitType.Ally : rtsHitType.Enemy);
 }
示例#22
0
        protected virtual void UnsubscribeFromUiTargetHandlers(AllyMember _target)
        {
            if (_target == null)
            {
                return;
            }
            var _handler = _target.allyEventHandler;

            gamemaster.CallOnDeregisterUiTarget(_target, _handler, _target.partyManager);
        }
        protected void HandleRightClick(rtsHitType hitType, RaycastHit hit)
        {
            if (!bIsCurrentPlayerCommander || bNoPartyCommandsAllowed)
            {
                return;
            }
            switch (hitType)
            {
            case rtsHitType.Ally:
                break;

            case rtsHitType.Enemy:
                GameObject _root  = hit.collider.gameObject.transform.root.gameObject;
                AllyMember _enemy = _root.GetComponent <AllyMember>();
                AllyInCommand.allyEventHandler.CallEventPlayerCommandAttackEnemy(_enemy);
                //Adding Command Attack Event Call To ActionItem Queue
                //AllyInCommand.allyEventHandler.CallOnAddActionItemToQueue(new RTSActionItem(
                //    _ally => _ally.allyEventHandler.CallEventPlayerCommandAttackEnemy(_enemy),
                //    _ally => true, ActionFilters.AI, true, false, true, false, _ally => true,
                //    _ally => _ally.bIsAttacking == false, (_ally) =>
                //    {
                //        _ally.allyEventHandler.CallEventStopTargettingEnemy();
                //        _ally.allyEventHandler.CallEventFinishedMoving();
                //    }));
                break;

            case rtsHitType.Cover:
                break;

            case rtsHitType.Walkable:
                AllyInCommand.allyEventHandler.CallEventCommandMove(hitType, hit);
                //if (AllyInCommand.allyEventHandler.bIsFreeMoving == false)
                //{
                //    AllyInCommand.allyEventHandler.CallEventCommandMove(hitType, hit);
                //    //Adding Command Move Event Call To ActionItem Queue
                //    //AllyInCommand.allyEventHandler.CallOnAddActionItemToQueue(new RTSActionItem(
                //    //    _ally => _ally.allyEventHandler.CallEventCommandMove(hitType, hit),
                //    //    _ally => true, ActionFilters.Movement, true, false, false, false,
                //    //    _ally => true, _ally => _ally.bIsFreeMoving || _ally.bIsNavMoving == false,
                //    //    _ally => _ally.allyEventHandler.CallEventFinishedMoving()
                //    //    ));
                //}
                break;

            case rtsHitType.Unwalkable:
                break;

            case rtsHitType.Unknown:
                break;

            default:
                break;
            }
        }
 protected void HandleLeftClickPartyMember(AllyMember ally)
 {
     if (!bIsCurrentPlayerCommander || bNoPartyCommandsAllowed)
     {
         return;
     }
     if (PartyMembers.Contains(ally) && ally != AllyInCommand)
     {
         SetAllyInCommand(ally);
     }
 }
示例#25
0
 protected virtual void SetupUITargetHandlers(AllyMember _previousAlly, AllyMember _currentAlly)
 {
     if (_previousAlly != null)
     {
         UnsubscribeFromUiTargetHandlers(_previousAlly);
     }
     if (_currentAlly != null)
     {
         SubscribeToUiTargetHandlers(_currentAlly);
     }
 }