Example #1
0
 public override void SummonTaskChange(FCCommand.CMD cmd)
 {
     if (cmd == FCCommand.CMD.STATE_ENTER)
     {
         AttackBase ab = _owner.ACGetAttackByName("SummonBiont");
         if (ab != null)
         {
             //single attackbase used for other state ,should not have attack conditions
             ab.AttCons = null;
         }
         _currentAttack = ab;
         ab.Init(this);
         ab.AttackEnter();
         AniEventAniIsOver    = _currentAttack.AniIsOver;
         _timeForIdleThisTime = 2.0f;
     }
     else if (cmd == FCCommand.CMD.STATE_UPDATE)
     {
         if (_currentAttack != null)
         {
             _currentAttack.AttackUpdate();
         }
     }
     else if (cmd == FCCommand.CMD.STATE_DONE)
     {
         ActionSummonBiont();
         SetNextState(AIAgent.STATE.IDLE);
     }
 }
 public override void IdleTaskChange(FCCommand.CMD cmd)
 {
     if (cmd == FCCommand.CMD.STATE_QUIT)
     {
         _owner.ACSetMoveMode(MoveAgent.MOVE_MODE.BY_ANIMATION);
     }
     else if (cmd == FCCommand.CMD.STATE_ENTER)
     {
         _owner.ACSetMoveMode(MoveAgent.MOVE_MODE.BY_MOVE_MANUAL);
         FaceToTarget(_targetAC);
         HandleInnerCmd(FCCommand.CMD.DIRECTION_FOLLOW_FORWARD, null);
         if (_state._preState.CurrentStateID == AIAgent.STATE.ATTACK)
         {
             _awayFromTarget      = AWAY_MODE.AWAY_AFTER_ATTACK;
             _timeForIdleThisTime = 0.1f;
         }
         else if (_state._preState.CurrentStateID == AIAgent.STATE.HURT)
         {
             _awayFromTarget      = AWAY_MODE.AWAY_AFTER_HURT;
             _timeForIdleThisTime = 0.3f;
         }
         else
         {
             _awayFromTarget      = AWAY_MODE.NONE;
             _timeForIdleThisTime = 0;
         }
     }
     else if (cmd == FCCommand.CMD.STATE_UPDATE)
     {
     }
     else if (cmd == FCCommand.CMD.STATE_DONE)
     {
         SetNextState(AIAgent.STATE.HESITATE);
     }
 }
Example #3
0
    private void ScaleTaskChange(FCCommand.CMD cmd)
    {
        if (cmd == FCCommand.CMD.STATE_ENTER)
        {
            AttackActive(true);
            _owner.EotAgentSelf.AddEot(eotData.eotList.ToArray());
            _owner.SetActionSwitchFlag(FC_ACTION_SWITCH_FLAG.IN_EOT_GODDOWN);
            _owner.ACOwner.SkillGodDown = true;
            //Debug.Log("scale enter");
        }
        else if (cmd == FCCommand.CMD.STATE_UPDATE)
        {
            //Debug.Log("scale update");
            ScaleUpdate();
        }
        else if (cmd == FCCommand.CMD.STATE_QUIT)
        {
            //Debug.Log("scale quit");

            foreach (Eot eot in eotData.eotList)
            {
                _owner.EotAgentSelf.ClearEot(eot.eotType);
            }

            _owner.ACOwner.SkillGodDown = false;

            _owner.ClearActionSwitchFlag(FC_ACTION_SWITCH_FLAG.IN_EOT_GODDOWN);
        }
    }
Example #4
0
    public bool Send(FCCommand.CMD cmd, OBJECT_ID objectID, FCCommand.STATE state, bool isHost)
    {
        bool ret = false;

        if (state != FCCommand.STATE.RIGHTNOW)
        {
            FCCommand ewd = null;
            if (_deActiveCommandList.Count != 0)
            {
                ewd = _deActiveCommandList[0];
                _deActiveCommandList.Remove(ewd);
            }
            else
            {
                ewd = new FCCommand();
            }
            ewd.Set(cmd, objectID, state, isHost);
            AddCmdToArray(ewd);
        }
        else
        {
            _fastCommand.Set(cmd, objectID, state, isHost);
            if (objectID.HandleCommand(ref _fastCommand))
            {
                _fastCommand._objID = null;
                ret = true;
            }
            else
            {
                //AddCmdToArray(ewd);
                // may need to add it to command list
            }
        }
        return(ret);
    }
Example #5
0
 public override void IdleTaskChange(FCCommand.CMD cmd)
 {
     if (cmd == FCCommand.CMD.STATE_QUIT)
     {
         _owner.ACSetMoveMode(MoveAgent.MOVE_MODE.BY_ANIMATION);
     }
     else if (cmd == FCCommand.CMD.STATE_ENTER)
     {
         if (_state._preState.CurrentStateID == AIAgent.STATE.HURT)
         {
             _fromHurt = true;
         }
         else
         {
             _fromHurt = false;
         }
         _owner.ACSetMoveMode(MoveAgent.MOVE_MODE.BY_MOVE_MANUAL);
         if (_targetAC.IsAlived)
         {
             SetNextState(AIAgent.STATE.LEAVE_AWAY);
         }
     }
     else if (cmd == FCCommand.CMD.STATE_UPDATE)
     {
         if (_targetAC.IsAlived)
         {
             SetNextState(AIAgent.STATE.LEAVE_AWAY);
         }
     }
     else if (cmd == FCCommand.CMD.STATE_FINISH)
     {
     }
 }
Example #6
0
 public override void Armor1BrokenTaskChange(FCCommand.CMD cmd)
 {
     if (cmd == FCCommand.CMD.STATE_ENTER)
     {
         _owner.ACStop();
         SetActionSwitchFlag(FC_ACTION_SWITCH_FLAG.IN_RIGIDBODY2);
         _owner.ACSetMoveMode(MoveAgent.MOVE_MODE.BY_MOVE_MANUAL);
         _owner._avatarController.RimFlashColor(true);
         if (_haveHpBar)
         {
             _timeCounterSuperArmor1Break = 0;
             //Assertion.Check(UIManager.Instance.SetBossShieldInfo != null);
             //UIManager.Instance.SetBossShieldInfo((int)(_timeForSuperArmor1Break-_timeCounterSuperArmor1Break));
         }
     }
     else if (cmd == FCCommand.CMD.STATE_UPDATE)
     {
         _timeCounterSuperArmor1Break += Time.deltaTime;
         if (_timeCounterSuperArmor1Break > _timeForSuperArmor1Break)
         {
             _timeCounterSuperArmor1Break = _timeForSuperArmor1Break;
         }
         if (_haveHpBar)
         {
             //UIManager.Instance.SetBossShieldInfo((int)(_timeForSuperArmor1Break-_timeCounterSuperArmor1Break));
         }
     }
     else if (cmd == FCCommand.CMD.STATE_QUIT)
     {
         _superArmor.Revive(FCConst.SUPER_ARMOR_LVL1);
         ClearActionSwitchFlag(FC_ACTION_SWITCH_FLAG.IN_RIGIDBODY2);
         _owner._avatarController.RimFlashColor(false);
         if (_haveHpBar)
         {
             //UIManager.Instance.SetBossShieldInfo(-1);
             //UIManager.Instance.SetBossShield(1);
         }
         _owner.ACSetMoveMode(MoveAgent.MOVE_MODE.BY_ANIMATION);
     }
     else if (cmd == FCCommand.CMD.STATE_DONE)
     {
         string skillName = _skillForAwake;
         if (_skillsForAwake != null && _skillsForAwake.Length > _attackCountAgent.AttackLevel)
         {
             skillName = _skillsForAwake[_attackCountAgent.AttackLevel];
         }
         if (skillName != "" &&
             _owner.IsAlived &&
             _attackCountAgent.SkillIsInMap(skillName))
         {
             GoToAttackForce(skillName, -1);
         }
         else
         {
             SetNextState(AIAgent.STATE.IDLE);
         }
     }
 }
Example #7
0
 public override void Armor2BrokenTaskChange(FCCommand.CMD cmd)
 {
     if (cmd == FCCommand.CMD.STATE_ENTER)
     {
         _owner.ACStop();
         _owner.ACSetMoveMode(MoveAgent.MOVE_MODE.BY_MOVE_MANUAL);
     }
     if (cmd == FCCommand.CMD.STATE_DONE)
     {
         SetNextState(AIAgent.STATE.IDLE);
     }
 }
Example #8
0
    public override void DummyTaskChange(FCCommand.CMD cmd)
    {
        base.DummyTaskChange(cmd);

        if (cmd == FCCommand.CMD.STATE_QUIT)
        {
            if (!_isSummonFinish1)
            {
                AddInvincible();
                SummonMonster();
            }
        }
    }
Example #9
0
    public bool HandleInnerCmd(FCCommand.CMD cmd, object param0, object param1, object param2, object param3)
    {
        bool result = false;

        if (_currentStep > 0 && _currentStep < 2)
        {
            switch (cmd)
            {
            case FCCommand.CMD.STOP_IS_ARRIVE_POINT:

                break;
            }
        }
        return(result);
    }
Example #10
0
    //in run state ,I will set CurrentSubStateID before enter.
    public override void RunTaskChange(FCCommand.CMD cmd)
    {
        base.RunTaskChange(cmd);

        //play dust in run state for wolf boss
        if (cmd == FCCommand.CMD.STATE_QUIT)
        {
            CharacterEffectManager.Instance.StopEffect(FC_CHARACTER_EFFECT.DUST_LARGE,
                                                       _owner._avatarController, -1);
        }
        else if (cmd == FCCommand.CMD.STATE_ENTER)
        {
            CharacterEffectManager.Instance.PlayEffect(FC_CHARACTER_EFFECT.DUST_LARGE,
                                                       _owner._avatarController, -1);
        }
    }
Example #11
0
 //we need wolf run way from player
 public override void AwayTaskChange(FCCommand.CMD cmd)
 {
     if (cmd == FCCommand.CMD.STATE_ENTER)
     {
         //first go to rest
         _owner.ACSetMoveMode(MoveAgent.MOVE_MODE.BY_MOVE_MANUAL);
         EventIsStopAtPoint = IsStopAtPoint;
         if (_owner.Energy >= 100 && _aiLevel == 0)
         {
             ChangeAILevel(1);
             SetNextAwayMode(AWAY_MODE.RUN_AWAY);
         }
         else if (_owner.Energy > 0 && _aiLevel == 1)
         {
             SetNextAwayMode(AWAY_MODE.RUN_AWAY);
         }
         else if (_owner.Energy <= 0 && _aiLevel == 1)
         {
             ChangeAILevel(0);
             SetNextAwayMode(AWAY_MODE.TIRED);
         }
         else
         {
             if (!_fromHurt)
             {
                 SetNextAwayMode(AWAY_MODE.HAVE_A_REST);
             }
             else
             {
                 SetNextAwayMode(AWAY_MODE.RUN_AWAY);
             }
         }
         ChangeToAwayMode();
     }
     else if (cmd == FCCommand.CMD.STATE_QUIT)
     {
         _owner.ACStop();
         StopAllCoroutines();
         ClearActionSwitchFlag(FC_ACTION_SWITCH_FLAG.IN_RIGIDBODY2);
         EventIsStopAtPoint = null;
         AniEventAniIsOver  = AniIsOver;
         //_owner.ACSetColliderAsTrigger(false);
         _owner.CurrentAngleSpeed = _owner.Data.angleSpeed;
         _owner.SetShipForSpeedAndForward(MoveAgent.ROTATE_FLAG.FOLLOW_SPEED);
     }
 }
Example #12
0
 public override void AvoidAndShootTaskChange(FCCommand.CMD cmd)
 {
     if (cmd == FCCommand.CMD.STATE_ENTER)
     {
         if (_owner.Energy >= 100)
         {
             SetActionSwitchFlag(FC_ACTION_SWITCH_FLAG.GAIN_NO_ENERGY);
             ClearActionSwitchFlag(FC_ACTION_SWITCH_FLAG.GAIN_ENERGY_BY_ATTACK);
         }
         else
         {
             ClearActionSwitchFlag(FC_ACTION_SWITCH_FLAG.GAIN_NO_ENERGY);
             SetActionSwitchFlag(FC_ACTION_SWITCH_FLAG.GAIN_ENERGY_BY_ATTACK);
         }
         _owner.ACSetMoveMode(MoveAgent.MOVE_MODE.BY_MOVE_MANUAL);
         EventIsStopAtPoint = IsStopAtPoint;
         FC_DANGER_LEVEL edl = GetTargetDangerLevel(_safeDistance, _dangerDistance);
         if (edl == FC_DANGER_LEVEL.SAFE)
         {
             if (_attackCountAgent.CanUseSkill())
             {
                 SetNextRangerMode(RANGER_MODE.SHOOT);
             }
             else
             {
                 SetNextRangerMode(RANGER_MODE.WAIT);
             }
         }
         else
         {
             SetNextRangerMode(RANGER_MODE.AVOID);
         }
         ChangeToRangerMode();
     }
     else if (cmd == FCCommand.CMD.STATE_QUIT)
     {
         _owner.SetShipForSpeedAndForward(MoveAgent.ROTATE_FLAG.FOLLOW_SPEED);
         _owner.ACStop();
         StopAllCoroutines();
         EventIsStopAtPoint = null;
         AniEventAniIsOver  = AniIsOver;
         _owner.ACSetMoveMode(MoveAgent.MOVE_MODE.BY_ANIMATION);
     }
 }
Example #13
0
 public override void HesitateTaskChange(FCCommand.CMD cmd)
 {
     if (cmd == FCCommand.CMD.STATE_ENTER)
     {
         if (_spActAgent != null && _haveWanderAction)
         {
             _spActAgent.StartToWanderAround(this, SpActionIsEnd, _wanderTimeThisTime);
         }
     }
     else if (cmd == FCCommand.CMD.STATE_UPDATE)
     {
     }
     else if (cmd == FCCommand.CMD.STATE_QUIT)
     {
         _spActAgent.StopWanderAround();
         _owner.ACRevertToDefalutMoveParams();
         GoToAttack();
     }
 }
Example #14
0
    public override void LevelUpTaskChange(FCCommand.CMD cmd)
    {
        if (cmd == FCCommand.CMD.STATE_ENTER)
        {
            SetActionSwitchFlag(FC_ACTION_SWITCH_FLAG.IN_SUPER_SAIYAJIN);
            SetActionSwitchFlag(FC_ACTION_SWITCH_FLAG.IN_RIGIDBODY2);

            AttackBase ab = _owner.ACGetAttackByName("LevelUp");
            if (ab != null)
            {
                //single attackbase used for other state ,should not have attack conditions
                ab.AttCons = null;
            }
            if (_hasSuperArmor)
            {
                _superArmor.SetArmor(FCConst.SUPER_ARMOR_LVL1, _armorAddAfterRage);
            }
            _currentAttack = ab;
            ab.Init(this);
            ab.AttackEnter();
            AniEventAniIsOver = _currentAttack.AniIsOver;
        }
        else if (cmd == FCCommand.CMD.STATE_UPDATE)
        {
            if (_currentAttack != null)
            {
                _currentAttack.AttackUpdate();
            }
        }
        else if (cmd == FCCommand.CMD.STATE_DONE)
        {
            GoToAttack();
        }
        else if (cmd == FCCommand.CMD.STATE_QUIT)
        {
            _currentAttack.AttackQuit();
            _currentAttack    = null;
            AniEventAniIsOver = AniIsOver;
            ClearActionSwitchFlag(FC_ACTION_SWITCH_FLAG.IN_SUPER_SAIYAJIN);
            ClearActionSwitchFlag(FC_ACTION_SWITCH_FLAG.IN_RIGIDBODY2);
        }
    }
Example #15
0
    public override void BornTaskChange(FCCommand.CMD cmd)
    {
        if (cmd == FCCommand.CMD.STATE_QUIT)
        {
            CameraController.Instance.AddCharacterForShadow(ACOwner._avatarController);
        }
        else if (cmd == FCCommand.CMD.STATE_UPDATE)
        {
        }
        else if (cmd == FCCommand.CMD.STATE_ENTER)
        {
            if (_needHideWeaponWhenRun)
            {
                _owner.SwitchWeaponTo(EnumEquipSlot.weapon_hang, _defaultWeaponType);
            }
            _runOnPath = false;
            _owner.ACSetMoveMode(MoveAgent.MOVE_MODE.BY_ANIMATION);

            // to find a nearest player as target
            _owner.ACBeginToSearch(true);
        }
        else if (cmd == FCCommand.CMD.STATE_DONE)
        {
            if (GameManager.Instance.GameState == EnumGameState.InBattleCinematic)
            {
                SetNextState(STATE.DUMMY);
            }
            else if (GameManager.Instance.GameState == EnumGameState.InBattle)
            {
                if (!_isSummonFinish1)
                {
                    AddInvincible();
                    SummonMonster();
                }
            }
        }
    }
Example #16
0
    //send msg to all clients except me

    public void SendCommandToOthers(FCCommand.CMD cmd,
                                    OBJECT_ID objID,
                                    Vector3 commandPosition,
                                    object param1,
                                    FC_PARAM_TYPE p1Type,
                                    object param2,
                                    FC_PARAM_TYPE p2Type,
                                    object param3,
                                    FC_PARAM_TYPE p3Type
                                    )
    {
        //single player will not send comment to others
        if (PhotonNetwork.room == null)
        {
            return;
        }

        Debug.Log("[send] command:" + cmd + " , obj_network_id:" + objID.NetworkId);

        //build command instance and add into output list
        FCCommand ewd = new FCCommand(GetNextCommandStreamID(objID.NetworkId));

        ewd.Set((FCCommand.CMD)cmd, objID, param1, p1Type, param2, p2Type, param3, p3Type,
                FCCommand.STATE.RIGHTNOW, false);
        ewd._commandPosition = commandPosition;
        if (CheatManager.netDelay > 0)
        {
            StartCoroutine(AddCommand(ewd));
        }
        else
        {
            _outputCommandList.Add(ewd);
        }
        //
        //_outputCommandList.Add(ewd);
    }
Example #17
0
 public override void IdleTaskChange(FCCommand.CMD cmd)
 {
     if (cmd == FCCommand.CMD.STATE_QUIT)
     {
         _owner.ACSetMoveMode(MoveAgent.MOVE_MODE.BY_ANIMATION);
     }
     else if (cmd == FCCommand.CMD.STATE_ENTER)
     {
         if (_targetAC.IsAlived)
         {
             SetNextState(AIAgent.STATE.AVOID_AND_SHOOT);
         }
     }
     else if (cmd == FCCommand.CMD.STATE_UPDATE)
     {
         if (_targetAC.IsAlived)
         {
             SetNextState(AIAgent.STATE.AVOID_AND_SHOOT);
         }
     }
     else if (cmd == FCCommand.CMD.STATE_FINISH)
     {
     }
 }
    public override void BornTaskChange(FCCommand.CMD cmd)
    {
        if (cmd == FCCommand.CMD.STATE_QUIT)
        {
            ClearActionSwitchFlag(FC_ACTION_SWITCH_FLAG.CANT_MOVE);
            ClearActionSwitchFlag(FC_ACTION_SWITCH_FLAG.CANT_ROTATE);
            ClearActionSwitchFlag(FC_ACTION_SWITCH_FLAG.IN_SUPER_SAIYAJIN);
            ClearActionSwitchFlag(FC_ACTION_SWITCH_FLAG.IN_RIGIDBODY2);

            CameraController.Instance.AddCharacterForShadow(ACOwner._avatarController);
        }
        else if (cmd == FCCommand.CMD.STATE_UPDATE)
        {
            if (!_owner.IsPlayer && _targetAC != null)
            {
                FaceToTarget(_targetAC, true);
            }
        }
        else if (cmd == FCCommand.CMD.STATE_ENTER)
        {
            SetActionSwitchFlag(FC_ACTION_SWITCH_FLAG.CANT_MOVE);
            SetActionSwitchFlag(FC_ACTION_SWITCH_FLAG.CANT_ROTATE);
            SetActionSwitchFlag(FC_ACTION_SWITCH_FLAG.IN_SUPER_SAIYAJIN);

            _runOnPath = false;
            _owner.ACSetMoveMode(MoveAgent.MOVE_MODE.BY_ANIMATION);
            if (!_owner.IsPlayer)
            {
                // to find a nearest player as target
                _owner.ACBeginToSearch(true);
            }
            else
            {
                if (_owner.IsClientPlayer)
                {
                    SetActionSwitchFlag(FC_ACTION_SWITCH_FLAG.IN_SUPER_NAMEKIAN);
                }
                SetNextState(AIAgent.STATE.IDLE);
            }
            if (!ACOwner.IsPlayer)
            {
                GlobalEffectManager.Instance.PlayEffect(FC_GLOBAL_EFFECT.BORN, ACOwner.ThisTransform.position);
            }
        }
        else if (cmd == FCCommand.CMD.STATE_DONE)
        {
            if (GameManager.Instance.GameState == EnumGameState.InBattleCinematic)
            {
                SetNextState(STATE.DUMMY);
            }
            else if (GameManager.Instance.GameState == EnumGameState.InBattle)
            {
                if (_targetAC != null)
                {
                    SetNextState(AIAgent.STATE.HESITATE);
                }
                else
                {
                    SetNextState(AIAgent.STATE.IDLE);
                }
            }
        }
    }
 public override void HesitateTaskChange(FCCommand.CMD cmd)
 {
     if (cmd == FCCommand.CMD.STATE_ENTER)
     {
         _timeTotalForWander  = 0;
         _dangerousRaduisSqrt = _dangerousRaduis * _dangerousRaduis;
         _wanderSpeed         = _owner.Data.TotalMoveSpeed * _wanderSpeedPercents;
         _hDirection          = HES_DIRECTION.NONE;
         _realSafeDistance    = _safeDistance + _bodyRadius + _targetAC.BodyRadius;
         _safeDistanceSqrt    = _realSafeDistance * _realSafeDistance;
         _owner.ACSetMoveMode(MoveAgent.MOVE_MODE.BY_MOVE_MANUAL);
         _wantToAttack  = false;
         _timeForWander = Random.Range(_timeForWanderMin, _timeForWanderMax);
         //CountTargetToSetWay();
         float ret = Random.Range(0, 1f);
         if (_awayFromTarget == AWAY_MODE.AWAY_AFTER_HURT)
         {
             if (RageIsFull)
             {
                 if (CanAttackOthers)
                 {
                     GoToAttack();
                 }
                 else
                 {
                     if (!_haveActionTicket)
                     {
                         FCTicketManager.Instance.ApplyTicket(_owner);
                     }
                 }
             }
             else if (ret < _chanceToAwayAfterHurt)
             {
                 SetNextSeekMode(SEEK_MODE.RUN_AWAY_AFTER_HURT);
             }
             else
             {
                 SetNextSeekMode(SEEK_MODE.WANDER_TO_PLAYER);
             }
             //have chance,
             //RageFromHurt >50
             //rage max = 100.as
             //hurt run away time min and max
         }
         else if (_awayFromTarget == AWAY_MODE.AWAY_AFTER_ATTACK)
         {
             //have chance to hit again
             //or run away
             if (ret < _chanceToAwayAfterAttack)
             {
                 SetNextSeekMode(SEEK_MODE.RUN_AWAY_AFTER_ATTACK);
             }
             else
             {
                 GoToAttack();
             }
         }
         else
         {
             //
             FC_DANGER_LEVEL dl = GetTargetDangerLevel(3, 8);
             if (dl == FC_DANGER_LEVEL.SAFE)
             {
                 _hesitateJitter = Random.Range(_hesitateJitterMin, _hesitateJitterMax);
                 SetNextSeekMode(SEEK_MODE.WANDER_TO_PLAYER);
             }
             else if (dl == FC_DANGER_LEVEL.DANGER)
             {
                 SetNextSeekMode(SEEK_MODE.RUN_AWAY_AFTER_ATTACK);
                 //SetNextSeekMode(SEEK_MODE.RUN_AWAY_AFTER_ATTACK);
             }
             else
             {
                 SetNextSeekMode(SEEK_MODE.RUN_AWAY_AFTER_HURT);
             }
         }
         if (_usedForFly)
         {
             _owner.MoveFollowForward = true;
             _owner.CurrentAngleSpeed = _angleSpeedForFlyWander;
         }
         ChangeToSeekMode();
     }
     else if (cmd == FCCommand.CMD.STATE_UPDATE)
     {
         UpdateHesitate();
     }
     else if (cmd == FCCommand.CMD.STATE_QUIT)
     {
         StopAllCoroutines();
         _owner.CurrentAngleSpeed = _owner.Data.angleSpeed;
         _owner.ACAniSpeedRecoverToNormal();
         _owner.ACRestoreToDefaultSpeed();
         _owner.SetShipForSpeedAndForward(MoveAgent.ROTATE_FLAG.FOLLOW_SPEED);
         //_owner.MoveFollowForward = false;
     }
 }
Example #20
0
 public override bool HandleInnerCmd(FCCommand.CMD cmd, object param0)
 {
     return(HandleInnerCmd(cmd, param0, null, null, null));
 }
Example #21
0
 public override void IdleTaskChange(FCCommand.CMD cmd)
 {
     if (cmd == FCCommand.CMD.STATE_QUIT)
     {
         _owner.ACSetMoveMode(MoveAgent.MOVE_MODE.BY_ANIMATION);
     }
     else if (cmd == FCCommand.CMD.STATE_ENTER)
     {
         if (!_isFight)
         {
             _wanderTimeThisTime  = -1;
             _timeForIdleThisTime = Random.Range(_timeForIdleMin, _timeForIdleMax);
             //_owner.ACSetMoveMode(MoveAgent.MOVE_MODE.BY_MOVE_MANUAL);
             _haverWanderActionThisTime = _haveWanderAction;
             AIAgent.STATE aas = AIAgent.STATE.IDLE;
             if (_state._preState != null)
             {
                 aas = _state._preState.CurrentStateID;
             }
             AIAgent.STATE ret = AIAgent.STATE.NONE;
             if (_state._preState.CurrentStateID == AIAgent.STATE.BORN)
             {
                 ret = AIAgent.STATE.ATTACK;
             }
             else if (_skillCount > 0 && aas == AIAgent.STATE.ATTACK && _afterSkill != null && _afterSkill.Count > 0)
             {
                 foreach (StateToGoCondition stgc in _afterSkill)
                 {
                     if (stgc.GetStateToGo(_skillCount, ref ret, ref _timeForIdleThisTime, ref _wanderTimeThisTime))
                     {
                         break;
                     }
                 }
             }
             if (ret == AIAgent.STATE.ATTACK)
             {
                 GoToAttack();
             }
             else if (ret == AIAgent.STATE.IDLE)
             {
                 _haverWanderActionThisTime = false;
             }
         }
         _owner.ACSetMoveMode(MoveAgent.MOVE_MODE.BY_ANIMATION);
         HandleInnerCmd(FCCommand.CMD.DIRECTION_FOLLOW_FORWARD, null);
         if (!_owner.IsPlayer)
         {
             _owner.ACStop();
         }
     }
     else if (cmd == FCCommand.CMD.STATE_FINISH)
     {
     }
     else if (cmd == FCCommand.CMD.STATE_DONE)
     {
         if (_isFight)
         {
             if (_haverWanderActionThisTime)
             {
                 SetNextState(AIAgent.STATE.HESITATE);
             }
             else
             {
                 GoToAttack();
             }
         }
         else
         {
             SetNextState(AIAgent.STATE.IDLE);
         }
     }
 }
Example #22
0
    public override bool HandleInnerCmd(FCCommand.CMD cmd, object param0, object param1, object param2, object param3)
    {
        bool ret = false;

        if (_sAHandleCmd != null)
        {
            ret = _sAHandleCmd(cmd, param0, param1, param2, param3);
        }
        if (!ret)
        {
            switch (cmd)
            {
            //state
            case FCCommand.CMD.STATE_GOTO:
            {
                AIAgent.STATE ast = (AIAgent.STATE)param0;
                ret = SetNextState(ast);
                break;
            }

            case FCCommand.CMD.STATE_ENTER:
                switch (_state.CurrentStateID)
                {
                case STATE.RUN:
                {
                    GotoNextPathPoint();
                    ret = true;
                    break;
                }

                case STATE.IDLE:
                {
                    if (_faceTarget == null)
                    {
                        _owner.ACRotateTo(_targetDirection, -1, true, true);
                    }
                    break;
                }
                }
                break;

            case FCCommand.CMD.STATE_DONE:
            {
                switch (_state.CurrentStateID)
                {
                case STATE.BORN:
                {
                    _owner.SetShipForSpeedAndForward(MoveAgent.ROTATE_FLAG.FOLLOW_SPEED);
                    _owner.ACSetMoveMode(MoveAgent.MOVE_MODE.BY_MOVE_MANUAL);
                    if (HasPathWay && !_controlByPlayer)
                    {
                        if (_pathway.HasPath)
                        {
                            _runOnPath = true;
                            SetNextState(AIAgent.STATE.RUN);
                        }
                        else
                        {
                            _runOnPath = false;
                            SetNextState(AIAgent.STATE.IDLE);
                        }
                    }
                    else
                    {
                        _runOnPath = false;
                        HandleInnerCmd(FCCommand.CMD.DIRECTION_FOLLOW_FORWARD, null);
                        SetNextState(AIAgent.STATE.IDLE);
                    }
                    ret = true;
                    break;
                }

                case STATE.RUN:
                {
                    ret = SetNextState(AIAgent.STATE.IDLE);
                    break;
                }

                case STATE.IDLE:
                {
                    ret = SetNextState(AIAgent.STATE.RUN);
                    break;
                }
                }

                break;
            }

            case FCCommand.CMD.MOVE_TO_POINT:
            {
                Vector3 p = (Vector3)param1;
                _owner.ACMove(ref p);
                ret = true;
                break;
            }


            //stop
            case FCCommand.CMD.STOP:
                _owner.ACStop();
                ret = true;
                break;

            case FCCommand.CMD.STOP_IS_ARRIVE_POINT:
            {
                _targetDirection = _owner.ThisTransform.forward;
                SetNextState(AIAgent.STATE.IDLE);
                break;
            }

            //Set
            case FCCommand.CMD.SET_TO_DEFAULT_SPEED:
            {
                ACOwner.CurrentSpeed = _owner.Data.TotalMoveSpeed;
                ret = true;
                break;
            }


            //direction
            case FCCommand.CMD.DIRECTION_FOLLOW_FORWARD:
            {
                _owner.SetShipForSpeedAndForward(MoveAgent.ROTATE_FLAG.FOLLOW_SPEED);
                ret = true;
                break;
            }

            case FCCommand.CMD.DIRECTION_UNLOCK:
            {
                _owner.SetShipForSpeedAndForward(MoveAgent.ROTATE_FLAG.UNLOCK);
                ret = true;
                break;
            }

            //action
            case FCCommand.CMD.ACTION_IS_AWAY_NPC:
            {
                Transform tf = (Transform)param1;
                if (tf == _faceTarget)
                {
                    _faceTarget = null;
                }
                ret = true;
                break;
            }

            case FCCommand.CMD.ACTION_IS_NEAR_NPC:
            {
                Transform tf = (Transform)param1;
                _faceTarget = tf;
                ret         = true;
                break;
            }
            }
        }
        return(ret);
    }
Example #23
0
 public override void RunTaskChange(FCCommand.CMD cmd)
 {
     base.RunTaskChange(cmd);
 }