public void SetToDead() //Used to set this to dead; most commonly called by RexActor when its HP drops to 0 or it otherwise is killed { EndAllStates(); DeathState deathState = GetComponent <DeathState>(); if (deathState) { deathState.Begin(); } }
void Awake() { aerialPeak = transform.position.y; if (slots.actor == null) { slots.actor = GetComponent <RexActor>(); } if (slots.physicsObject == null) { slots.physicsObject = GetComponent <RexPhysics>(); } //Buffering any MovingStates or LandingStates attached to this so we don't have to call GetComponent constantly movingState = GetComponent <MovingState>(); landingState = GetComponent <LandingState>(); if (states == null) { states = new List <RexState>(); } if (concurrentStates == null) { concurrentStates = new List <RexState>(); } //Add all states with isConcurrent marked to the concurrentStates list, and all other states to states list, for easier and faster updates RexState[] stateComponents = GetComponents <RexState>(); //Create default, falling, and death states automatically, since every RexController needs them defaultState = gameObject.AddComponent(typeof(DefaultState)) as DefaultState; defaultState.animation = animations.defaultAnimation; fallingState = gameObject.AddComponent(typeof(FallingState)) as FallingState; fallingState.animation = animations.fallingAnimation; deathState = gameObject.AddComponent(typeof(DeathState)) as DeathState; deathState.animation = animations.deathAnimation; deathState.audioClip = audioClips.deathClip; //Automatically make this face left or right based on whether or not the transform is scaled to a negative or not direction.horizontal = (slots.actor && slots.actor.transform.localScale.x >= 0.0f) ? Direction.Horizontal.Right : Direction.Horizontal.Left; }