Esempio n. 1
0
    private void Start()
    {
        // Set up game's stuff
        Application.targetFrameRate = 60;
        Screen.orientation          = ScreenOrientation.Portrait;
        //Screen.SetResolution(540, 960, false);

        // Load profile
        SCR_Profile.Init();
        SCR_Profile.LoadProfile();

        bossSelecting = SCR_Profile.bossSelecting;

        RefreshSoundButtonStatus();
        UpdateMoneyNumber();
        UpdateBoss();

        dgbBoss[0].GetComponentInChildren <MeshRenderer>().sharedMaterial.SetFloat("_FlashAmount", 0);

        // Music
        SCR_WaitMusic.FadeIn();
        SCR_PunchMusic.FadeOut();
        SCR_RunSound.Stop();

        // OK, confirm that menu is now the first state
        menuLoaded = true;

        // Skip right into gameplay for tutorial

        /*
         * if (SCR_Profile.showTutorial == 1) {
         *      SceneManager.LoadScene("GSGameplay/SCN_Gameplay");
         * }
         */
    }
Esempio n. 2
0
 private void Update()
 {
     if (!musicPlayed && SCR_WaitMusic.ready && SCR_PunchMusic.ready)
     {
         musicPlayed = true;
         SCR_WaitMusic.Play();
         SCR_PunchMusic.Play();
     }
 }
Esempio n. 3
0
 public void RefreshSoundStatus()
 {
     if (SCR_Profile.soundOn == 1)
     {
         if (musicPlayed == true)
         {
             SCR_WaitMusic.Play();
             SCR_PunchMusic.Play();
         }
     }
     else
     {
         if (musicPlayed == true)
         {
             SCR_WaitMusic.Stop();
             SCR_PunchMusic.Stop();
         }
     }
 }
Esempio n. 4
0
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
            source   = GetComponent <AudioSource>();
            DontDestroyOnLoad(gameObject);

            if (SCR_Audio.LOAD_FROM_FILE == true)
            {
                instance.StartCoroutine(LoadFromFile());
            }
            else
            {
                ready = true;
            }
        }
        else
        {
            Destroy(gameObject);
        }
    }
    public void Lose()
    {
        iTween.Stop(imgSecurityProgressFG.gameObject);
        imgSecurityProgressFG.GetComponent <SCR_SecurityProgress>().UpdateFlashAmount(0);

        imgSecurityProgressBG.gameObject.SetActive(false);
        imgSecurityProgressFG.gameObject.SetActive(false);

        pnlResult.SetActive(true);
        btnReplay.SetActive(true);
        btnMainMenu.SetActive(true);

        //txtResultTitle.text = boss.GetComponent<SCR_Boss>().resultTitle[SCR_Profile.bossSelecting];
        //txtResultTitle.fontSize = boss.GetComponent<SCR_Boss>().resultTitleFontSize[SCR_Profile.bossSelecting];

        const int FONT_MIN   = 80;
        const int FONT_MAX   = 155;
        const int LENGTH_MIN = 8;
        const int LENGTH_MAX = 16;

        txtResultTitle.text = SCR_Profile.bosses[SCR_Profile.bossSelecting].name;
        int l = txtResultTitle.text.Length;

        if (l < LENGTH_MIN)
        {
            l = LENGTH_MIN;
        }
        if (l > LENGTH_MAX)
        {
            l = LENGTH_MAX;
        }
        float r = 1 - (float)(l - LENGTH_MIN) / (LENGTH_MAX - LENGTH_MIN);

        txtResultTitle.fontSize = (int)(FONT_MIN + (FONT_MAX - FONT_MIN) * r);

        SCR_WaitMusic.FadeIn();
        SCR_PunchMusic.FadeOut();

        if (maxBossY > SCR_Profile.highScore)
        {
            imgHighScore.SetActive(true);
        }
        else
        {
            imgHighScore.SetActive(false);
        }

        SCR_Profile.ReportScore(maxBossY);
        txtPunchNumber.GetComponent <Text>().text  = maxCombo.ToString();
        txtHeightNumber.GetComponent <Text>().text = maxBossY.ToString();
        txtBestNumber.GetComponent <Text>().text   = SCR_Profile.highScore.ToString();

        int money = (int)(maxBossY * 0.5);

        AddMoney(money);

        txtMoneyNumber.GetComponent <Text>().text = "$" + totalReward.ToString();

        imgSecurityProgressBG.color = new Color(1, 1, 1, 0);
        imgSecurityProgressFG.color = new Color(1, 1, 1, 0);

        // -- //
        bool found = false;

        for (int i = 0; i < SCR_Profile.bosses.Length; i++)
        {
            if (SCR_Profile.bosses[i].unlocked == 0 && SCR_Profile.money >= SCR_Profile.bosses[i].cost)
            {
                if (SCR_Profile.bosses[i].recommended == 0)
                {
                    shouldSelect = i;
                    found        = true;
                    break;
                }
            }
        }

        if (found)
        {
            imgNotice.SetActive(true);
        }
        // -- //

        SCR_UnityAnalytics.FinishGame(maxBossY);
    }
    // ==================================================
    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);
    }