void CheckEdge() // this code checks if the duck has gone out of the duckBoundary, and what should happen when it does { switch (duckState) { case DuckState.alive: // if the duck is alive, the code will ake sure it bounces around the duckBoundary if (Bounce()) // if the duck bounced, we need to run code to update it's velocity and animations { // if it didn't bounce, it would be a waste of resources to run this code rb.velocity = direction * speed; // and, set it's velocity to the new direction multiplied by the duck's speed if (direction.x > 0) { // if the direction is positive, make it face right animator.Play("Fly1"); } else { // otherwise, make it face left animator.Play("Fly2"); } } break; case DuckState.falling: // if the duck is falling, the code will kill it when it reaches the bottom of the duckBoundary if (transform.position.y < duckBoundary.boundary.yMin) { // if the duck's y is less than the boundary's minimum y, duckState = DuckState.dead; // set it as dead, Dead(); // and kill it } break; } }
bool firstFall; // is this the first loop where the duck is falling? void Start() { audioManager = AudioManager.instance; // set up singletons duckBoundary = DuckBoundary.instance; animator = GetComponent <Animator>(); rb = GetComponent <Rigidbody2D>(); // access the various components hitbox = GetComponent <Hitbox>(); fallSound.InitializeAudioSource(gameObject.AddComponent <AudioSource>()); // initialize the fall sound speed = Random.Range(minSpeed, maxSpeed); // generate a random speed for the duck direction = directions[Random.Range(0, directions.Length)]; // set the duck's direction to one of the 4 defined above firstFall = true; // the duck hasn't fallen yet, so the next fall will certainly be it's first if (direction.x < 0) { // the animator defaults to the animation "Fly1", which faces right. if the x direction is negative, animator.Play("Fly2"); // the duck will be flying left, so we have to play "FLy2", an animation that faces left } rb.velocity = direction * speed; // set the physics velocity to the duck's directional vector multiplied by the duck's speed duckState = DuckState.alive; // make sure the duck is alive }
protected virtual void Awake() { _state = GetComponent <DuckState>(); _health = GetComponent <Health>(); _carrier = GetComponent <Carrier>(); _diver = GetComponent <DiveDamager>(); _flyControl = GetComponent <FlyControl>(); }
// Use this for initialization void Awake() { _state = GetComponent <DuckState>(); _health = GetComponent <Health>(); _data = _state.Data; _carrier = GetComponentInChildren <Carrier>(); _blast = GetComponentInChildren <Blast>(); _body = GetComponent <MovableBody>(); _flyControl = GetComponent <FlyControl>(); }
private void Awake() { _view = GetComponent <PlayerView>(); _state = GetComponent <DuckState>(); _health = GetComponent <Health>(); _diver = GetComponent <DiveDamager>(); _body = GetComponent <MovableBody>(); _carrier = GetComponent <Carrier>(); _flyControl = GetComponent <FlyControl>(); }
public Duck(MainWindow window, int top, DuckController controller) { dispatcher = Dispatcher.CurrentDispatcher; aliveDuck = new AliveDuck(this); shotDuck = new ShotDuck(this); deadDuck = new DeadDuck(this); this.controller = controller; duckState = aliveDuck; }
public void duckCamera(DuckState state) { if (state == DuckState.duckStart) { height = 8.0f; } else if (state == DuckState.duckOver) { height = deftHeight; } }
public void OnDuckStateRestoringComplete(DuckState state) { object[] objArray1 = new object[] { state }; base.method_8("OnDuckStateRestoringComplete", objArray1); }
public void setDuckState(DuckState newDuckState) { duckState = newDuckState; }
void Update() { if (m_isActive) { if ((m_currentState == DuckState.Inactive) || (m_currentState == DuckState.Release)) { if (m_attack == 0.0f) { m_currentState = DuckState.Hold; m_fadeT = 1.0f; } else { m_currentState = DuckState.Attack; m_faderSpeed = (1.0f) / m_attack; } } } else { if (m_currentState != DuckState.Inactive) { if (m_attack == 0.0f) { m_currentState = DuckState.Inactive; m_fadeT = 0.0f; } else { m_currentState = DuckState.Release; m_faderSpeed = (1.0f) / m_release; } } } switch (m_currentState) { case DuckState.Attack: m_fadeT += m_faderSpeed * WingroveRoot.GetDeltaTime(); if (m_fadeT >= 1.0f) { m_fadeT = 1.0f; m_currentState = DuckState.Hold; } break; case DuckState.Hold: m_fadeT = 1.0f; break; case DuckState.Release: m_fadeT -= m_faderSpeed * WingroveRoot.GetDeltaTime(); if (m_fadeT <= 0.0f) { m_fadeT = 0.0f; m_currentState = DuckState.Inactive; } break; case DuckState.Inactive: break; } }
void Update() { bool hasActiveCues = false; foreach (BaseWingroveAudioSource was in m_audioSources) { if (was.HasActiveCues()) { hasActiveCues = true; } } if (hasActiveCues) { if ((m_currentState == DuckState.Inactive) || (m_currentState == DuckState.Release)) { if (m_attack == 0.0f) { m_currentState = DuckState.Hold; m_fadeT = 1.0f; } else { m_currentState = DuckState.Attack; m_faderSpeed = (1.0f) / m_attack; } } } else { if (m_currentState != DuckState.Inactive) { if (m_attack == 0.0f) { m_currentState = DuckState.Inactive; m_fadeT = 0.0f; } else { m_currentState = DuckState.Release; m_faderSpeed = (1.0f) / m_release; } } } switch (m_currentState) { case DuckState.Attack: m_fadeT += m_faderSpeed * WingroveRoot.GetDeltaTime(); if (m_fadeT >= 1.0f) { m_fadeT = 1.0f; m_currentState = DuckState.Hold; } break; case DuckState.Hold: m_fadeT = 1.0f; break; case DuckState.Release: m_fadeT -= m_faderSpeed * WingroveRoot.GetDeltaTime(); if (m_fadeT <= 0.0f) { m_fadeT = 0.0f; m_currentState = DuckState.Inactive; } break; case DuckState.Inactive: break; } }
void Awake() { _state = GetComponent <DuckState>(); }
public void AnimateRestoringDuckState(DuckState state) { object[] objArray1 = new object[] { state }; base.method_8("AnimateRestoringDuckState", objArray1); }
public void ChangeDuckState(DuckState state, DuckMode mode) { object[] objArray1 = new object[] { state, mode }; base.method_8("ChangeDuckState", objArray1); }
// Use this for initialization void Awake() { _arbiter = GetComponent <Arbiter>(); _arbiter.CollidersEnabled = false; _owner = transform.parent.GetComponent <DuckState>(); }