Example #1
0
 void DetectState(Collider2D other)
 {
     // Si el collider tiene tag Ground, reseteamos las animaciones y cambiamos el estado a Grounded.
     if (IsTagged("Ground", other) || IsTagged("Enemy", other))
     {
         ResetAnims();
         movementScript.SwapState(GroundedState.GetInstance());
     }
     // Si el collider tiene tag Rope (Soga), le avisamos al script de interaccion que tiene un objeto
     // para interactuar, y no hacemos nada más.
     else if (IsTagged("Rope", other))
     {
         interactionScript.objectToInteract = other.gameObject;
         feedbackScript.ShowRopeFeedback();
     }
     // Si el collider tiene tag Water, reseteamos las animaciones, cambiamos el estado a Swimming y
     // le avisamos al animatorController que se esta nadando.
     else if (IsTagged("Water", other))
     {
         ResetAnims();
         movementScript.SwapState(SwimmingState.GetInstance());
         movementScript.anim.SetBool("isSwimming", true);
     }
     else if (IsTagged("TeleportInteracter", other))
     {
         interactionScript.objectToInteract = other.gameObject;
         feedbackScript.ShowDoorFeedback();
     }
 }
Example #2
0
 static public SwimmingState GetInstance()
 {
     if (instance == null)
     {
         instance = new SwimmingState();
     }
     return(instance);
 }
Example #3
0
        // Start is called before the first frame update
        protected virtual void Start()
        {
            _fsm = new FSM <States>();

            FlockEntity flockEntity = this.GetComponent <FlockEntity>();

            SwimmingState <States> swimming = new SwimmingState <States>(_fsm, this, flockEntity);
            InFlockState <States>  inflock  = new InFlockState <States>(_fsm, this, flockEntity);

            swimming.AddTransition(States.IN_FLOCK, inflock);
            inflock.AddTransition(States.SWIMMING, swimming);

            _fsm.SetInit(swimming);
        }
 public void SetSwimState(SwimmingState swimstate)
 {
     m_SwimState = swimstate;
 }