コード例 #1
0
    public void CrashIntoObject(float angle)
    {
        float changeX = BOSS_CRASH_BONUS * SCR_Helper.Sin(angle);
        float changeY = BOSS_CRASH_BONUS * SCR_Helper.Cos(angle);

        if (changeY < 0)
        {
            changeY *= 0.5f;
        }

        speedX += changeX;
        speedY += changeY;

        float handicap = BOSS_MIN_HANDICAP + (y / BOSS_HANDICAP_HEIGHT) * (1 - BOSS_MIN_HANDICAP);

        if (handicap > 1)
        {
            handicap = 1;
        }
        if (speedX > handicap * BOSS_MAX_SPEED_X)
        {
            speedX = handicap * BOSS_MAX_SPEED_X;
        }
        else if (speedX < -handicap * BOSS_MAX_SPEED_X)
        {
            speedX = -handicap * BOSS_MAX_SPEED_X;
        }

        Time.timeScale = 0.1f;
    }
コード例 #2
0
    public override void Break()
    {
        base.Break();

        angle = Random.Range(30, 60);
        if (Random.Range(0, 10) > 5)
        {
            angle = -angle;
        }
        speedX = SCR_Helper.Sin(angle) * BROKEN_SPEED;
        speedY = SCR_Helper.Cos(angle) * BROKEN_SPEED;

        smokeParticle.SetActive(true);
        transform.localEulerAngles = new Vector3(0, 0, angle);

        breakParticle.transform.position = new Vector3(SCR_Gameplay.SCREEN_W * 0.5f + x, y, breakParticle.transform.position.z);
        foreach (Transform child in breakParticle.transform)
        {
            child.gameObject.SetActive(true);
        }

        if (SCR_Profile.soundOn == 1)
        {
            GetComponent <AudioSource>().Stop();
        }
        SCR_Audio.PlayObjectHitSound();
        SCR_Audio.PlayUFOCollisionSound();
    }
コード例 #3
0
    public void Aim(float px, float py)
    {
        if (state == PlayerState.WATCH || state == PlayerState.LAND)
        {
            target.SetActive(true);
            target.GetComponent <SCR_Target>().SetPosition(px - SCR_Gameplay.SCREEN_W * 0.5f, py);

            float x1, x2, y1, y2;
            x1 = x;
            y1 = SCR_Gameplay.instance.cameraHeight - PLAYER_SIZE;
            if (y1 < PLAYER_START_Y)
            {
                y1 = PLAYER_START_Y;
            }

            float aimAngle = SCR_Helper.AngleBetweenTwoPoint(x1, y1, px - SCR_Gameplay.SCREEN_W * 0.5f, py);
            x2 = x1 + SCR_Gameplay.SCREEN_H * SCR_Helper.Sin(aimAngle) * 2;
            y2 = y1 + SCR_Gameplay.SCREEN_H * SCR_Helper.Cos(aimAngle) * 2;

            target.GetComponent <SCR_Target>().SetLine(x1, y1, x2, y2);

            currentAimX = px;
            currentAimY = py;
        }
    }
コード例 #4
0
    private void Punch()
    {
        //SCR_Audio.PlayPunchNormalSound();
        SCR_Audio.PlayPunchDirectSound();

        float punchAngle = SCR_Helper.AngleBetweenTwoPoint(x, y, bossScript.x, bossScript.y);
        float punchX     = SECURITY_FORCE * SCR_Helper.Sin(punchAngle);
        float punchY     = SECURITY_FORCE * (1 + SCR_Helper.Cos(punchAngle) * 0.33f);

        float particleX = (x + bossScript.x) * 0.5f;
        float particleY = (y + bossScript.y) * 0.5f;

        punchParticle.transform.position = new Vector3(SCR_Gameplay.SCREEN_W * 0.5f + particleX, particleY, punchParticle.transform.position.z);
        foreach (Transform child in punchParticle.transform)
        {
            child.gameObject.SetActive(true);
        }

        bossScript.Punch(punchX, Mathf.Abs(punchY), true);
        SCR_Gameplay.instance.SecurityPunchSuccess(bossScript.x + SCR_Gameplay.SCREEN_W * 0.5f, bossScript.y - SCR_Gameplay.instance.cameraHeight);

        //SCR_Gameplay.instance.AddMoneyAtPosition(SECURITY_MONEY, x + SCR_Gameplay.SCREEN_W * 0.5f, y - SCR_Gameplay.instance.cameraHeight);

        SCR_Gameplay.instance.AddMoneyAtPosition(
            SCR_Player.PUNCH_MONEY_START + SCR_Player.PUNCH_MONEY_STEP * (SCR_Gameplay.instance.comboCount - 1),
            x + SCR_Gameplay.SCREEN_W * 0.5f,
            y - SCR_Gameplay.instance.cameraHeight);
    }
コード例 #5
0
    public void AddDeltaCameraToPlayer(float amount)
    {
        if (state == PlayerState.FLY_UP)
        {
            y += amount * 0.7f;

            targetY += amount;

            if (y < targetY - PLAYER_PUNCH_RANGE && ricocheted == false)
            {
                flyAngle = SCR_Helper.AngleBetweenTwoPoint(x, y, targetX, targetY);
                speedX   = PLAYER_FLY_SPEED * SCR_Helper.Sin(flyAngle);
                speedY   = PLAYER_FLY_SPEED * SCR_Helper.Cos(flyAngle);
            }
        }

        punchParticle.transform.position = new Vector3(punchParticle.transform.position.x, punchParticle.transform.position.y + amount, punchParticle.transform.position.z);
    }
コード例 #6
0
    // ==================================================
    private void Update()
    {
        float dt = Time.deltaTime;

        if (SCR_Gameplay.instance.gameState == GameState.BOSS_FALLING)
        {
            dt = 0;
        }

        if (state >= BossState.FLY_1 && state <= BossState.FLY_6)
        {
            if (SCR_Profile.showTutorial == 1)
            {
                if (SCR_Gameplay.instance.tutorialStep == TutorialStep.AIM)
                {
                    predictY         = y - (SCR_Gameplay.GRAVITY * BOSS_TUTORIAL_DELTA * BOSS_TUTORIAL_DELTA) * 0.5f;
                    tutorialCounter += dt * 100;
                    tutorialFinger.transform.localPosition = new Vector3(SCR_Gameplay.SCREEN_W * 0.5f + SCR_Helper.Sin(tutorialCounter) * SCR_Gameplay.SCREEN_W * 0.3f, predictY, tutorialTarget.transform.localPosition.z);
                    tutorialFinger.SetActive(true);
                    tutorialFinger.GetComponent <SCR_TutorialFinger>().Stop();
                }
                else if (SCR_Gameplay.instance.tutorialStep == TutorialStep.PUNCH)
                {
                    predictX = x + speedX * BOSS_TUTORIAL_DELTA;
                    predictY = y - (SCR_Gameplay.GRAVITY * BOSS_TUTORIAL_DELTA * BOSS_TUTORIAL_DELTA) * 0.5f;
                    tutorialTarget.transform.localPosition = new Vector3(SCR_Gameplay.SCREEN_W * 0.5f + predictX, predictY, tutorialTarget.transform.localPosition.z);
                    tutorialTarget.SetActive(true);
                    //tutorialFinger.transform.localPosition = new Vector3 (SCR_Gameplay.SCREEN_W * 0.5f + predictX, predictY, tutorialTarget.transform.localPosition.z);
                    tutorialFinger.SetActive(false);
                    //tutorialFinger.GetComponent<SCR_TutorialFinger>().Animate();

                    if (!tutorialRange)
                    {
                        tutorialRange = Instantiate(PFB_TutorialRange);
                        tutorialRange.transform.localScale = new Vector3(SCR_Gameplay.SCREEN_SCALE * 3, SCR_Gameplay.SCREEN_SCALE * 3, 1);
                        tutorialRange.transform.position   = new Vector3(SCR_Gameplay.SCREEN_W * 0.5f + SCR_Gameplay.instance.player.GetComponent <SCR_Player>().x, SCR_Gameplay.instance.cameraHeight - SCR_Player.PLAYER_SIZE, tutorialRange.transform.position.z);
                        float angle = SCR_Helper.AngleBetweenTwoPoint(SCR_Gameplay.instance.player.GetComponent <SCR_Player>().x, SCR_Gameplay.instance.cameraHeight - SCR_Player.PLAYER_SIZE, predictX, predictY);
                        tutorialRange.transform.localEulerAngles = new Vector3(0, 0, -angle);
                    }
                }
            }
            if (SCR_Gameplay.instance.tutorialStep != TutorialStep.AIM && SCR_Gameplay.instance.tutorialStep != TutorialStep.PUNCH)
            {
                float oldSpeedY = speedY;

                if (bubbleTime > 0)
                {
                    speedY -= SCR_Gameplay.GRAVITY * dt * (speedY / 10000);
                }
                else
                {
                    speedY -= SCR_Gameplay.GRAVITY * dt;
                }

                if (speedY < 0 && oldSpeedY >= 0 && SCR_Gameplay.instance.tutorialStep == TutorialStep.THROW)
                {
                    SCR_Gameplay.instance.TriggerTutorial(TutorialStep.AIM);
                }

                if (speedY > maxSpeedY)
                {
                    speedY = maxSpeedY;
                }
                y += speedY * dt;

                //if (speedY > maxSpeedY)	y += maxSpeedY * dt;
                //else                  y += speedY * dt;



                if (magnetTime > 0)
                {
                    if (SCR_Gameplay.instance.player.GetComponent <SCR_Player>().IsFlyingUp())
                    {
                        float flyAngle = SCR_Helper.AngleBetweenTwoPoint(x, y, SCR_Gameplay.instance.player.GetComponent <SCR_Player>().x, SCR_Gameplay.instance.player.GetComponent <SCR_Player>().y);
                        float attractX = BOSS_MAGNET_FORCE * SCR_Helper.Sin(flyAngle);
                        float attractY = BOSS_MAGNET_FORCE * SCR_Helper.Cos(flyAngle);                          // we don't need this actually
                        x += attractX * dt;
                    }
                }

                x += speedX * dt;



                if (x <= -(SCR_Gameplay.SCREEN_W * 0.5f - BOSS_REVERSE_X))
                {
                    x = -(SCR_Gameplay.SCREEN_W * 0.5f - BOSS_REVERSE_X);
                    if (bubbleTime > 0)
                    {
                        speedX = -speedX * 0.7f;
                    }
                    else
                    {
                        speedX = -speedX;
                    }
                    RandomRotate();
                    SCR_Audio.PlayBounceSound();
                }
                else if (x >= (SCR_Gameplay.SCREEN_W * 0.5f - BOSS_REVERSE_X))
                {
                    x = (SCR_Gameplay.SCREEN_W * 0.5f - BOSS_REVERSE_X);
                    if (bubbleTime > 0)
                    {
                        speedX = -speedX * 0.7f;
                    }
                    else
                    {
                        speedX = -speedX;
                    }
                    RandomRotate();
                    SCR_Audio.PlayBounceSound();
                }

                if (y <= SCR_Gameplay.instance.cameraHeight - BOSS_SIZE)
                {
                    SwitchState(BossState.FALL);
                    SCR_Gameplay.instance.gameState = GameState.BOSS_FALLING;
                    SCR_Gameplay.instance.Lose();

                    if (size == BossSize.BIG)
                    {
                        Shrink();
                    }

                    SCR_Audio.PlayFallSound();
                }

                rotation += rotateSpeed * dt;

                float r = currentScale.x / originalScale.x;
                atmosBurn.SetActive(true);
                atmosBurn.transform.localPosition = new Vector3(
                    SCR_Gameplay.SCREEN_W * 0.5f + x + BOSS_BURN_OFFSET_X * r,
                    y + BOSS_BURN_OFFSET_Y * r,
                    atmosBurn.transform.localPosition.z);

                float alpha = (speedY - BOSS_BURN_SPEED_MIN) / (BOSS_BURN_SPEED_MAX - BOSS_BURN_SPEED_MIN);
                if (alpha > BOSS_BURN_ALPHA)
                {
                    alpha = BOSS_BURN_ALPHA;
                }
                Color color = atmosBurn.GetComponent <SpriteRenderer>().color;
                color.a = alpha;
                atmosBurn.GetComponent <SpriteRenderer>().color = color;

                if (alpha > 0)
                {
                    SCR_Gameplay.instance.ShakeCamera(0.016f);
                }
            }
        }
        else if (state == BossState.FALL)
        {
            speedY -= SCR_Gameplay.GRAVITY * dt;

            x += speedX * dt;
            y += speedY * dt;

            if (x <= -(SCR_Gameplay.SCREEN_W * 0.5f - BOSS_REVERSE_X))
            {
                x      = -(SCR_Gameplay.SCREEN_W * 0.5f - BOSS_REVERSE_X);
                speedX = -speedX;
            }
            else if (x >= (SCR_Gameplay.SCREEN_W * 0.5f - BOSS_REVERSE_X))
            {
                x      = (SCR_Gameplay.SCREEN_W * 0.5f - BOSS_REVERSE_X);
                speedX = -speedX;
            }

            if (y <= BOSS_START_Y)
            {
                y = BOSS_START_Y;
                SwitchState(BossState.SLIDE);
                SCR_Audio.PlayPunchNormalSound();

                smokeParticle.transform.position = new Vector3(SCR_Gameplay.SCREEN_W * 0.5f + x + BOSS_SMOKE_OFFSET_X * direction, y + BOSS_SMOKE_OFFSET_Y, smokeParticle.transform.position.z);

                landParticle.SetActive(true);
                landParticle.transform.position = new Vector3(SCR_Gameplay.SCREEN_W * 0.5f + x, y + BOSS_SMOKE_OFFSET_Y, landParticle.transform.position.z);
            }

            rotation = 0;
        }
        else if (state == BossState.SLIDE)
        {
            if (speedX > 0)
            {
                speedX   -= BOSS_SLIDE_FRICTION * dt;
                direction = 1;
                if (speedX < 0)
                {
                    speedX = 0;
                    SwitchState(BossState.RUN);
                    SCR_RunSound.Play();
                }
            }
            else
            {
                speedX   += BOSS_SLIDE_FRICTION * dt;
                direction = -1;
                if (speedX > 0)
                {
                    speedX = 0;
                    SwitchState(BossState.RUN);
                    SCR_RunSound.Play();
                }
            }

            smokeParticle.transform.position = new Vector3(SCR_Gameplay.SCREEN_W * 0.5f + x + BOSS_SMOKE_OFFSET_X * direction, y + BOSS_SMOKE_OFFSET_Y, smokeParticle.transform.position.z);
            ParticleSystem.EmissionModule emission = smokeParticle.GetComponent <ParticleSystem>().emission;
            emission.rateOverTime = Mathf.Abs(speedX) * BOSS_SMOKE_RATE;

            x += speedX * dt;

            if (x <= -(SCR_Gameplay.SCREEN_W * 0.5f - BOSS_REVERSE_X))
            {
                x         = -(SCR_Gameplay.SCREEN_W * 0.5f - BOSS_REVERSE_X);
                direction = 1;
                speedX    = -speedX;
            }
            else if (x >= (SCR_Gameplay.SCREEN_W * 0.5f - BOSS_REVERSE_X))
            {
                x         = (SCR_Gameplay.SCREEN_W * 0.5f - BOSS_REVERSE_X);
                direction = -1;
                speedX    = -speedX;
            }

            rotation = 0;
        }
        else if (state == BossState.RUN)
        {
            x       += direction * BOSS_RUN_SPEED * dt;
            rotation = 0;

            if (x <= -(SCR_Gameplay.SCREEN_W * 0.5f - BOSS_REVERSE_X))
            {
                SCR_RunSound.Fade();
            }
            else if (x >= (SCR_Gameplay.SCREEN_W * 0.5f - BOSS_REVERSE_X))
            {
                SCR_RunSound.Fade();
            }
        }

        transform.position         = new Vector3(SCR_Gameplay.SCREEN_W * 0.5f + x, y, transform.position.z);
        transform.localScale       = new Vector3(currentScale.x * (-direction), currentScale.y, currentScale.z);
        transform.localEulerAngles = new Vector3(0, 0, rotation);

        bossName.transform.localPosition = new Vector3(
            SCR_Gameplay.SCREEN_W * 0.5f + x,
            y + BOSS_NAME_OFFSET_Y * currentScale.x / originalScale.x,
            bossName.transform.localPosition.z);


        float shadowScale = 1 - (y - BOSS_START_Y) / BOSS_SHADOW_DISTANCE;

        if (shadowScale < 0)
        {
            shadowScale = 0;
        }
        shadow.transform.position   = new Vector3(SCR_Gameplay.SCREEN_W * 0.5f + x, shadow.transform.position.y, shadow.transform.position.z);
        shadow.transform.localScale = new Vector3(SCR_Gameplay.SCREEN_SCALE * BOSS_SCALE * shadowScale, SCR_Gameplay.SCREEN_SCALE * BOSS_SCALE * shadowScale, SCR_Gameplay.SCREEN_SCALE * BOSS_SCALE);

        for (int i = 0; i < 6; i++)
        {
            moneyParticle[i].transform.position = new Vector3(SCR_Gameplay.SCREEN_W * 0.5f + x, y, moneyParticle[i].transform.position.z);
        }

        moneyBagParticle.transform.position = moneyParticle[0].transform.position;

        if (enlargeTime > 0)
        {
            enlargeTime -= dt;
            if (enlargeTime <= 0)
            {
                Shrink();
                enlargeTime = 0;
            }
            else if (enlargeTime < BOSS_FLASH_DURATION * 0.8f)
            {
                Flash();
            }
        }

        if (bubbleTime > 0)
        {
            bubbleTime -= dt;
            if (bubbleTime < BOSS_FLASH_DURATION * 0.8f)
            {
                Flash();
            }
        }
        else
        {
            bubble.GetComponent <SCR_Bubble>().FadeOut();
        }

        if (magnetTime > 0)
        {
            magnetTime -= dt;
            if (magnetTime < BOSS_FLASH_DURATION * 0.8f)
            {
                Flash();
            }
        }
        else
        {
            attract.GetComponent <SCR_Attract>().FadeOut();
        }



        if (state == BossState.TALK)
        {
            if (talkCounter < BOSS_TALK_START)
            {
                talkCounter += dt;
                if (talkCounter >= BOSS_TALK_START)
                {
                    SCR_Audio.PlayTalkSound();
                    dialogueID++;
                    if (dialogueID >= dialogue.Length)
                    {
                        dialogueID = 0;
                    }
                    talkBubble.transform.GetChild(0).GetChild(0).gameObject.GetComponent <Text>().text = dialogue[dialogueID];
                    talkBubble.SetActive(true);
                }
            }
            else
            {
                talkCounter += dt;
                if (talkCounter >= BOSS_TALK_END)
                {
                    talkBubble.SetActive(false);
                    talkCounter = 0;
                }
            }
        }
    }
コード例 #7
0
    public void PerformPunch()
    {
        if (target.activeSelf)
        {
            targetX = currentAimX - SCR_Gameplay.SCREEN_W * 0.5f;
            targetY = currentAimY;

            if (SCR_Profile.showTutorial == 1)
            {
                SCR_Gameplay.instance.ShowSecurityProgress();
                if (SCR_Gameplay.instance.tutorialStep == TutorialStep.AIM)
                {
                    target.SetActive(false);
                    return;
                }
                if (SCR_Gameplay.instance.tutorialStep == TutorialStep.PUNCH)
                {
                    if (SCR_Helper.DistanceBetweenTwoPoint(targetX, targetY, bossScript.predictX, bossScript.predictY) > PLAYER_TUTORIAL_RANGE)
                    {
                        target.SetActive(false);
                        //return;
                    }
                }
            }


            y = SCR_Gameplay.instance.cameraHeight - PLAYER_SIZE;
            if (y < PLAYER_START_Y)
            {
                y = PLAYER_START_Y;
            }

            if (targetX >= x)
            {
                direction = 1;
            }
            else
            {
                direction = -1;
            }

            flyAngle = SCR_Helper.AngleBetweenTwoPoint(x, y, targetX, targetY);
            speedX   = PLAYER_FLY_SPEED * SCR_Helper.Sin(flyAngle);
            speedY   = PLAYER_FLY_SPEED * SCR_Helper.Cos(flyAngle);

            trail.GetComponent <SCR_Trail>().JumpTo(x, y);
            trail.GetComponent <SCR_Trail>().TurnParticleOn();

            target.SetActive(false);

            SwitchState(PlayerState.FLY_UP);
            SCR_Audio.PlayFlyUpSound();

            ricocheted = false;

            if (SCR_Profile.showTutorial == 1)
            {
                SCR_Gameplay.instance.TriggerTutorial(TutorialStep.FLY_UP);
                bossScript.HideTutorial();
            }
        }
        else
        {
            target.SetActive(false);
        }
    }
コード例 #8
0
    // ==================================================
    private void Punch(float distance)
    {
        float punchAngle = SCR_Helper.AngleBetweenTwoPoint(x, y, bossScript.x, bossScript.y);
        float punchX     = PLAYER_PUNCH_FORCE * SCR_Helper.Sin(punchAngle);
        float punchY     = PLAYER_PUNCH_FORCE * (1 + SCR_Helper.Cos(punchAngle) * 0.33f);

        float particleX = (x + bossScript.x) * 0.5f;
        float particleY = (y + bossScript.y) * 0.5f;

        punchParticle.transform.position = new Vector3(SCR_Gameplay.SCREEN_W * 0.5f + particleX, particleY, punchParticle.transform.position.z);
        foreach (Transform child in punchParticle.transform)
        {
            child.gameObject.SetActive(true);
        }
        Material shockMaterial = punchParticle.transform.Find("Shock").GetComponent <Renderer>().sharedMaterial;
        int      index         = SCR_Gameplay.instance.comboCount;

        if (index < 0)
        {
            index = 0;
        }
        if (index > PUNCH_PARTICLE_COLORS.Length - 1)
        {
            index = PUNCH_PARTICLE_COLORS.Length - 1;
        }
        shockMaterial.SetColor("_TintColor", PUNCH_PARTICLE_COLORS[index]);

        bossScript.Punch(punchX, Mathf.Abs(punchY), false);
        if (ricocheted == true)
        {
            bossScript.ShowMoneyBag();
            SCR_Gameplay.instance.ShowRicochet(bossScript.x + SCR_Gameplay.SCREEN_W * 0.5f, bossScript.y - SCR_Gameplay.instance.cameraHeight);
            SCR_Audio.PlayPunchRicochetSound();

            int money = RICOCHET_MONEY;

            if (bossScript.size == BossSize.BIG)
            {
                money *= PUNCH_MONEY_BIG_MULTIPLIER;
            }

            SCR_Gameplay.instance.AddMoneyAtPosition(money, bossScript.x + SCR_Gameplay.SCREEN_W * 0.5f, bossScript.y - SCR_Gameplay.instance.cameraHeight);
        }
        else
        {
            SCR_Audio.PlayPunchNormalSound();

            int money = PUNCH_MONEY_START + PUNCH_MONEY_STEP * SCR_Gameplay.instance.comboCount;

            if (bossScript.size == BossSize.BIG)
            {
                money *= PUNCH_MONEY_BIG_MULTIPLIER;
            }

            SCR_Gameplay.instance.AddMoneyAtPosition(
                money,
                bossScript.x + SCR_Gameplay.SCREEN_W * 0.5f,
                bossScript.y - SCR_Gameplay.instance.cameraHeight);
        }

        SCR_Gameplay.instance.PunchSuccess(bossScript.x + SCR_Gameplay.SCREEN_W * 0.5f, bossScript.y - SCR_Gameplay.instance.cameraHeight);

        punchCount = PLAYER_PUNCH_TIME;
    }
コード例 #9
0
    // ==================================================
    private void Update()
    {
        float dt = Time.deltaTime;

        if (state == SecurityState.STAND)
        {
        }
        else if (state == SecurityState.CHEER)
        {
        }
        else if (state == SecurityState.FLY_UP)
        {
            float flyAngle = SCR_Helper.AngleBetweenTwoPoint(x, y, bossScript.x, bossScript.y);
            speedX = SECURITY_SPEED * SCR_Helper.Sin(flyAngle);
            speedY = SECURITY_SPEED * SCR_Helper.Cos(flyAngle);

            var distance = SCR_Helper.DistanceBetweenTwoPoint(x, y, bossScript.x, bossScript.y);
            if (distance <= SECURITY_RANGE * bossScript.currentScale.x / bossScript.originalScale.x)
            {
                speedY = 0;
                trail.GetComponent <SCR_Trail>().TurnParticleOff();
                Punch();
                SwitchState(SecurityState.FLY_DOWN);
            }

            if (laughDelay > 0)
            {
                laughDelay -= dt;
                if (laughDelay <= 0)
                {
                    SCR_Audio.PlaySecurityLaughSound();
                }
            }
        }
        else if (state == SecurityState.FLY_DOWN)
        {
            SwitchState(SecurityState.FLY_DOWN);
            speedY -= SCR_Gameplay.GRAVITY * dt;
        }

        x += speedX * dt;
        y += speedY * dt;

        if (state == SecurityState.FLY_UP)
        {
            trail.GetComponent <SCR_Trail>().MoveTo(x, y);
        }
        else if (state == SecurityState.FLY_DOWN)
        {
            if (speedX < 0 && x <= -(SCR_Gameplay.SCREEN_W * 0.5f - SECURITY_SIZE * 0.5f))
            {
                x      = -(SCR_Gameplay.SCREEN_W * 0.5f - SECURITY_SIZE * 0.5f);
                speedX = -speedX;
            }
            else if (speedX > 0 && x >= (SCR_Gameplay.SCREEN_W * 0.5f - SECURITY_SIZE * 0.5f))
            {
                x      = (SCR_Gameplay.SCREEN_W * 0.5f - SECURITY_SIZE * 0.5f);
                speedX = -speedX;
            }
            if (y <= SCR_Gameplay.instance.cameraHeight - SECURITY_SIZE || y <= SECURITY_START_Y)
            {
                y      = SECURITY_START_Y;
                speedX = 0;
                speedY = 0;
                SwitchState(SecurityState.STAND);

                landParticle.SetActive(true);
                landParticle.transform.position = new Vector3(SCR_Gameplay.SCREEN_W * 0.5f + x, y + SECURITY_SMOKE_OFFSET_Y, landParticle.transform.position.z);
            }
        }

        transform.position   = new Vector3(SCR_Gameplay.SCREEN_W * 0.5f + x, y, transform.position.z);
        transform.localScale = new Vector3(SCR_Gameplay.SCREEN_SCALE * SECURITY_SCALE * direction, SCR_Gameplay.SCREEN_SCALE * SECURITY_SCALE, SCR_Gameplay.SCREEN_SCALE * SECURITY_SCALE);

        float shadowScale = 1 - (y - SECURITY_START_Y) / SECURITY_SHADOW_DISTANCE;

        if (shadowScale < 0)
        {
            shadowScale = 0;
        }
        shadow.transform.position   = new Vector3(SCR_Gameplay.SCREEN_W * 0.5f + x, shadow.transform.position.y, shadow.transform.position.z);
        shadow.transform.localScale = new Vector3(SCR_Gameplay.SCREEN_SCALE * SECURITY_SCALE * shadowScale * (-direction), SCR_Gameplay.SCREEN_SCALE * SECURITY_SCALE * shadowScale, SCR_Gameplay.SCREEN_SCALE * SECURITY_SCALE);
    }