Пример #1
0
    protected override void StateChanged()
    {
        base.StateChanged();

        switch ((EntityState)state)
        {
        case EntityState.Normal:
            CancelInvoke(fireStartFunc);
            bodySpriteCtrl.StopOverrideClip();
            mFiring = false;

            float side = Mathf.Sign(Player.instance.collider.bounds.center.x - collider.bounds.center.x);
            bodyCtrl.moveSide = side;

            if (mSensor)
            {
                mSensor.Activate(true);
            }

            Invoke(fireStartFunc, projStartDelay);
            break;

        case EntityState.Stun:
            bodyCtrl.moveSide = 0.0f;
            break;

        case EntityState.Dead:
            if (mSensor)
            {
                mSensor.Activate(false);
            }
            break;

        case EntityState.RespawnWait:
            if (mSensor)
            {
                mSensor.Activate(false);
            }

            RevertTransform();
            break;
        }
    }
Пример #2
0
    protected override void StateChanged()
    {
        switch ((EntityState)prevState)
        {
        case EntityState.Normal:
            CancelInvoke(activeFunc);
            //CancelInvoke(fireStartFunc);
            mFiring = false;

            Blink(0);
            if (projInactiveInvul)
            {
                stats.isInvul = false;
            }
            bodySpriteCtrl.StopOverrideClip();
            break;
        }

        base.StateChanged();

        switch ((EntityState)state)
        {
        case EntityState.Normal:
            CancelInvoke(activeFunc);
            //CancelInvoke(fireStartFunc);
            mFiring = false;

            if (!mRock)
            {
                Vector3 rockPos = transform.position;
                rockPos.y += rockYOfs;
                mRock      = Projectile.Create(projGroup, rockProjType, rockPos, Vector3.zero, null);

                mRockCtrl       = mRock.GetComponent <PlatformerController>();
                mRockBlinkDelay = mRock.GetComponent <EntityBlinkDelay>();

                bodySpriteCtrl.controller = mRockCtrl;

                if (rollerDieDelayOverride)
                {
                    mRock.dieBlink = false;
                    mRock.dieDelay = 0.0f;
                }
            }

            mRockCtrl.dirHolder    = transform;
            mRockCtrl.moveSideLock = true;
            mRockCtrl.moveSide     = defaultMoveSide;

            if (mRockBlinkDelay)
            {
                mRockBlinkDelay.enabled = false;
            }

            if (mSensor)
            {
                mSensor.Activate(true);
            }

            if (!string.IsNullOrEmpty(projType))
            {
                if (mPlayers == null)
                {
                    mPlayers = GameObject.FindGameObjectsWithTag("Player");
                }

                InvokeRepeating(activeFunc, 0, projActiveCheckDelay);

                if (projInactiveInvul)
                {
                    stats.isInvul = true;
                }
                if (!string.IsNullOrEmpty(projInactiveClip))
                {
                    bodySpriteCtrl.PlayOverrideClip(projInactiveClip);
                }
            }
            //Invoke(fireStartFunc, projStartDelay);
            break;

        case EntityState.Stun:
            mRockCtrl.moveSide = 0.0f;
            break;

        case EntityState.Dead:
            if (mRock && mRock.isAlive)
            {
                if (rollerDieDelayOverride)
                {
                    if (mRockBlinkDelay)
                    {
                        mRockBlinkDelay.delay   = rollerDieDelay - rollerDieBlinkDelay;
                        mRockBlinkDelay.enabled = true;
                    }
                    else
                    {
                        mRock.dieBlink = true;
                    }

                    mRock.dieDelay = rollerDieDelay;
                }

                if (mRock.stats)
                {
                    mRock.stats.curHP = 0;
                }
                else
                {
                    mRock.state = (int)Projectile.State.Dying;
                }

                mRock = null;
            }

            if (mSensor)
            {
                mSensor.Activate(false);
            }

            bodySpriteCtrl.controller = null;
            break;

        case EntityState.RespawnWait:
            if (mRock && !mRock.isReleased)
            {
                mRock.Release();
                mRock           = null;
                mRockCtrl       = null;
                mRockBlinkDelay = null;
            }

            if (mSensor)
            {
                mSensor.Activate(false);
            }

            bodySpriteCtrl.controller = null;

            RevertTransform();
            break;
        }
    }
Пример #3
0
    void ToPhase(Phase phase)
    {
        if (mCurPhase == phase)
        {
            return;
        }

        mSensor.hFlip = bodySpriteCtrl.isLeft;
        bodySpriteCtrl.StopOverrideClip();
        Jump(0);
        shaker.enabled = false;

        //Debug.Log("phase: " + phase);

        //prev
        switch (mCurPhase)
        {
        case Phase.Crazy:
            StopCoroutine(CrazyRoutine);

            for (int i = 0; i < mCrazyProjs.Length; i++)
            {
                if (mCrazyProjs[i])
                {
                    if (mCrazyProjs[i].isAlive)
                    {
                        if (mCrazyProjs[i].stats)
                        {
                            mCrazyProjs[i].stats.curHP = 0;
                        }
                        else
                        {
                            mCrazyProjs[i].state = (int)Projectile.State.Dying;
                        }
                    }

                    mCrazyProjs[i] = null;
                }
            }

            stats.damageAmp   = 0.0f;
            mCrazyProjsActive = false;
            break;

        case Phase.Move:
            mSensor.Activate(false);
            bodyCtrl.moveSide = 0.0f;

            CancelInvoke(ChaserLaunchFunc);
            break;
        }

        switch (phase)
        {
        case Phase.Move:
            mLastMoveTime = Time.fixedTime;

            mChaserAccumCount = 0;

            animator.Play("normal");
            mCurWallJumpCount = 0;
            mSensor.Activate(true);

            if (!IsInvoking(ChaserLaunchFunc))
            {
                InvokeRepeating(ChaserLaunchFunc, 0.0f, angryChaserLaunchDelay);
            }
            break;

        case Phase.Crazy:
            StartCoroutine(CrazyRoutine);
            break;

        case Phase.Dead:
            break;
        }

        mCurPhase = phase;
    }