public override void Initialize()
    {
        for (int i = 0; i < 10; ++i)
        {
            LavaPillar lava = Instantiate(lavaOrigin).GetComponent <LavaPillar>();
            lava.Initialize();
            lava.gameObject.SetActive(false);
            lavaList.Add(lava);
        }

        genTime = Random.Range(1f, 1f);
    }
    private void FixedUpdate()
    {
        Astronaut plr             = Astronaut.TheAstronaut;
        bool      lookindirection = false;



        bool stateexpired = (Time.time >= (StateTime + StateDuration));

        /*
         *  if (Defeated)
         * {
         *  MyRigidbody.bodyType = RigidbodyType2D.Static;
         *  MyCollider.enabled = false;
         * }
         */
        switch (MyState)
        {
        case State.Waiting: { break; }

        case State.Introducing:
        {
            //Introduced = false;
            //Rise up from the ground in a menacing fashion
            this.Vulnerable = false;
            SwimTowards     = 0;

            Astronaut.TheAstronaut.MyRigidbody.velocity = new Vector2(0f, Astronaut.TheAstronaut.MyRigidbody.velocity.y);         //Hold Still, please.
            if (!Risen)
            {
                Vector3 dif   = (IntroTargetPosition.position - this.transform.position);
                float   speed = 5f;
                float   d     = (speed * Time.deltaTime);
                if (!MagmaSplash.isPlaying)
                {
                    MagmaSplash.Play();
                }
                if (dif.magnitude < d)
                {
                    this.transform.position = IntroTargetPosition.position;
                    Risen  = true;
                    Roared = false;
                    MySpriteRenderer.transform.localPosition = new Vector3(0f, 0f, 0f);
                }
                else
                {
                    this.transform.position = (this.transform.position + (dif.normalized * d));
                    Vector2 c = (Random.insideUnitCircle.normalized * .1f);

                    MySpriteRenderer.transform.localPosition = new Vector3(c.x, c.y, 0f);
                }
            }
            else if (!Roared)
            {
                RoarParticles.Play();
                AudioManager.AM.crossfade(AudioManager.AM.CurrentMusic, 0f, .3f);
                AudioManager.AM.playGeneralSoundOneShot(AudioManager.AM.FireBossRoar, AudioManager.AM.PlayerAudioMixer, 1f, 1f, false, 10f);
                plr.addCamShake(1f, 1f, 1f, 3f, .5f);
                Roared   = true;
                RoarTime = Time.time;
                MagmaSplash.Stop();
                //Pass some RRRRRRRAAAAAAAAWWWWWWWRRRRRRRR!!!! text.
            }
            else
            {
                if ((Time.time - RoarTime) >= 3f)
                {
                    Introduced = true;
                    beginBossFight();
                    //setState(State.StandingBy,3f+Random.value*3f);
                    standBy();
                }
            }


            break;
        }

        case State.StandingBy:
        {
            //Move Towards the Player
            setThrowEffect(false);
            if (!Defeated)
            {
                if (!MagmaSplash.isPlaying)
                {
                    MagmaSplash.Play();
                }
                this.Vulnerable = true;
                if ((plr != null) && (plr.Alive))
                {
                    Vector3 dif = (plr.transform.position - this.transform.position);
                    int     dir = (int)Mathf.Sign(dif.x);
                    if (SwimTowards == 0)
                    {
                        SwimTowards = dir;
                    }
                    else
                    {
                        LookDirection        = 0;
                        MoveDirection        = SwimTowards;
                        MyRigidbody.velocity = new Vector2(SwimTowards * WalkSpeed * (1f + (4f * Astronaut.AggressionLevelF)), MyRigidbody.velocity.y);
                    }

                    if (stateexpired)
                    {
                        //Choose an action
                        MyRigidbody.velocity = new Vector2(0f, MyRigidbody.velocity.y);
                        float r = Random.value;
                        if (r < .25f)
                        {
                            startThrowAttack();        //startRainingFlameMeteor();
                        }
                        else if (r < .5f)
                        {
                            startFireBeam();
                        }
                        else if (r < .75f)
                        {
                            startLavaPillars();
                        }
                        else if ((Random.value < .5f) && (!HasRepositioned))
                        {
                            startRepositioning();
                        }
                        else
                        {
                            standBy();
                        }
                    }
                }
            }


            break;
        }

        case State.Repositioning:
        {
            if (!Defeated)
            {
                MyCollider.enabled   = false;
                MyRigidbody.bodyType = RigidbodyType2D.Kinematic;

                float st = ((Time.time - StateTime) / StateDuration);
                if (st < .5f)
                {
                    MagmaSplash.Emit(3);
                    this.transform.position = Vector3.Lerp(repositionstartposition, new Vector3(repositionstartposition.x, StartTransform.position.y, repositionstartposition.z), st / .5f);
                }
                else if (st < 1f)
                {
                    this.transform.position = Vector3.Lerp(new Vector3(repositiondestination.x, StartTransform.position.y, repositiondestination.z), repositiondestination, (st - .5f) / .5f);
                    MagmaSplash.Emit(3);
                    if (!MagmaSplash.isPlaying)
                    {
                        MagmaSplash.Play();
                    }
                }
                else
                {
                    if (MagmaSplash.isPlaying)
                    {
                        MagmaSplash.Stop();
                    }
                    this.transform.position = repositiondestination;
                }
                if (!MagmaSplash.isPlaying)
                {
                    MagmaSplash.Play();
                }
            }

            if (stateexpired)
            {
                if (!Defeated)
                {
                    this.transform.position = repositiondestination;
                    MyCollider.enabled      = true;
                    MyRigidbody.bodyType    = RigidbodyType2D.Dynamic;
                    standBy();
                    HasRepositioned = true;
                }
            }
            break;
        }

        case State.FireBeaming:
        {
            SwimTowards   = 0;
            MoveDirection = 0;
            //MyFireBeam.BreathActive = true;
            MyRigidbody.velocity = new Vector2(0f, MyRigidbody.velocity.y);
            setThrowEffect(false);
            if (!Defeated)
            {
                if ((plr != null) && (plr.Alive))
                {
                    MyFireBeam.BeamActive = true;
                    Vector3 dif = (plr.transform.position - MyFireBeam.transform.position);
                    if (Mathf.Sign(dif.x) == LookDirection)
                    {
                        float ang       = Vector3.SignedAngle(MyFireBeam.transform.forward, dif.normalized, Vector3.forward);
                        float maxdegsPS = (10f * (1 * Astronaut.AggressionLevel));
                        float delt      = maxdegsPS * Time.fixedDeltaTime;
                        //MyIceBreath.transform.LookAt(MyIceBreath.transform.position + dif.normalized);
                        //if (false)

                        if (Mathf.Abs(ang) < delt)
                        {
                            //MyFireBeam.transform.LookAt(MyFireBeam.transform.position + dif.normalized);
                            MyFireBeam.transform.Rotate(0f, 0f, Mathf.Sign(ang), Space.World);
                        }
                        else
                        {
                            MyFireBeam.transform.Rotate(0f, 0f, Mathf.Sign(ang) * delt, Space.World);
                        }
                    }

                    /*
                     * if (MyFireBeam.MyCollider.OverlapPoint(new Vector2(plr.transform.position.x, plr.transform.position.y)))
                     * {
                     *  MyFireBeam.OnTouched(plr.MyCollider);
                     * }
                     */
                    //Physics2D.OverlapBox(,LayerMask.GetMask(new string[]{"Player" }));
                }
                if (stateexpired)
                {
                    MyFireBeam.BeamActive = false;
                    standBy();
                }
            }
            break;
        }

        case State.LavaPillar:
        {
            if (!Defeated)
            {
                if (stateexpired)
                {
                    if (LavaPillarsRemaining > 0)
                    {
                        LavaPillarsRemaining--;
                        Vector3 lpos = Vector3.Lerp(LavaPillarTransform1.position, LavaPillarTransform2.position, Random.value);
                        LavaPillarTelegraphRing.Play();
                        if ((Random.value < .25f) && ((plr != null) && (plr.Alive)))
                        {
                            lpos = new Vector3(plr.transform.position.x, lpos.y, lpos.z);
                        }
                        lpos = new Vector3(lpos.x, lpos.y - 2f, lpos.z);
                        LavaPillar lp = GameObject.Instantiate(LavaPillarPrefab, lpos, LavaPillarPrefab.transform.rotation);
                        lp.PillarDuration *= 1f;
                        StateTime          = Time.time;
                        StateDuration      = 1f;
                    }
                    else
                    {
                        standBy();
                    }
                }
            }
            break;
        }

        case State.FlameMeteor:
        {
            /*
             * if (!Defeated)
             *  if (stateexpired)
             *  {
             *      standBy();
             *  }
             *
             */
            break;
        }

        case State.LavaThrowing:
        {
            float throwPoseDur  = 2.2f * (1f - (.75f * Astronaut.AggressionLevelF));
            float throwWaitDur  = .8f * (1f - (.75f * Astronaut.AggressionLevelF));
            float throwDuration = .4f * (1f - (.75f * Astronaut.AggressionLevelF));
            float ThrowVelocity = 10f * (1f + (1f * Astronaut.AggressionLevelF));
            float v             = (Time.time - StateTime);
            if (!Defeated)
            {
                if (ThrowPoised)
                {
                    if ((v / throwDuration) >= 1f)
                    {
                        //setThrowEffect(false);
                        MyRigidbody.velocity = new Vector2(0f, MyRigidbody.velocity.y);

                        foreach (Lavaball lb in BallsOfLava)
                        {
                            if (lb != null)
                            {
                                Vector3 rs  = (Random.insideUnitCircle * 1f);
                                Vector3 dif = ((plr.transform.position + new Vector3(rs.x, rs.y, 0f)) - lb.transform.position);
                                dif = dif.normalized;
                                lb.Launch(dif * ThrowVelocity);
                            }
                        }
                        BallsOfLava.Clear();
                        //ThrowTransform.position = SlashEndTransform.position;
                        if ((v / (throwDuration + throwWaitDur)) >= 1f)
                        {
                            standBy();
                            ThrowTransform.position = ThrowAwayTransform.position;
                        }
                    }
                    else
                    {
                        ThrowTransform.position = Vector3.Lerp(ThrowStartTransform.position, ThrowEndTransform.position, (v / throwDuration));
                        //setThrowEffect(true);
                    }
                }
                else
                {
                    //setThrowEffect(true);

                    if ((v / throwPoseDur) >= 1f)
                    {
                        ThrowTransform.position = ThrowStartTransform.position;
                        if (v / (throwPoseDur + throwWaitDur) >= 1f)
                        {
                            ThrowPoised = true;
                            StateTime   = Time.time;
                        }
                    }
                    else
                    {
                        ThrowTransform.position = Vector3.Lerp(ThrowAwayTransform.position, ThrowStartTransform.position, Mathf.Clamp01(v / throwPoseDur));

                        MyRigidbody.velocity = new Vector2(0f, MyRigidbody.velocity.y);
                    }
                    foreach (Lavaball lb in BallsOfLava)
                    {
                        if (lb != null)
                        {
                            lb.transform.position = (lb.StartPosition + (ThrowTransform.position - ThrowAwayTransform.position));
                        }
                    }
                }
            }

            if (Defeated)
            {
                foreach (Lavaball lb in BallsOfLava)
                {
                    if (lb.gameObject.activeInHierarchy)
                    {
                        GameObject.Destroy(lb.gameObject);
                    }
                }
                BallsOfLava.Clear();
            }

            if (!Defeated)
            {
                MyCollider.enabled = true;
            }
            break;
        }

        case State.Defeated:
        {
            float f = (Time.time - StateTime);
            MyFireBeam.BeamActive            = false;
            RainingFlameMeteor               = false;
            MyCollider.enabled               = false;
            MyRigidbody.bodyType             = RigidbodyType2D.Kinematic;
            MyRigidbody.velocity             = new Vector2(0f, 0f);
            LavaTransform.transform.position = LavaTransform.transform.position - (Vector3.up * Time.deltaTime * 2f);         //Make the lava subside when defeated
            if (f < 3f)
            {
                setThrowEffect(false);
                MySpriteRenderer.enabled = true;
                MySpriteRenderer.color   = new Color(MySpriteRenderer.color.r, MySpriteRenderer.color.g, MySpriteRenderer.color.b, 1f - (f / 3f));
                MySpriteRenderer.transform.Rotate(0f, 0f, Time.fixedDeltaTime * 360f * 4f);
            }
            else
            {
                if (!PlayerHasBeenReleased)
                {
                    plr.PlayerHasControl = false;
                    MyDroppedGoalElement.HomingInOnAstronaut = true;
                    MyDroppedGoalElement.HomingTime          = Time.time;
                    MyDroppedGoalElement.Collectable         = true;
                    Astronaut.TheAstronaut.WatchingLocation  = null;
                    PlayerHasBeenReleased = true;
                }
                MySpriteRenderer.enabled = false;
            }


            break;
        }
        }

        if (LookDirection != 0)
        {
            if (ForwardFacing != 0)
            {
                ForwardFacing = LookDirection;
            }
        }
        else
        {
            if (MoveDirection != 0)
            {
                ForwardFacing = MoveDirection;
            }
        }

        if (RainingFlameMeteor)
        {
            RainingFlameMeteor = false;
            dropMeteor();

            /*
             * if ((Time.time - RainingIceShardsStartTime) >= RainingIceShardsDuration)
             * {
             *  RainingFlameMeteor = false;
             * }
             *
             * if ((Time.time - LastShardDroppedTime) >= IceShardDropInterval)
             * {
             *  dropIcicle();
             * }
             */
        }



        updateForwardFace();
        //MyFireBeam.FrostParticles.transform.localScale = new Vector3(-1 * ForwardFacing * Mathf.Abs(MyFireBeam.FrostParticles.transform.localScale.x),
        //MyFireBeam.FrostParticles.transform.localScale.y, MyFireBeam.FrostParticles.transform.localScale.z);
    }