Example #1
0
 public override void Enter()
 {
     base.Enter();
     _characterMotor    = _go.GetComponent <CharacterMotor>();
     _catchParticipant  = _go.GetComponent <CatchParticipant>();
     _catchParticipants = GameObject.FindObjectsOfType <CatchParticipant>();
 }
    public void OnCollisionStay(Collision collision)
    {
        CatchParticipant collidingGameParticipant = collision.gameObject.GetComponent <CatchParticipant>();

        //If no longer immune to being gaught
        //If I am the catcher and catch a runner
        if (collidingGameParticipant != null && _CatchRole == CatchRole.Catcher && collidingGameParticipant._CatchRole == CatchRole.Runner)
        {
            if (_lastCatchCollisionTime + _catchImmunityTime < Time.time && collidingGameParticipant._lastCatchCollisionTime + _catchImmunityTime < Time.time && collidingGameParticipant._lastCatchCollisionTime + _catchImmunityTime < Time.time)
            {
                _lastCatchCollisionTime = Time.time;
                collidingGameParticipant._lastCatchCollisionTime = Time.time;

                _CatchRole = CatchRole.Runner;
                collidingGameParticipant._CatchRole = CatchRole.Catcher;
            }
        }
    }
Example #3
0
        private Vector3 GetClosestRunnerPos()
        {
            CatchParticipant closestParticipant = null;
            float            curMinDistance     = 99999;

            for (int i = 0; i < _catchParticipants.Length; i++)
            {
                if (_catchParticipants[i] != this._catchParticipant)
                {
                    float distance = Vector3.Distance(_go.transform.position, _catchParticipants[i].transform.position);
                    if (distance < curMinDistance)
                    {
                        curMinDistance     = distance;
                        closestParticipant = _catchParticipants[i];
                    }
                }
            }
            return(closestParticipant.transform.position);
        }
Example #4
0
 public override void Enter()
 {
     _characterMotor   = _go.GetComponent <CharacterMotor>();
     _catchParticipant = _go.GetComponent <CatchParticipant>();
 }
 private void Awake()
 {
     catchParticipant = GetComponent <CatchParticipant>();
     _sm           = new StateMachine();
     _sm._CurState = new TauntingState(gameObject, _sm);
 }