コード例 #1
0
 void CheckIfStillSeeing(float _deltaTime)
 {
     _timeSinceLastCheck += _deltaTime;
     if (_timeSinceLastCheck > _checkInterval)
     {
         _timeSinceLastCheck -= _checkInterval;
         if (_target.CanSee(_self.transform.position))
         {
             _self.SetAction(new ValueAction(ActionType.SawTarget, _timeSinceSeenTarget, true));
             _self.SetAction(new VectorAction(ActionType.SawTarget, _lastKnownPostion, true));
             if (Vector3.Distance(_lastKnownPostion, _target.transform.position) > _distanceThrehold)
             {
                 _self.SetAtomicAction(ActionType.AIRotate, _self, _target.transform.position, GameManager.FixedGameTime);
             }
             _lastKnownPostion = _target.transform.position;
         }
         else
         {
             _timeSinceSeenTarget += _checkInterval;
             if (_timeSinceSeenTarget > _timeToLoseTarget)
             {
                 _self.SetAction(new BasicAction(ActionType.DidntSeeTarget, true));
             }
         }
     }
     if (_timeSinceLastCheck < 0)
     {
         _timeSinceLastCheck += _checkInterval;
     }
 }