Example #1
0
    public void EnableSkill()
    {
        for (int i = 0; i < gbjParticle.Length; i++)
        {
            gbjParticle[i].GetComponent <ParticleSystemRenderer>().material = MaterialParticle;
        }

        GetComponent <SpriteRenderer>().sprite = SpritePlayer;

        InvokeRepeating("ExplodeSkill", 0, 0.15f);
        GetComponent <SC_PlayerShip>().StartSkill(50);
        GameObject.Find("SpawnManager").GetComponent <SC_Spawns>().SpawnRepeat(0, (0.4f / PlayerPrefs.GetFloat("Hardship")));
        GameObject.Find("bgdPurple").GetComponent <SC_Background>().IncomingVel = 2;
    }
Example #2
0
    void Update()
    {
        countScreen.SetActive(false);

        if (Input.GetKeyDown(KeyCode.A))
        {
            detected = true;
        }

        kinect = KinectManager.Instance;
        try
        {
            kinect.IsUserDetected();
            kinectPower = true;
        }
#pragma warning disable CS0168 // Variable is declared but never used
        catch (Exception e)
        {
            kinectPower = false;
        }

        if (kinectPower)
        {
            if (kinect.IsUserDetected() || detected)
            {
                warningImg.SetActive(false);
                warningAktif = false;
                if (PlayerPrefs.GetFloat("xBahuKanan") == 0)
                {
                    PlayerPrefs.SetFloat("xBahuKanan", getPosX(BahuKanan, 1));
                    PlayerPrefs.SetFloat("xBahuKiri", getPosX(BahuKiri, 1));
                }

                if (count > 0)
                {
                    guideMusic.playGuideMusic(guideMusic.go);
                    countScreen.SetActive(true);
                    countText.text = count.ToString();
                    return;
                }
                else if (count == 0)
                {
                    countScreen.SetActive(true);
                    readyText.text = "";
                    countText.text = "Go!".ToString();
                    return;
                }
                else
                {
                    countScreen.SetActive(false);
                }
            }
            else
            {
                warningImg.SetActive(true);
                warningAktif = true;
                count        = coundown;
                return;
            }

            if (kinect.IsUserDetected())
            {
                KinectController();
            }
        }

        // Time Controller
        string tempTime = string.Format("{0:00}:{1:00}", (int)(secTime / 60), (int)(secTime % 60));
        timeText.GetComponent <Text>().text = tempTime;

        // Dead Checker
        if (isDead)
        {
            return;
        }

        // Stoping Game
        if (character.transform.position.y < 0)
        {
            Death();
        }

        // Disable Control During Animation Camera
        if (Time.time - startTime < animationDuration)
        {
            //character.Move(Vector3.forward * speed * Time.deltaTime);
            count = coundown;
            return;
        }

        if (count > 0)
        {
            guideMusic.playGuideMusic(guideMusic.go);
            countScreen.SetActive(true);
            countText.text = count.ToString();
            return;
        }
        else if (count == 0)
        {
            countScreen.SetActive(true);
            readyText.text = "";
            countText.text = "Go!".ToString();
            return;
        }
        else
        {
            countScreen.SetActive(false);
        }

        // Reset Move Vector
        moveVector = Vector3.zero;

        // set Gravity
        if (character.isGrounded)
        {
            verticalVelocity = -0.5f;
        }
        else
        {
            verticalVelocity -= gravity * Time.deltaTime;
        }

        // character Jump
        int tempCountJump = GetComponent <ScoreController>().GamePlay.GetComponent <Gameplay>().countdownQuestion;
        if (character.isGrounded && (tempCountJump > 7 || tempCountJump < 4) && secTime > 1)
        {
            if (Input.GetKeyDown(KeyCode.UpArrow))
            {
                moveVector.y = jumpHeight * speed;
            }
            else
            {
                if (kinectPower)
                {
                    if (kinect.IsUserDetected())
                    {
                        if (IsJump())
                        {
                            moveVector.y = jumpHeight * speed;
                        }
                    }
                }
            }
        }

        // X - LR
        moveVector.x = 0;

        // Y - UD
        moveVector.y += verticalVelocity;

        // Z - FB
        moveVector.z = speed;

        // character is Moving by moveVector
        character.Move(moveVector * Time.deltaTime);

        // Controller left right
        if (Input.GetKeyDown(KeyCode.LeftArrow) && userPos > -1)
        {
            userPos -= 1;
        }
        else if (Input.GetKeyDown(KeyCode.RightArrow) && userPos < 1)
        {
            userPos += 1;
        }
        else
        {
            if (kinectPower)
            {
                if (kinect.IsUserDetected())
                {
                    if (IsLeft())
                    {
                        userPos = -1;
                    }
                    else if (IsRight())
                    {
                        userPos = 1;
                    }
                    else
                    {
                        userPos = 0;
                    }
                }
            }
        }

        transform.position = new Vector3(userPos * 2.0f, transform.position.y, transform.position.z);
    }
Example #3
0
 public static float getDifficulty()
 {
     return(PlayerPrefs.GetFloat(DIFFICULTY_KEY));
 }
Example #4
0
 // Use this for initialization
 void Start()
 {
     GameData.playerTopAccuracy = PlayerPrefs.GetFloat("accuracy");
     accuracy.text = GameData.playerTopAccuracy + "% trafień";
 }
Example #5
0
 public static float GetSFXVolumn()
 {
     return(PlayerPrefs.GetFloat(CONST_KEY_SFX_VOLUMN));
 }
Example #6
0
    void InitializeUIColor()
    {
        theme     = PlayerPrefs.GetString("theme");
        UIColor   = PlayerPrefs.GetString("UIColor");
        textColor = PlayerPrefs.GetString("textColor");
        pathUI    = "Sprites/" + theme + "/UI_" + UIColor + "/UI_" + UIColor;

        GameObject.Find("Background/Background").GetComponent <SpriteRenderer> ().sprite = Resources.Load <Sprite> (pathUI + "_Background01");
        // Canvas下组件的初始化
        string playerEName = PlayerPrefs.GetString("PlayerName");
        string playerCName = WWW.UnEscapeURL(playerEName);

        GameObject.Find("Canvas/SceneNameText").GetComponent <Text> ().text         = (textColor + "设置" + "</color>");
        GameObject.Find("Canvas/PlayerNameText").GetComponent <Text> ().text        = (textColor + playerCName + "</color>");
        GameObject.Find("Canvas/ChangeNameButton").GetComponent <Image> ().sprite   = Resources.Load <Sprite> (pathUI + "_ButtonRec01");
        GameObject.Find("Canvas/ChangeNameButton/Text").GetComponent <Text> ().text = (textColor + "更改" + "</color>");
        inputField = GameObject.Find("Canvas/InputField").GetComponent <InputField> ();
        if (theme == "inksnow")
        {
            inputField.GetComponent <Image> ().color          = Color.black;
            inputField.GetComponentInChildren <Text> ().color = Color.white;
            inputField.textComponent.color = Color.white;
        }
        else
        {
            inputField.GetComponent <Image> ().color          = Color.white;
            inputField.GetComponentInChildren <Text> ().color = Color.black;
            inputField.textComponent.color = Color.black;
        }
        inputField.keyboardType = TouchScreenKeyboardType.Default;
        inputField.gameObject.SetActive(false);

        GameObject.Find("Canvas/AssembleText").GetComponent <Text> ().text        = (textColor + "自动调节" + "</color>");
        GameObject.Find("Canvas/BackGroundSoundText").GetComponent <Text> ().text = (textColor + "背景音乐" + "</color>");
        GameObject.Find("Canvas/MoveSoundText").GetComponent <Text> ().text       = (textColor + "操作音效" + "</color>");

        // 单选框和滑动条的初始化
        if (theme == "starysky")
        {
            GameObject.Find("Canvas/AssembleToggle/Background").GetComponent <Image> ().color                  = Color.white;
            GameObject.Find("Canvas/AssembleToggle/Background/Checkmark").GetComponent <Image> ().color        = Color.black;
            GameObject.Find("Canvas/BackGroundSoundToggle/Background").GetComponent <Image> ().color           = Color.white;
            GameObject.Find("Canvas/BackGroundSoundToggle/Background/Checkmark").GetComponent <Image> ().color = Color.black;
            GameObject.Find("Canvas/MoveSoundToggle/Background").GetComponent <Image> ().color                 = Color.white;
            GameObject.Find("Canvas/MoveSoundToggle/Background/Checkmark").GetComponent <Image> ().color       = Color.black;

            GameObject.Find("Canvas/AssembleSlider/Background").GetComponent <Image> ().color                      = Color.gray;
            GameObject.Find("Canvas/AssembleSlider/Fill Area/Fill").GetComponent <Image> ().color                  = Color.white;
            GameObject.Find("Canvas/AssembleSlider/Handle Slide Area/Handle").GetComponent <Image> ().color        = Color.white;
            GameObject.Find("Canvas/BackGroundSoundSlider/Background").GetComponent <Image> ().color               = Color.gray;
            GameObject.Find("Canvas/BackGroundSoundSlider/Fill Area/Fill").GetComponent <Image> ().color           = Color.white;
            GameObject.Find("Canvas/BackGroundSoundSlider/Handle Slide Area/Handle").GetComponent <Image> ().color = Color.white;
            GameObject.Find("Canvas/MoveSoundSlider/Background").GetComponent <Image> ().color                     = Color.gray;
            GameObject.Find("Canvas/MoveSoundSlider/Fill Area/Fill").GetComponent <Image> ().color                 = Color.white;
            GameObject.Find("Canvas/MoveSoundSlider/Handle Slide Area/Handle").GetComponent <Image> ().color       = Color.white;
        }
        else
        {
            GameObject.Find("Canvas/AssembleToggle/Background").GetComponent <Image> ().color                  = Color.black;
            GameObject.Find("Canvas/AssembleToggle/Background/Checkmark").GetComponent <Image> ().color        = Color.white;
            GameObject.Find("Canvas/BackGroundSoundToggle/Background").GetComponent <Image> ().color           = Color.black;
            GameObject.Find("Canvas/BackGroundSoundToggle/Background/Checkmark").GetComponent <Image> ().color = Color.white;
            GameObject.Find("Canvas/MoveSoundToggle/Background").GetComponent <Image> ().color                 = Color.black;
            GameObject.Find("Canvas/MoveSoundToggle/Background/Checkmark").GetComponent <Image> ().color       = Color.white;

            GameObject.Find("Canvas/AssembleSlider/Background").GetComponent <Image> ().color                      = Color.gray;
            GameObject.Find("Canvas/AssembleSlider/Fill Area/Fill").GetComponent <Image> ().color                  = Color.black;
            GameObject.Find("Canvas/AssembleSlider/Handle Slide Area/Handle").GetComponent <Image> ().color        = Color.black;
            GameObject.Find("Canvas/BackGroundSoundSlider/Background").GetComponent <Image> ().color               = Color.gray;
            GameObject.Find("Canvas/BackGroundSoundSlider/Fill Area/Fill").GetComponent <Image> ().color           = Color.black;
            GameObject.Find("Canvas/BackGroundSoundSlider/Handle Slide Area/Handle").GetComponent <Image> ().color = Color.black;
            GameObject.Find("Canvas/MoveSoundSlider/Background").GetComponent <Image> ().color                     = Color.gray;
            GameObject.Find("Canvas/MoveSoundSlider/Fill Area/Fill").GetComponent <Image> ().color                 = Color.black;
            GameObject.Find("Canvas/MoveSoundSlider/Handle Slide Area/Handle").GetComponent <Image> ().color       = Color.black;
        }
        aToggle         = GameObject.Find("Canvas/AssembleToggle/Background/Checkmark").GetComponent <Image> ();
        bToggle         = GameObject.Find("Canvas/BackGroundSoundToggle/Background/Checkmark").GetComponent <Image> ();
        mToggle         = GameObject.Find("Canvas/MoveSoundToggle/Background/Checkmark").GetComponent <Image> ();
        aToggle.enabled = PlayerPrefs.GetInt("isAutomaticAdjustment") == 0 ? false : true;
        bToggle.enabled = PlayerPrefs.GetInt("IsPlayBackGroundSound") == 0 ? false : true;
        mToggle.enabled = PlayerPrefs.GetInt("IsPlayMoveSound") == 0 ? false : true;
        aSlider         = GameObject.Find("Canvas/AssembleSlider").GetComponent <Slider> ();
        bSlider         = GameObject.Find("Canvas/BackGroundSoundSlider").GetComponent <Slider> ();
        mSlider         = GameObject.Find("Canvas/MoveSoundSlider").GetComponent <Slider> ();
        aSlider.value   = PlayerPrefs.GetFloat("operationError");
        bSlider.value   = PlayerPrefs.GetFloat("PlayBackGroundSound");
        mSlider.value   = PlayerPrefs.GetFloat("PlayMoveSound");
        GameObject.Find("Canvas/HLine1").GetComponent <SpriteRenderer> ().sprite = Resources.Load <Sprite> (pathUI + "_Dividingline");
        GameObject.Find("Canvas/HLine2").GetComponent <SpriteRenderer> ().sprite = Resources.Load <Sprite> (pathUI + "_Dividingline");
        GameObject.Find("Canvas/SLine1").GetComponent <SpriteRenderer> ().sprite = Resources.Load <Sprite> (pathUI + "_Dividingline");
        GameObject.Find("Canvas/SLine2").GetComponent <SpriteRenderer> ().sprite = Resources.Load <Sprite> (pathUI + "_Dividingline");
        GameObject.Find("Canvas/ExitButton").GetComponent <Image> ().sprite      = Resources.Load <Sprite> (pathUI + "_ButtonExit");
        GameObject.Find("Canvas/ExitButton/Text").GetComponent <Text> ().text    = (textColor + "       退 出" + "</color>");
    }
Example #7
0
 // Use this for initialization
 void Start()
 {
     addResolutionsToDropdown();
     volumeSlider       = GameObject.Find("Slider").GetComponent <Slider>();
     volumeSlider.value = PlayerPrefs.GetFloat("currentVolume", volumeSlider.value);
 }
Example #8
0
 void Update()
 {
     music.volume = PlayerPrefs.GetFloat(IDs.musicVolume);
 }
 public override void Awake()
 {
     Strength = PlayerPrefs.GetFloat("CurrentSTRlevel"); // LOAD
     base.Awake();
 }
Example #10
0
 // Start is called before the first frame update
 void Start()
 {
     AudioController.instance.PlayWinSound();
     bestTime = PlayerPrefs.GetFloat("saveLevel1") + PlayerPrefs.GetFloat("saveLevel2") + PlayerPrefs.GetFloat("saveLevel3") + PlayerPrefs.GetFloat("saveLevel4") + PlayerPrefs.GetFloat("saveLevel5") + PlayerPrefs.GetFloat("saveLevel5_1") + PlayerPrefs.GetFloat("saveLevel4_1") + PlayerPrefs.GetFloat("saveLevel3_1");
 }
Example #11
0
    void Update()
    {
        if (hp <= 0f)
        {
            Instantiate(enemy_destroy, gameObject.transform.position, Quaternion.identity);
            PlayerPrefs.SetFloat("Game_PlayerHP", Player.hp);
            Destroy(gameObject);
        }

        if (stateCDTimer <= 0f)
        {
            stateCDTimer = stateCD;
        }

        if (stateCanChange)
        {
            stateCDTimer -= Time.deltaTime;
        }

        strafeCDTimer -= Time.deltaTime;

        if (stateCDTimer <= 0 && stateCanChange)
        {
            if (playerInRange)                      // Figuring out current state in terms of player location
            {
                if (playerCloseRange)
                {
                    current = State.closeRange;
                }
                else
                {
                    current = State.normalRange;
                }
            }
            else
            {
                current = State.farRange;
            }
        }

        if (current == State.normalRange)
        {
            Enemy_Bullet.speed  = 10f * PlayerPrefs.GetFloat("Enemy_ATK_Speed(FACTOR)");
            Enemy_Gun.fireSpeed = 0.4f * PlayerPrefs.GetFloat("Enemy_ATK_Rate(FACTOR)");
            if (strafeCDTimer <= 0f)
            {
                strafeDirection = 0;
                strafeDirection = Random.Range(-1.0f, 1.0f);
                moveVelocity    = new Vector2(strafeDirection * strafeSpd, 0f);
                strafeCDTimer   = strafeCD;
            }
        }
        else if (current == State.farRange)
        {
            farCDTimer    -= Time.deltaTime;
            stateCanChange = false;

            Enemy_Bullet.speed  = 20f * PlayerPrefs.GetFloat("Enemy_ATK_Speed(FACTOR)");
            Enemy_Gun.fireSpeed = 0.1f * PlayerPrefs.GetFloat("Enemy_ATK_Rate(FACTOR)");
            // Decrease spread
            if (strafeCDTimer <= 0f)
            {
                strafeDirection = 0;
                strafeDirection = Random.Range(-1.0f, 1.0f);
                moveVelocity    = new Vector2(strafeDirection * strafeSpd, 0f);
                strafeCDTimer   = strafeCD;
            }

            if (farCDTimer <= 0f)
            {
                current    = State.farMove;
                farCDTimer = farCD;
            }
        }
        else if (current == State.closeRange)
        {
            closeCDTimer  -= Time.deltaTime;
            stateCanChange = false;

            Enemy_Bullet.speed  = 7f * PlayerPrefs.GetFloat("Enemy_ATK_Speed(FACTOR)");
            Enemy_Gun.fireSpeed = 0.2f * PlayerPrefs.GetFloat("Enemy_ATK_Rate(FACTOR)");
            // Increase spread
            if (strafeCDTimer <= 0f)
            {
                strafeDirection = 0;
                strafeDirection = Random.Range(-1.0f, 1.0f);
                moveVelocity    = new Vector2(strafeDirection * strafeSpd, 0f);
                strafeCDTimer   = strafeCD;
            }

            if (closeCDTimer <= 0f)
            {
                current      = State.closeMove;
                closeCDTimer = closeCD;
            }
        }
        else if (current == State.closeMove)
        {
            transform.position = Vector2.MoveTowards(transform.position, playerPos.position, -retreatSpd * Time.deltaTime);
            if (strafeCDTimer <= 0f)
            {
                strafeDirection = 0;
                strafeDirection = Random.Range(-1.0f, 1.0f);
                moveVelocity    = new Vector2(strafeDirection * strafeSpd, 0f);
                strafeCDTimer   = strafeCD;
            }
            if (playerExitSpecialStatus)
            {
                playerExitSpecialStatus = false;
                stateCDTimer            = stateCD;
                stateCanChange          = true;
                current = State.normalRange;
            }
        }
        else if (current == State.farMove)
        {
            transform.position = Vector2.MoveTowards(transform.position, playerPos.position, approachSpd * Time.deltaTime);
            if (strafeCDTimer <= 0f)
            {
                strafeDirection = 0;
                strafeDirection = Random.Range(-1.0f, 1.0f);
                moveVelocity    = new Vector2(strafeDirection * strafeSpd, 0f);
                strafeCDTimer   = strafeCD;
            }
            if (playerExitSpecialStatus)
            {
                playerExitSpecialStatus = false;
                stateCDTimer            = stateCD;
                stateCanChange          = true;
                current = State.normalRange;
            }
        }


        avoidCDTimer_x -= Time.deltaTime;    // Countdown for avoiding projectile behaviour
        avoidCDTimer_y -= Time.deltaTime;
    }
 private void Start()
 {
     rigidbody          = GetComponent <Rigidbody>();
     transform.position = new Vector3(PlayerPrefs.GetFloat("PlayerXPos", -4), 0, PlayerPrefs.GetFloat("PlayerZPos", 4));
 }
Example #13
0
 private void Start()
 {
     GetComponent <Slider>().value = PlayerPrefs.GetFloat("MainVolume");
 }
    // Update is called once per frame
    void Update()
    {
        gameoverTimer += 1 * Time.deltaTime;
        colourTimer   += 1 * Time.deltaTime;

        if (colourTimer < 2)
        {
            bg = Color.Lerp(cam.backgroundColor, targetColour, colourSwitch);
            cam.backgroundColor = bg;
        }
        else
        {
            cam.backgroundColor = targetColour;
        }

        if (!gameOver)
        {
            ScoreText.text = score.ToString();

            //triangle
            if (gameChoice == 0)
            {
                if (firstGame)
                {
                    targetColour = tr;
                    tri          = Instantiate(target, new Vector3(0, 0, 0), Quaternion.identity);
                    tri.transform.localEulerAngles = new Vector3(0, 0, 40);
                    rb = Instantiate(controlTri, new Vector3(0, 0, 0), Quaternion.identity);
                    rb.transform.localEulerAngles = new Vector3(0, 0, 120);
                    firstGame = false;
                }
                else if (changingGame)
                {
                    targetColour = tr;
                    tri          = Instantiate(target, new Vector3(0, 0, 0), Quaternion.identity);
                    tri.transform.localEulerAngles = new Vector3(0, 0, 120 / rotations);
                    rb = Instantiate(controlTri, new Vector3(0, 0, 0), Quaternion.identity);
                    rb.transform.localEulerAngles = new Vector3(0, 0, (120 / rotations) * Random.Range(1, rotations + 1));
                    changingGame = false;
                }
                if (tri.transform.localScale.x < 2 && rotationCheck())
                {
                    if (closeSpeed <= 7)
                    {
                        closeSpeed += speedUpTri;
                    }

                    if (speed < 7)
                    {
                        speed += speedUpSq;
                    }

                    if (expandSpeed < 8)
                    {
                        expandSpeed += expandSpeedUp;
                    }

                    score++;

                    Destroy(tri);
                    Destroy(rb);

                    while (gameChoice == 0)
                    {
                        gameChoice = Random.Range(0, 3);
                    }
                    changingGame = true;
                    colourTimer  = 0;
                }
                else if (tri.transform.localScale.x < 1 && !gameOver)
                {
                    gameOver      = true;
                    gameoverTimer = 0;
                }
                else if ((Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began) || Input.GetKeyDown(KeyCode.Space))
                {
                    rb.transform.localEulerAngles = new Vector3(0, 0, rb.transform.rotation.eulerAngles.z + (120 / rotations));
                }

                tri.transform.localScale = new Vector3(tri.transform.localScale.x - closeSpeed * Time.deltaTime, tri.transform.localScale.y - closeSpeed * Time.deltaTime, 1);

                if (rb.transform.localEulerAngles.z > 121)
                {
                    rb.transform.localEulerAngles = new Vector3(0, 0, 120 / rotations);
                }
            }
            //square
            else if (gameChoice == 1)
            {
                if (firstGame)
                {
                    targetColour = squ;
                    square1      = Instantiate(sSquare, new Vector3(0, 4, 0), Quaternion.identity);
                    square2      = Instantiate(bSquare, new Vector3(0, -3.5f, 0), Quaternion.identity);
                    square2.GetComponent <Rigidbody2D>().velocity = new Vector3(speed, 0, 0);
                    firstGame = false;
                }
                else if (changingGame)
                {
                    targetColour = squ;
                    square1      = Instantiate(sSquare, new Vector3(0, 4, 0), Quaternion.identity);
                    square2      = Instantiate(bSquare, new Vector3(0, -3.5f, 0), Quaternion.identity);
                    square2.GetComponent <Rigidbody2D>().velocity = new Vector3(speed, 0, 0);
                    changingGame = false;
                }

                if (((Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began) || Input.GetKeyDown(KeyCode.Space)) && square1.transform.position.y >= 4)
                {
                    square1.GetComponent <Rigidbody2D>().velocity = new Vector3(0, -dropSpeed, 0);
                }

                if (square2.transform.position.x > 2.5)
                {
                    square2.GetComponent <Rigidbody2D>().velocity = new Vector3(-square2.GetComponent <Rigidbody2D>().velocity.x, 0, 0);
                    square2.transform.position = new Vector3(2.5f, -3.5f, 0);
                }

                if (square2.transform.position.x < -2.5)
                {
                    square2.GetComponent <Rigidbody2D>().velocity = new Vector3(-square2.GetComponent <Rigidbody2D>().velocity.x, 0, 0);
                    square2.transform.position = new Vector3(-2.5f, -3.5f, 0);
                }

                if (square1.transform.position.y < -10)
                {
                    gameOver       = true;
                    ScoreText.text = "GAME OVER \n" + score.ToString();
                    gameoverTimer  = 0;
                }

                if (squareCheck(square1, square2))
                {
                    if (speed < 7)
                    {
                        speed += speedUpSq;
                    }

                    if (closeSpeed <= 7)
                    {
                        closeSpeed += speedUpTri;
                    }

                    if (expandSpeed < 8)
                    {
                        expandSpeed += expandSpeedUp;
                    }

                    score++;

                    Destroy(square1);
                    Destroy(square2);

                    while (gameChoice == 1)
                    {
                        gameChoice = Random.Range(0, 3);
                    }
                    changingGame = true;
                    colourTimer  = 0;
                }
            }
            //circle
            else if (gameChoice == 2)
            {
                if (firstGame)
                {
                    targetColour = cir;
                    maxAimCircle = Instantiate(targetCircle, new Vector3(0, 0, 0), Quaternion.identity);
                    minAimCircle = Instantiate(cover, new Vector3(0, 0, 0), Quaternion.identity);
                    minAimCircle.GetComponent <Rigidbody2D>().transform.localScale = new Vector3(4, 4);
                    tMin = 4;
                    maxAimCircle.GetComponent <Rigidbody2D>().transform.localScale = new Vector3(minAimCircle.GetComponent <Rigidbody2D>().transform.localScale.x + targetSize, minAimCircle.GetComponent <Rigidbody2D>().transform.localScale.x + targetSize, 1);
                    tMax          = 4 + targetSize;
                    currentcircle = Instantiate(circle, new Vector3(0, 0, 0), Quaternion.identity);
                    circlerb      = currentcircle.GetComponent <Rigidbody2D>();
                    firstGame     = false;
                }
                else if (changingGame)
                {
                    targetColour = cir;
                    maxAimCircle = Instantiate(targetCircle, new Vector3(0, 0, 0), Quaternion.identity);
                    minAimCircle = Instantiate(cover, new Vector3(0, 0, 0), Quaternion.identity);
                    TargetGen();
                    currentcircle = Instantiate(circle, new Vector3(0, 0, 0), Quaternion.identity);
                    circlerb      = currentcircle.GetComponent <Rigidbody2D>();
                    changingGame  = false;
                }

                minAimCircle.GetComponent <SpriteRenderer>().color = cam.backgroundColor;

                if (((Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began) || Input.GetKeyDown(KeyCode.Space)) && (circlerb.transform.localScale.x > tMin && circlerb.transform.localScale.x < tMax))
                {
                    if (expandSpeed < 8)
                    {
                        expandSpeed += expandSpeedUp;
                    }

                    if (closeSpeed <= 7)
                    {
                        closeSpeed += speedUpTri;
                    }


                    if (speed < 7)
                    {
                        speed += speedUpSq;
                    }

                    score++;

                    Destroy(maxAimCircle);
                    Destroy(minAimCircle);
                    Destroy(currentcircle);

                    while (gameChoice == 2)
                    {
                        gameChoice = Random.Range(0, 3);
                    }
                    changingGame = true;
                    colourTimer  = 0;
                }
                else if (((Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began) || Input.GetKeyDown(KeyCode.Space)))
                {
                    gameOver       = true;
                    ScoreText.text = "GAME OVER \n" + score.ToString();
                    gameoverTimer  = 0;
                }

                circlerb.transform.localScale = new Vector3(circlerb.transform.localScale.x + expandSpeed * Time.deltaTime, circlerb.transform.localScale.y + expandSpeed * Time.deltaTime, 1);
            }
        }

        if (gameOver)
        {
            ScoreText.text = "G  A  M  E" + "\n" + score.ToString();
        }
        if (gameOver && (Input.GetKeyDown(KeyCode.Space) || (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began)) && gameoverTimer > 1)
        {
            if (score > PlayerPrefs.GetFloat("comboHighScore"))
            {
                PlayerPrefs.SetFloat("comboHighScore", score);
                PlayerPrefs.Save();
            }
            SceneManager.LoadScene("menu");
        }
    }
Example #15
0
    private void StartAtCheckPoint()
    {
        PlayerMovement player = FindObjectOfType <PlayerMovement>();
        NavMeshAgent   agent  = player.GetComponent <NavMeshAgent>();

        //Move the player
        agent.enabled             = false;
        player.transform.position = transform.position + new Vector3(0, 2, 0.5f);
        agent.enabled             = true;
        FindObjectOfType <PlayerMovement>().GetComponent <Keybearer>().posessedKey = PlayerPrefs.GetInt("PlayerKey");
        //Move Companion
        if (PlayerPrefs.HasKey("CompanionPresent"))
        {
            mCompanion         = GameObject.Find(PlayerPrefs.GetString("CompanionPresent")).GetComponent <CompanionAI>();
            player.myCompanion = mCompanion;
            agent         = mCompanion.GetComponent <NavMeshAgent>();
            agent.enabled = false;
            if (PlayerPrefs.HasKey("DropOffLocation"))
            {
                mCompanion.transform.position = GameObject.Find(PlayerPrefs.GetString("DropOffLocation")).transform.position + new Vector3(0, 2, -0.5f);
            }
            else if (PlayerPrefs.HasKey("CompanionX"))
            {
                mCompanion.transform.position = new Vector3(PlayerPrefs.GetFloat("CompanionX"), PlayerPrefs.GetFloat("CompanionY") + 2, PlayerPrefs.GetFloat("CompanionZ") - 0.5f);
            }
            else
            {
                mCompanion.transform.position = transform.position + new Vector3(0, 2, -0.5f);
            }

            agent.enabled = true;
        }
    }
Example #16
0
 private void Start()
 {
     mixer.SetFloat("masterVolume", PlayerPrefs.GetFloat("MasterVolume"));
     mixer.SetFloat("sfxVolume", PlayerPrefs.GetFloat("SfxVolume"));
     mixer.SetFloat("musicVolume", PlayerPrefs.GetFloat("MusicVolume"));
 }
Example #17
0
        private void Start()
        {
            var volume = PlayerPrefs.GetFloat("Volume", 1);

            OptionsMenu.SetAudioMixerVolume(audioMixer, volume);
        }
Example #18
0
    public void HighScores()
    {
        highScoresUI.SetActive(true);
        menuUI.SetActive(false);
        FindObjectOfType <AudioManager>().Play("Click");

        rushHighScore.text      = PlayerPrefs.GetString("RushName", Name) + ": " + PlayerPrefs.GetFloat("RushHighScore", 0).ToString("0");
        burstHighScore.text     = PlayerPrefs.GetString("BurstName", Name) + ": " + PlayerPrefs.GetFloat("BurstHighScore", 0).ToString("0");
        enduranceHighScore.text = PlayerPrefs.GetString("EnduranceName", Name) + ": " + PlayerPrefs.GetFloat("EnduranceHighScore", 0).ToString("0");
    }
    // Use this for initialization
    void Start()
    {
        currentplayer = PlayerPrefs.GetString("CurrentPlayer");

        //First section
        add100h  = this.gameObject.transform.GetChild(0).gameObject;
        sub100h  = this.gameObject.transform.GetChild(1).gameObject;
        mult100h = this.gameObject.transform.GetChild(2).gameObject;
        div100h  = this.gameObject.transform.GetChild(3).gameObject;

        add250e  = this.gameObject.transform.GetChild(4).gameObject;
        sub250e  = this.gameObject.transform.GetChild(5).gameObject;
        mult250e = this.gameObject.transform.GetChild(6).gameObject;
        div250e  = this.gameObject.transform.GetChild(7).gameObject;

        level2 = this.gameObject.transform.GetChild(8).gameObject;

        //Second section

        add500h  = this.gameObject.transform.GetChild(9).gameObject;
        sub500h  = this.gameObject.transform.GetChild(10).gameObject;
        mult500h = this.gameObject.transform.GetChild(11).gameObject;
        div500h  = this.gameObject.transform.GetChild(12).gameObject;

        add1000e  = this.gameObject.transform.GetChild(13).gameObject;
        sub1000e  = this.gameObject.transform.GetChild(14).gameObject;
        mult1000e = this.gameObject.transform.GetChild(15).gameObject;
        div1000e  = this.gameObject.transform.GetChild(16).gameObject;

        level3 = this.gameObject.transform.GetChild(17).gameObject;

        //Third section

        add1500h  = this.gameObject.transform.GetChild(18).gameObject;
        sub1500h  = this.gameObject.transform.GetChild(19).gameObject;
        mult1500h = this.gameObject.transform.GetChild(20).gameObject;
        div1500h  = this.gameObject.transform.GetChild(21).gameObject;

        add3000e  = this.gameObject.transform.GetChild(22).gameObject;
        sub3000e  = this.gameObject.transform.GetChild(23).gameObject;
        mult3000e = this.gameObject.transform.GetChild(24).gameObject;
        div3000e  = this.gameObject.transform.GetChild(25).gameObject;

        level4 = this.gameObject.transform.GetChild(26).gameObject;

        //Fourth section

        add2000h  = this.gameObject.transform.GetChild(27).gameObject;
        sub2000h  = this.gameObject.transform.GetChild(28).gameObject;
        mult2000h = this.gameObject.transform.GetChild(29).gameObject;
        div2000h  = this.gameObject.transform.GetChild(30).gameObject;

        add5000e  = this.gameObject.transform.GetChild(31).gameObject;
        sub5000e  = this.gameObject.transform.GetChild(32).gameObject;
        mult5000e = this.gameObject.transform.GetChild(33).gameObject;
        div5000e  = this.gameObject.transform.GetChild(34).gameObject;

        level5 = this.gameObject.transform.GetChild(35).gameObject;

        //High scores...

        addscore      = ((int)PlayerPrefs.GetFloat(currentplayer + "_Addscore"));
        subtractscore = ((int)PlayerPrefs.GetFloat(currentplayer + "_Subtractscore"));
        multiplyscore = ((int)PlayerPrefs.GetFloat(currentplayer + "_Multiplicationscore"));
        dividescore   = ((int)PlayerPrefs.GetFloat(currentplayer + "_Divisionscore"));

        //Experience Points...
        addexperience      = ((int)PlayerPrefs.GetFloat(currentplayer + "_Addexp"));
        subtractexperience = ((int)PlayerPrefs.GetFloat(currentplayer + "_Subtractexp"));
        multiplyexperience = ((int)PlayerPrefs.GetFloat(currentplayer + "_Multiplyexp"));
        divideexperience   = ((int)PlayerPrefs.GetFloat(currentplayer + "_Divideexp"));

        playerlevel = ((int)PlayerPrefs.GetFloat(currentplayer + "_PlayerLevel"));

        //Function to update the achievements

        AchieveUpdate();
    }
Example #20
0
    public void resetScores()
    {
        PlayerPrefs.DeleteAll();
        FindObjectOfType <AudioManager>().Play("Click");

        rushHighScore.text      = PlayerPrefs.GetString("RushName", Name) + ": " + PlayerPrefs.GetFloat("RushHighScore", 0).ToString("0");
        burstHighScore.text     = PlayerPrefs.GetString("BurstName", Name) + ": " + PlayerPrefs.GetFloat("BurstHighScore", 0).ToString("0");
        enduranceHighScore.text = PlayerPrefs.GetString("EnduranceName", Name) + ": " + PlayerPrefs.GetFloat("EnduranceHighScore", 0).ToString("0");
    }
Example #21
0
 protected override float GetValueFromPref()
 {
     return(PlayerPrefs.GetFloat(Key, DefaultValue));
 }
Example #22
0
 public static float GetAccountBalance()
 {
     return(PlayerPrefs.GetFloat(AccountBalanceKey, AccountBalanceDefault));
 }
Example #23
0
 public static float GetBGMVolumn()
 {
     return(PlayerPrefs.GetFloat(CONST_KEY_BGM_VOLUMN));
 }
Example #24
0
 public void ChangeMusicVolume()
 {
     clickSound.Play();
     PlayerPrefs.SetFloat(BackgroundPref, backgroundSlider.value / 10);
     backgroundMusic.volume = PlayerPrefs.GetFloat(BackgroundPref);
 }
Example #25
0
        protected override void GameSetup()
        {
            base.GameSetup();

            var sb = new System.Text.StringBuilder();

            MyDebug.DebugLevel = DebugLevel;

            sb.Append("GameManager: GameSetup()");
            sb.Append("\nApplication.systemLanguage: ").Append(Application.systemLanguage);


            // Gameplay related properties
            IsUnlocked = PlayerPrefs.GetInt("IsUnlocked", 0) != 0;
#pragma warning disable 618
            IsUserInteractionEnabled = true;
#pragma warning restore 618
            IsSplashScreenShown = false;
            TimesGamePlayed     = PlayerPrefs.GetInt("TimesGamePlayed", 0);
            TimesGamePlayed++;
            TimesLevelsPlayed          = PlayerPrefs.GetInt("TimesLevelsPlayed", 0);
            TimesPlayedForRatingPrompt = PlayerPrefs.GetInt("TimesPlayedForRatingPrompt", 0);
            TimesPlayedForRatingPrompt++;
            sb.Append("\nTimesGamePlayed: ").Append(TimesGamePlayed);
            sb.Append("\nTimesLevelsPlayed: ").Append(TimesLevelsPlayed);
            sb.Append("\nTimesPlayedForRatingPrompt: ").Append(TimesPlayedForRatingPrompt);
            sb.Append("\nApplication.PersistantDataPath: ").Append(Application.persistentDataPath);

            MyDebug.Log(sb.ToString());

            // audio related properties
            BackGroundAudioVolume = 1;              // default if nothing else is set.
            EffectAudioVolume     = 1;              // default if nothing else is set.
            var audioSources = GetComponents <AudioSource>();
            if (audioSources.Length == 0)
            {
                MyDebug.LogWarning(
                    "To make use of the Game Manager audio functions you should add 2 AudioSource components to the same gameobject as the GameManager. The first for background audio and the second for effects.");
            }
            else
            {
                if (audioSources.Length > 0)
                {
                    BackGroundAudioSource = audioSources[0];
                    BackGroundAudioVolume = BackGroundAudioSource.volume;
                }
                if (audioSources.Length > 1)
                {
                    EffectAudioSources = new AudioSource[audioSources.Length - 1];
                    Array.Copy(audioSources, 1, EffectAudioSources, 0, audioSources.Length - 1);
                    EffectAudioVolume = EffectAudioSources[0].volume;
                }
            }

            BackGroundAudioVolume = PlayerPrefs.GetFloat("BackGroundAudioVolume", BackGroundAudioVolume);
            EffectAudioVolume     = PlayerPrefs.GetFloat("EffectAudioVolume", EffectAudioVolume);


            // display related properties
            SetDisplayProperties();

            // Localisation setup. If nothing stored then use system Language if it exists. Otherwise we will default to English.
            LocaliseText.AllowedLanguages = SupportedLanguages;

            // setup players.
            Players = new Player[Instance.PlayerCount];
            for (var i = 0; i < Instance.PlayerCount; i++)
            {
                Players[i] = CreatePlayer(i);
            }
            SetPlayerByNumber(0);

            // setup worlds if auto setup
            if (AutoCreateWorlds)
            {
                Worlds = new GameItemsManager <World, GameItem>();
                if (WorldUnlockMode == GameItem.UnlockModeType.Coins)
                {
                    Worlds.LoadDefaultItems(1, NumberOfAutoCreatedWorlds, CoinsToUnlockLevels, LoadWorldDatafromResources);
                }
                else
                {
                    Worlds.LoadDefaultItems(1, NumberOfAutoCreatedWorlds, loadFromResources: LoadWorldDatafromResources);
                }
            }

            // setup levels if auto setup
            if (AutoCreateLevels)
            {
                int startLevel = AutoCreateWorlds ? WorldLevelNumbers[Worlds.Selected.Number - 1].Min : 1;
                int endLevel   = AutoCreateWorlds ? WorldLevelNumbers[Worlds.Selected.Number - 1].Max : NumberOfAutoCreatedLevels;
                Levels = new GameItemsManager <Level, GameItem>();
                if (LevelUnlockMode == GameItem.UnlockModeType.Coins)
                {
                    Levels.LoadDefaultItems(startLevel, endLevel, CoinsToUnlockLevels, LoadLevelDatafromResources);
                }
                else
                {
                    Levels.LoadDefaultItems(startLevel, endLevel, loadFromResources: LoadLevelDatafromResources);
                }
            }

            // setup levels if auto setup
            if (AutoCreateCharacters)
            {
                Characters = new GameItemsManager <Character, GameItem>();
                if (CharacterUnlockMode == GameItem.UnlockModeType.Coins)
                {
                    Characters.LoadDefaultItems(1, NumberOfAutoCreatedCharacters, CoinsToUnlockCharacters, LoadCharacterDatafromResources);
                }
                else
                {
                    Characters.LoadDefaultItems(1, NumberOfAutoCreatedCharacters, loadFromResources: LoadCharacterDatafromResources);
                }
            }

            // coroutine to check for display changes (don't need to do this every frame)
            if (!Mathf.Approximately(DisplayChangeCheckDelay, 0))
            {
                StartCoroutine(CheckForDisplayChanges());
            }

            // flag as initialised
            IsInitialised = true;
        }
Example #26
0
 public static float GetWealthValue()
 {
     wealthValue = PlayerPrefs.GetFloat("wealthValue");
     return(wealthValue);
 }
Example #27
0
 public static float GetMasterVolume()
 {
     return(PlayerPrefs.GetFloat(MASTER_VOLUME_KEY));
 }
Example #28
0
        void onWarpChatRecived(string sender, string message)
        {
            JSONNode s = JSON.Parse(message);

            switch (s[RouletteTag.TAG])
            {
            case RouletteTag.MOVE_TO_TABLE:
            {
                onMoveToTable();
                Numbers = JSON.Parse(s["PREVIOUS_NUMBER"]);
                GameID  = s["GAME_ID"];
                ManageHistoryPanels(Numbers);
            }
            break;

            case RouletteTag.START_WHEEL:
            {
                this.winingNumber = int.Parse(s[RouletteTag.VALUE]);
                GameID            = s["GAME_ID"];
            }
            break;

            case RouletteTag.NOT_ENOUGH_COIN:
            {
                string playerName = s[RouletteTag.PLAYER];
                if (playerName.Equals(GameUser.CurrentUser.ID))
                {
                    GameController.showToast("Alert! you don't have sufficient coins");
                }
            }
            break;

            case RouletteTag.START_DEAL:
            {
                this.winingNumber = -1;
            }
            break;

            case RouletteTag.BET_ADDED:
            {
                string betID = s["BET_ID"];
                addBetOnTable(betID);
            }
            break;

            case RouletteTag.REMOVE_DONE:
            {
                string playerName = s[RouletteTag.PLAYER];
                if (playerName.Equals(GameUser.CurrentUser.ID))
                {
                    // Debug.Log ("Clear Table ");
                    BetListHistory.Clear();
                    foreach (Bet b in BetList)
                    {
                        // Debug.Log ("user coins" + b.coin);

                        GameUser.CurrentUser.Coin = "" + (float.Parse(GameUser.CurrentUser.Coin) + b.coin);
                        PlayerPrefs.SetFloat(RouletteTag.TOTAL_BET, PlayerPrefs.GetInt(RouletteTag.TOTAL_BET) - b.coin);
                        Player_coin.text = "Coin:" + GameUser.CurrentUser.Coin;
                        BetListHistory.Add(b);
                    }
                    this.BetList.Clear();
                    RouletteDelegate.removeAllBet();
                    refreshTable();
                }
            }
            break;

            case RouletteTag.UNDO_DONE:
            {
                string playerName = s[RouletteTag.PLAYER];
                if (playerName.Equals(GameUser.CurrentUser.ID))
                {
                    string betID = s["BET_ID"];
                    Bet    b     = getBetbyID(betID);
                    if (b != null)
                    {
                        Destroy(b.coinSample);
                        GameUser.CurrentUser.Coin = "" + (float.Parse(GameUser.CurrentUser.Coin) + b.coin);
                        PlayerPrefs.SetFloat(RouletteTag.TOTAL_BET, PlayerPrefs.GetFloat(RouletteTag.TOTAL_BET) - b.coin);
                        Player_coin.text = "Coin:" + GameUser.CurrentUser.Coin;
                        foreach (int n in b.number)
                        {
                            if (n > 0)
                            {
                                GameObject btn = GameObject.Find("" + n);
                                Color      c   = btn.transform.GetChild(0).GetComponent <Image> ().color;
                                c.a = 0.0f;
                                btn.transform.GetChild(0).GetComponent <Image> ().color = c;
                            }
                        }
                        BetList.Remove(b);
                    }
                    refreshTable();
                }
            }
            break;

            case RouletteTag.MOVE_TO_WHEEL:
            {
                moveToWheel();
                try {
                    HistoryPanel.transform.SetSiblingIndex(0);
                    GameID = s["GAME_ID"];
                } catch (System.Exception ex) {
                }
                isTable = false;
            }
            break;

            case RouletteTag.BETTING_STOP:
            {
                // sendBetttingToServer ();
                GameID = s["GAME_ID"];
            }
            break;

            case RouletteTag.WIN_COIN:
            {
                // Debug.Log (message);
                string playerName = s[RouletteTag.PLAYER];
                if (playerName.Equals(GameUser.CurrentUser.ID))
                {
                    if (PlayerPrefs.GetInt("Sound") == 1)
                    {
                        Player.PlayOneShot(WinSound);
                    }
                    winAmount.text = "Win: " + s[RouletteTag.VALUE];
                    RouletteDelegate.winnerFound();
                }
                ServerRequest();
                // Debug.Log ("win found");
            }
            break;

            case RouletteTag.LOSS_COIN:
            {
                ServerRequest();
                // Debug.Log ("loss found");
            }
            break;

            case RouletteTag.BETTING_START:
            {
                GameID         = s["GAME_ID"];
                winAmount.text = "Win: 0";
                clearTableAfterWin();
            }
            break;

            case RouletteTag.TIME:
            {
                try {
                    Timer.text = int.Parse(s[RouletteTag.VALUE]) + ":00";
                    if (PlayerPrefs.GetInt("Sound") == 1)
                    {
                        Player.PlayOneShot(ClockSound);
                    }
                } catch (System.Exception ex) {
                    // Debug.Log (ex.Message);
                }
            }
            break;
            }
        }
Example #29
0
 public static void resetTimeAtLastCheckpoint()
 {
     startTime = Time.time - PlayerPrefs.GetFloat("timeAtLastCheckpoint") + startTime;
 }
 // Start is called before the first frame update
 void Start()
 {
     timeStart  = PlayerPrefs.GetFloat("moghtun");
     timeStart2 = PlayerPrefs.GetFloat("fie");
 }