示例#1
0
    protected virtual void Idle()
    {
        switch (State)
        {
        case NpcPhysicalState.Waiting:
        {
            StopMoving();

            if (_waitingTime < 0)
            {
                _waitingTime = Random.Range(MinWaitTime, MaxWaitTime);
            }

            _waitedFor += Time.deltaTime;

            if (_waitedFor > _waitingTime)
            {
                State = NpcPhysicalState.Moving;

                _waitedFor   = 0;
                _waitingTime = -1;
            }

            break;
        }

        case NpcPhysicalState.Moving:
        {
            if (_moveDirection == Vector2.zero)
            {
                PickRandomMovementDirection();
                _waitedFor   = 0;
                _waitingTime = Random.Range(MinMovementTime, MaxMovementTime);
            }

            MoveToDirection();

            _waitedFor += Time.deltaTime;

            if (_waitedFor > _waitingTime)
            {
                StopMoving();

                _waitedFor   = 0;
                _waitingTime = -1;
                State        = NpcPhysicalState.Waiting;
            }

            break;
        }

        case NpcPhysicalState.Attacking:
        case NpcPhysicalState.Defending:
        default:
            break;
        }
    }
示例#2
0
 public virtual void TargetedBy(Civilian shooter)
 {
     State = NpcPhysicalState.Moving;
 }