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;
    }
    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();
    }
    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;
        }
    }
Beispiel #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);
    }
    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);
    }
Beispiel #6
0
    private void Update()
    {
        if (scaleMovement)
        {
            float dt = Time.deltaTime;
            scaleCount += dt * SCALE_SPEED;
            if (scaleCount > 360)
            {
                scaleCount -= 360;
            }

            float scale = SCR_Helper.Sin(scaleCount) * SCALE_VARIANCE * SCR_Gameplay.SCREEN_SCALE;

            gameObject.transform.localScale = new Vector3(SCR_Gameplay.SCREEN_SCALE + scale, SCR_Gameplay.SCREEN_SCALE + scale, 1);
        }
        else
        {
            gameObject.transform.localScale = new Vector3(SCR_Gameplay.SCREEN_SCALE, SCR_Gameplay.SCREEN_SCALE, 1);
        }
    }
    // ==================================================
    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;
                }
            }
        }
    }
    // Update
    private void Update()
    {
        // Don't do anything if menu state is not the first state
        if (SCR_Menu.menuLoaded == false)
        {
            return;
        }

        float dt = Time.deltaTime;

        if (Input.GetMouseButton(0))
        {
            float touchX = Input.mousePosition.x * TOUCH_SCALE;
            float touchY = Input.mousePosition.y * TOUCH_SCALE;

            if (gameState == GameState.TALKING)
            {
                gameState = GameState.GRABBING;
                player.GetComponent <SCR_Player>().GoGrabTheBoss();
            }
            else if (gameState == GameState.PUNCHING)
            {
                if (SCR_Profile.showTutorial == 0 ||
                    tutorialStep == TutorialStep.AIM ||
                    tutorialStep == TutorialStep.PUNCH ||
                    tutorialStep == TutorialStep.CONTINUE)
                {
                    player.GetComponent <SCR_Player>().Aim(touchX, touchY + cameraHeight);
                }

                if (SCR_Profile.showTutorial == 1 && tutorialStep == TutorialStep.AIM)
                {
                    tutorialCounter += dt;
                    if (tutorialCounter > TUTORIAL_HOLD_DURATION)
                    {
                        TriggerTutorial(TutorialStep.PUNCH);
                    }
                }
            }
        }
        else
        {
            if (gameState == GameState.GRABBING)
            {
                if (player.GetComponent <SCR_Player>().IsGrabbingTheBoss())
                {
                    gameState = GameState.PUNCHING;
                    player.GetComponent <SCR_Player>().ThrowTheBoss();
                }
            }
            else if (gameState == GameState.PUNCHING)
            {
                player.GetComponent <SCR_Player>().PerformPunch();
            }
            tutorialCounter = 0;
        }

        /*
         * if (Input.GetMouseButtonUp(0) && gameState == GameState.BOSS_RUNNING) {
         *      if (boss.GetComponent<SCR_Boss>().IsRunning()) {
         *              SceneManager.LoadScene("GSMenu/SCN_Menu");
         *              SCR_Audio.PlayClickSound();
         *      }
         * }
         */
        if (gameState == GameState.PUNCHING)
        {
            cameraTarget = boss.GetComponent <SCR_Boss>().y - SCREEN_H + CAMERA_OFFSET_Y;
            if (cameraTarget > cameraHeight)
            {
                float deltaCamera = (cameraTarget - cameraHeight) * dt * CAMERA_SPEED_MULTIPLIER;
                SCR_LightBar.deltaCamera = deltaCamera;

                cameraHeight += deltaCamera;

                player.GetComponent <SCR_Player>().AddDeltaCameraToPlayer(deltaCamera);
                security.GetComponent <SCR_Security>().AddDeltaCameraToSecurity(deltaCamera);

                if (flyingObject != null)
                {
                    flyingObject.GetComponent <SCR_FlyingObject>().AddDeltaCameraToObject(deltaCamera);
                }

                if (powerUp != null)
                {
                    powerUp.GetComponent <SCR_PowerUp>().AddDeltaCameraToObject(deltaCamera);
                }
            }

            if (!breakFurniture)
            {
                if (boss.GetComponent <SCR_Boss>().y > FURNITURE_Y - SCR_Boss.BOSS_SIZE)
                {
                    SCR_Background.BreakFurniture(boss.GetComponent <SCR_Boss>().x, boss.GetComponent <SCR_Boss>().y, boss.GetComponent <SCR_Boss>().speedY);
                    breakFurniture = true;
                }
            }

            if (flyingObject == null)
            {
                if (SCR_Profile.showTutorial == 0)
                {
                    objectCounter += dt;
                    if (objectCounter >= objectSpawnTime - OBJECT_DANGER_BEFORE && !dangerShowed && cameraHeight > 100000)
                    {
                        ShowDanger();
                        dangerShowed = true;
                    }

                    if (objectCounter >= objectSpawnTime)
                    {
                        objectCounter   = 0;
                        objectSpawnTime = Random.Range(OBJECT_SPAWN_TIME_MIN, OBJECT_SPAWN_TIME_MAX);

                        dangerShowed = false;

                        if (cameraHeight > 400000)
                        {
                            flyingObject = SCR_Pool.GetFreeObject(PFB_FlyingObject[2]);
                        }
                        else if (cameraHeight > 250000)
                        {
                            flyingObject = SCR_Pool.GetFreeObject(PFB_FlyingObject[1]);
                        }
                        else if (cameraHeight > 100000)
                        {
                            flyingObject = SCR_Pool.GetFreeObject(PFB_FlyingObject[0]);
                        }

                        if (flyingObject != null)
                        {
                            float x = Random.Range(-(SCREEN_W - SCR_FlyingObject.OBJECT_SIZE) * 0.5f, (SCREEN_W - SCR_FlyingObject.OBJECT_SIZE) * 0.5f);
                            float y = cameraHeight + Random.Range(1.0f, 1.5f) * SCREEN_H;
                            flyingObject.GetComponent <SCR_FlyingObject>().Spawn(x, y);
                        }
                    }
                }
            }
            else
            {
                if (flyingObject.GetComponent <SCR_FlyingObject>().broken == false)
                {
                    if (SCR_Helper.DistanceBetweenTwoPoint(flyingObject.GetComponent <SCR_FlyingObject>().x, flyingObject.GetComponent <SCR_FlyingObject>().y, boss.GetComponent <SCR_Boss>().x, boss.GetComponent <SCR_Boss>().y) < (SCR_FlyingObject.OBJECT_SIZE + SCR_Boss.BOSS_SIZE) * 0.5f)
                    {
                        float bossAngle = SCR_Helper.AngleBetweenTwoPoint(flyingObject.GetComponent <SCR_FlyingObject>().x, flyingObject.GetComponent <SCR_FlyingObject>().y, boss.GetComponent <SCR_Boss>().x, boss.GetComponent <SCR_Boss>().y);
                        boss.GetComponent <SCR_Boss>().CrashIntoObject(bossAngle);
                        flyingObject.GetComponent <SCR_FlyingObject>().Break();

                        firstDrone = false;
                    }

                    else if (SCR_Helper.DistanceBetweenTwoPoint(flyingObject.GetComponent <SCR_FlyingObject>().x, flyingObject.GetComponent <SCR_FlyingObject>().y, player.GetComponent <SCR_Player>().x, player.GetComponent <SCR_Player>().y) < (SCR_FlyingObject.OBJECT_SIZE + SCR_Player.PLAYER_SIZE) * 0.5f)
                    {
                        flyingObject.GetComponent <SCR_FlyingObject>().Break();

                        firstDrone = false;
                    }
                }
            }

            if (powerUp == null || !powerUp.activeSelf)
            {
                if (SCR_Profile.showTutorial == 0)
                {
                    powerUpCounter += dt;
                    if (powerUpCounter >= powerUpSpawnTime)
                    {
                        powerUpCounter   = 0;
                        powerUpSpawnTime = Random.Range(POWER_UP_SPAWN_TIME_MIN, POWER_UP_SPAWN_TIME_MAX);

                        int choose = Random.Range(0, (int)PowerUpType.COUNT);
                        powerUp = SCR_Pool.GetFreeObject(PFB_PowerUp[choose]);
                        powerUp.GetComponent <SCR_PowerUp>().Spawn();
                    }
                }
            }
            else
            {
                float powerUpX = powerUp.GetComponent <SCR_PowerUp>().x;
                float powerUpY = powerUp.GetComponent <SCR_PowerUp>().y;
                float bossX    = boss.GetComponent <SCR_Boss>().x;
                float bossY    = boss.GetComponent <SCR_Boss>().y;
                float playerX  = player.GetComponent <SCR_Player>().x;
                float playerY  = player.GetComponent <SCR_Player>().y;

                float bossEdibleDistance      = (SCR_PowerUp.POWER_UP_SIZE + SCR_Boss.BOSS_SIZE) * 0.5f;
                float playerEdibleDistance    = (SCR_PowerUp.POWER_UP_SIZE + SCR_Player.PLAYER_SIZE) * 0.5f;
                float bossDistanceToPowerUp   = SCR_Helper.DistanceBetweenTwoPoint(powerUpX, powerUpY, bossX, bossY);
                float playerDistanceToPowerUp = SCR_Helper.DistanceBetweenTwoPoint(powerUpX, powerUpY, playerX, playerY);

                if (firstPizza)
                {
                    for (int i = 0; i < 5; i++)
                    {
                        bossX += boss.GetComponent <SCR_Boss>().speedX *dt;
                        bossY += boss.GetComponent <SCR_Boss>().speedY *dt;
                        if (SCR_Helper.DistanceBetweenTwoPoint(powerUpX, powerUpY, bossX, bossY) <= bossEdibleDistance)
                        {
                            Time.timeScale = 0.01f;
                            firstPizza     = false;
                            break;
                        }

                        playerX += player.GetComponent <SCR_Player>().speedX *dt;
                        playerY += player.GetComponent <SCR_Player>().speedY *dt;
                        if (SCR_Helper.DistanceBetweenTwoPoint(powerUpX, powerUpY, playerX, playerY) <= playerEdibleDistance)
                        {
                            Time.timeScale = 0.01f;
                            firstPizza     = false;
                            break;
                        }
                    }
                }

                if (bossDistanceToPowerUp < bossEdibleDistance || playerDistanceToPowerUp < playerEdibleDistance)
                {
                    if (powerUp.GetComponent <SCR_PowerUp>().type == PowerUpType.PIZZA)
                    {
                        boss.GetComponent <SCR_Boss>().Enlarge();
                    }
                    else if (powerUp.GetComponent <SCR_PowerUp>().type == PowerUpType.BUBBLE)
                    {
                        boss.GetComponent <SCR_Boss>().Bubble();
                    }
                    else if (powerUp.GetComponent <SCR_PowerUp>().type == PowerUpType.MAGNET)
                    {
                        boss.GetComponent <SCR_Boss>().Magnet();
                    }

                    powerUp.SetActive(false);
                    powerUp = null;
                }
                else if (powerUpY <= cameraHeight - SCR_PowerUp.POWER_UP_SIZE)
                {
                    powerUp.SetActive(false);
                    powerUp = null;
                }
            }
        }
        else if (gameState == GameState.BOSS_FALLING)
        {
            float deltaCamera = -cameraHeight * dt * CAMERA_SPEED_MULTIPLIER;
            if (deltaCamera > -1)
            {
                deltaCamera = -1;
            }
            SCR_LightBar.deltaCamera = deltaCamera;

            cameraHeight += deltaCamera;

            player.GetComponent <SCR_Player>().TurnOffCrossHair();

            if (cameraHeight < CAMERA_ENDING_Y)
            {
                gameState = GameState.BOSS_RUNNING;
                player.GetComponent <SCR_Player>().ReAdjustY();
                boss.GetComponent <SCR_Boss>().ReAdjustY();
            }
        }
        else if (gameState == GameState.BOSS_RUNNING)
        {
            float deltaCamera = -cameraHeight * dt * CAMERA_SPEED_MULTIPLIER;
            if (deltaCamera > -1)
            {
                deltaCamera = -1;
            }
            cameraHeight += deltaCamera;
            if (cameraHeight < 0)
            {
                cameraHeight = 0;
            }
        }

        SCR_Background.SetCameraY(cameraHeight);

        if (cameraShakeTime > 0)
        {
            cameraShakeTime -= dt;
            Camera.main.transform.position = new Vector3(SCREEN_W * 0.5f + Random.Range(-CAMERA_SHAKE_AMOUNT, CAMERA_SHAKE_AMOUNT), SCREEN_H * 0.5f + cameraHeight + Random.Range(-CAMERA_SHAKE_AMOUNT, CAMERA_SHAKE_AMOUNT), Camera.main.transform.position.z);
        }
        else
        {
            Camera.main.transform.position = new Vector3(SCREEN_W * 0.5f, SCREEN_H * 0.5f + cameraHeight, Camera.main.transform.position.z);
        }

        if (comboTime > 0)
        {
            comboTime -= dt;
            if (comboTime <= 0)
            {
                comboTime  = 0;
                comboCount = 0;

                /*
                 * for (int i=1; i<imgCombo.Length; i++) {
                 *      imgCombo[i].SetActive (false);
                 * }
                 * imgCombo[0].SetActive (true);
                 */
            }
        }
        //imgClockContent.GetComponent<Image>().fillAmount = comboTime / COMBO_TIME;

        if (boss.GetComponent <SCR_Boss>().y * 0.01f - 3 > maxBossY)
        {
            maxBossY = (int)(boss.GetComponent <SCR_Boss>().y * 0.01f - 3);
            txtCurrentHeight.GetComponent <Text>().text = maxBossY.ToString();
        }

        if (SCR_Profile.showTutorial == 1)
        {
            if (tutorialStep != TutorialStep.AIM && Time.timeScale < 1)
            {
                Time.timeScale += dt * 2.0f;
                if (Time.timeScale > 1)
                {
                    Time.timeScale = 1;
                }
            }
        }
        else
        {
            if (Time.timeScale < 1)
            {
                Time.timeScale += dt * 3.0f;
                if (Time.timeScale > 1)
                {
                    Time.timeScale = 1;
                }
            }
        }

        if (flashWhiteAlpha > 0)
        {
            flashWhiteAlpha -= dt * 2.0f;
            if (flashWhiteAlpha < 0)
            {
                flashWhiteAlpha = 0;
            }

            Color color = pnlFlashWhite.GetComponent <Image>().color;
            color.a = flashWhiteAlpha;
            pnlFlashWhite.GetComponent <Image>().color = color;
        }

        if (SCR_Profile.showTutorial == 0)
        {
            if (tutorialAlpha > 0)
            {
                tutorialAlpha -= TUTORIAL_FADE_SPEED * dt;
                if (tutorialAlpha < 0)
                {
                    tutorialAlpha = 0;
                }
                Color color = txtTutorial.GetComponent <Text>().color;
                color.a = tutorialAlpha;
                txtTutorial.GetComponent <Text>().color = color;
            }
        }


        if (SCR_Profile.money - internalMoney > 1000)
        {
            internalMoney += 57;
        }
        else if (SCR_Profile.money - internalMoney > 100)
        {
            internalMoney += 13;
        }
        else if (SCR_Profile.money - internalMoney > 10)
        {
            internalMoney += 7;
        }
        else if (SCR_Profile.money - internalMoney > 0)
        {
            internalMoney += 1;
        }

        if (SCR_Profile.money - internalMoney < -1000)
        {
            internalMoney -= 57;
        }
        else if (SCR_Profile.money - internalMoney < -100)
        {
            internalMoney -= 13;
        }
        else if (SCR_Profile.money - internalMoney < -10)
        {
            internalMoney -= 7;
        }
        else if (SCR_Profile.money - internalMoney < 0)
        {
            internalMoney -= 1;
        }

        txtMoney.GetComponent <Text>().text = internalMoney.ToString();
    }
    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);
        }
    }
    // ==================================================
    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;
    }
    // ==================================================
    private void Update()
    {
        float dt = Time.deltaTime;

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

        if (state == PlayerState.TRANSFORM)
        {
            trasnformCount += dt;
            if (trasnformCount >= PLAYER_TRANSFORM_TIME)
            {
                SwitchState(PlayerState.WALK);
            }

            if (trasnformCount >= PLAYER_TEAR_TIME && trasnformCount - dt < PLAYER_TEAR_TIME)
            {
                tearParticle.transform.position = new Vector3(transform.position.x, transform.position.y, tearParticle.transform.position.z);
                foreach (Transform child in tearParticle.transform)
                {
                    child.gameObject.SetActive(true);
                }
            }
        }
        else if (state == PlayerState.WALK || state == PlayerState.GRAB)
        {
            x += direction * PLAYER_WALK_SPEED * dt;
            if (x <= -(SCR_Gameplay.SCREEN_W * 0.5f - PLAYER_REVERSE_X))
            {
                x         = -(SCR_Gameplay.SCREEN_W * 0.5f - PLAYER_REVERSE_X);
                direction = 1;
            }
            else if (x >= (SCR_Gameplay.SCREEN_W * 0.5f - PLAYER_REVERSE_X))
            {
                x         = (SCR_Gameplay.SCREEN_W * 0.5f - PLAYER_REVERSE_X);
                direction = -1;
            }

            if (state == PlayerState.WALK)
            {
                if (bossScript.IsTalking())
                {
                    if (Mathf.Abs(x - bossScript.x) < PLAYER_GRAB_RANGE)
                    {
                        bossScript.Grabbed();
                        SCR_WaitMusic.FadeOut();
                        SCR_PunchMusic.FadeIn();
                        SwitchState(PlayerState.GRAB);
                        SCR_Gameplay.instance.TriggerTutorial(TutorialStep.THROW);
                    }
                }
            }
            if (state == PlayerState.GRAB)
            {
                bossScript.x         = x + direction * PLAYER_GRAB_RANGE;
                bossScript.y         = y + PLAYER_GRAB_HEIGHT;
                bossScript.direction = -direction;
            }

            if (SCR_Gameplay.instance.gameState == GameState.BOSS_FALLING || SCR_Gameplay.instance.gameState == GameState.BOSS_RUNNING)
            {
                SwitchState(PlayerState.WATCH);
            }
        }
        else if (state == PlayerState.CHARGE)
        {
            chargeCount += dt;
            if (chargeCount >= PLAYER_CHARGE_TIME && chargeCount - dt < PLAYER_CHARGE_TIME)
            {
                bossScript.Thrown();

                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;
                shockMaterial.SetColor("_TintColor", PUNCH_PARTICLE_COLORS[0]);

                if (SCR_Profile.showTutorial == 0)
                {
                    SCR_Gameplay.instance.ShowSecurityProgress();
                }
            }
            else if (chargeCount >= PLAYER_CHARGE_TIME + PLAYER_THROW_TIME)
            {
                SwitchState(PlayerState.WATCH);
                chargeCount = 0;
            }
        }
        else if (state == PlayerState.THROW)
        {
            chargeCount += dt;
            if (chargeCount >= PLAYER_THROW_TIME)
            {
                chargeCount = 0;
                SwitchState(PlayerState.WATCH);
            }
        }
        else if (state == PlayerState.FLY_UP || state == PlayerState.PUNCH || state == PlayerState.FLY_DOWN)
        {
            if (state == PlayerState.FLY_UP)
            {
                var distance = SCR_Helper.DistanceBetweenTwoPoint(x, y, bossScript.x, bossScript.y);
                if (distance <= PLAYER_PUNCH_RANGE * bossScript.currentScale.x / bossScript.originalScale.x)
                {
                    Punch(distance);
                    SwitchState(PlayerState.PUNCH);
                    speedY = 0;
                    trail.GetComponent <SCR_Trail>().TurnParticleOff();
                }
                else if (y > SCR_Gameplay.instance.cameraHeight + SCR_Gameplay.SCREEN_H)
                {
                    SwitchState(PlayerState.FLY_DOWN);
                    speedY = 0;
                    trail.GetComponent <SCR_Trail>().TurnParticleOff();
                }
            }
            else if (state == PlayerState.PUNCH)
            {
                speedY -= SCR_Gameplay.GRAVITY * dt;
                target.SetActive(false);
                punchCount -= dt;
                if (punchCount < 0)
                {
                    punchCount = 0;
                    SwitchState(PlayerState.FLY_DOWN);
                }
            }
            else if (state == PlayerState.FLY_DOWN)
            {
                speedY -= SCR_Gameplay.GRAVITY * dt;
                target.SetActive(false);
            }

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

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

            if (state == PlayerState.FLY_UP)
            {
                trail.GetComponent <SCR_Trail>().MoveTo(x, y);
            }
            else if (state == PlayerState.FLY_DOWN)
            {
                if (y <= SCR_Gameplay.instance.cameraHeight - PLAYER_SIZE || y <= PLAYER_START_Y)
                {
                    y = PLAYER_START_Y;
                    SwitchState(PlayerState.LAND);

                    landCount = 0;
                    landParticle.SetActive(true);
                    landParticle.transform.position = new Vector3(SCR_Gameplay.SCREEN_W * 0.5f + x, y + PLAYER_SMOKE_OFFSET_Y, landParticle.transform.position.z);
                }
            }
        }
        else if (state == PlayerState.LAND)
        {
            landCount += dt;
            if (landCount >= PLAYER_LAND_TIME)
            {
                SwitchState(PlayerState.WATCH);
            }
        }
        else if (state == PlayerState.WATCH)
        {
            if (bossScript.x < x)
            {
                direction = -1;
            }
            else
            {
                direction = 1;
            }
        }

        if (y <= SCR_Gameplay.instance.cameraHeight - PLAYER_SIZE)
        {
            marker.SetActive(true);
            marker.transform.position = new Vector3(SCR_Gameplay.SCREEN_W * 0.5f + x, SCR_Gameplay.instance.cameraHeight, landParticle.transform.position.z);
        }
        else
        {
            marker.SetActive(false);
        }

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

        float shadowScale = 1 - (y - PLAYER_START_Y) / PLAYER_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 * PLAYER_SHADOW_SCALE * shadowScale, SCR_Gameplay.SCREEN_SCALE * PLAYER_SHADOW_SCALE * shadowScale, 1);
    }
Beispiel #12
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);
    }
 // Use this for initialization
 void Start()
 {
     TorchController = SCR_Helper.FindParentWithTag(this.gameObject, "TorchController").GetComponent <SCR_TorchController>();
 }