public static int GetInt(string key) { return(PlayerPrefs.GetInt(key)); }
IEnumerator playNarration() { yield return new WaitForSeconds(1.0f); if (PlayerPrefs.GetInt("voice") == 0) narration.Play(); }
// Update is called once per frame void Update() { gameObject.GetComponent<Text>().text = "Vidas: " + PlayerPrefs.GetInt("Vidas", 0); }
// Use this for initialization void Start() { #if UNITY_IOS iCadeInput.Activate(true); //Register some callbacks iCadeInput.AddICadeEventCallback(iCadeStateCallback); iCadeInput.AddICadeButtonUpCallback(iCadeButtonUpCallback); iCadeInput.AddICadeButtonDownCallback(iCadeButtonDownCallback); #endif playing = false; GameObject moveBackground = GameObject.Find("MoveBackground"); //GameObject helpBackground = GameObject.Find("HelpBackground"); switch(PlayerPrefs.GetInt("fontSizeIndex")) { case 0: moveBackground.transform.localScale = new Vector2(1.0f, 1.0f); //helpBackground.transform.localScale = new Vector2(1.0f, 1.0f); //help.GetComponent<RectTransform>().sizeDelta = new Vector2(200.0f, 145); //showMoves.GetComponent<RectTransform>().sizeDelta = new Vector2(375, 145); break; case 1: moveBackground.transform.localScale = new Vector2(1.0f, 1.2f); //helpBackground.transform.localScale = new Vector2(1.3f, 1.2f); //help.GetComponent<RectTransform>().sizeDelta = new Vector2(250.0f, 190); //showMoves.GetComponent<RectTransform>().sizeDelta = new Vector2(375, 190); break; case 2: moveBackground.transform.localScale = new Vector2(1.0f, 1.5f); //helpBackground.transform.localScale = new Vector2(1.5f, 1.5f); //help.GetComponent<RectTransform>().sizeDelta = new Vector2(300.0f, 210); //showMoves.GetComponent<RectTransform>().sizeDelta = new Vector2(375, 210); break; } showMoves.fontSize = (int)(25 * PlayerPrefs.GetFloat("printSize")) + 20;//25;// PlayerPrefs.GetInt("fontSize"); help.fontSize = (int)(27 * PlayerPrefs.GetFloat("printSize")) + 23;//25;// PlayerPrefs.GetInt("fontSize")-5; loopState = false; loopsFromSlider = 2; howManyTimesToLoop.text = "Times To Loop : " + loopsFromSlider; countLoops = 0; saveStartLocation = -1; countTillLineSkip = 0; growthSwitch = true; shrinkSwitch = true; stepCount = 0; scanCount = 0; turned = false; facingRight = true; spinOrRoll = false; jumpSwitch = true; jumpReset = false; startFormat = "<b><color=#00ff00ff>"; endFormat = "</color></b>"; movementLengthCollection = 0; backwardCount = 0; buttonCount = 0; if (PlayerPrefs.GetInt("Scan") == 1 && !MiniGame.tutorialMode) { StartCoroutine(scanner()); } if (PlayerPrefs.GetInt("voice") == 0) { narration.Play(); } directionalLight = GameObject.FindObjectOfType<Light>(); //GameStatusEventHandler.gameWasStarted("challenge"); if (MiniGame.tutorialMode) StartCoroutine(buttonFlash()); }
// Update is called once per frame void Update() { if(loopCounts.Count > 0) { Debug.Log("Loop Count: " + loopCounts.Count); foreach (int loopCount in loopCounts) { Debug.Log("Values of loop counts: " + loopCount); } if (loopsFromSlider != loopCounts[loopCounts.Count - 1]) loopCounts[loopCounts.Count - 1] = (int) loopsFromSlider; } if (Input.GetKeyDown("1") == true) { key1Press = true; objectApp = true; } if (Input.GetKeyDown("2") == true) { key2Press = true; objectApp = true; } if (Input.GetKeyDown("3") == true) { key3Press = true; objectApp = true; } if (Input.GetKeyDown("space") == true) { keyspacePress = true; objectApp = true; } if (e != null) { if (e.keyCode.ToString() == "10" && e.type == EventType.keyDown) { keyenterPress = true; objectApp = true; } } //Debug.Log(tutorialCount); if (key1Press || key2Press || key3Press || keyspacePress || keyenterPress || objectApp) //Input.anyKeyDown) { //if (Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1) || Input.GetMouseButtonDown(2)) return; if (winCanvas.active) { nextLevel(); } else if (tryAgainCanvas.active) { clearList(); } else if ((PlayerPrefs.GetInt("Scan") == 1 || MiniGame.tutorialMode) && !playing) { checkScanPosition(); } key1Press = false; key2Press = false; key3Press = false; keyspacePress = false; keyenterPress = false; objectApp = false; } if (move.text.Contains("Forward")) { if (facingRight) { if (player.transform.position.x < 6.7) { player.transform.position = Vector3.MoveTowards(player.transform.position, new Vector3(player.transform.position.x + 2, player.transform.position.y, 0), Time.deltaTime * 1); } } else { if (player.transform.position.x > -7.4) { player.transform.position = Vector3.MoveTowards(player.transform.position, new Vector3(player.transform.position.x - 2, player.transform.position.y, 0), Time.deltaTime * 1); } } } if (move.text.Contains("Backward")) { if (facingRight) { if (player.transform.position.x > -7.4) { player.transform.position = Vector3.MoveTowards(player.transform.position, new Vector3(player.transform.position.x - 2, player.transform.position.y, 0), Time.deltaTime * 1); } } else { if (player.transform.position.x < 6.7) { player.transform.position = Vector3.MoveTowards(player.transform.position, new Vector3(player.transform.position.x + 2, player.transform.position.y, 0), Time.deltaTime * 1); } } } if (move.text.Contains("Spin")) { spinOrRoll = true; player.transform.Rotate(0, Time.deltaTime * 370, 0); } if (move.text.Contains("Grow") && growthSwitch) { if (player.transform.localScale.x < 3) { player.transform.localScale = new Vector3(player.transform.localScale.x + .5f, player.transform.localScale.y + .5f, player.transform.localScale.z + .5f); } growthSwitch = false; } if (move.text.Contains("Shrink") && shrinkSwitch) { if (player.transform.localScale.x > .5f) { player.transform.localScale = new Vector3(player.transform.localScale.x - .5f, player.transform.localScale.y - .5f, player.transform.localScale.z - .5f); } shrinkSwitch = false; } if (move.text.Contains("Jump")) { if (jumpSwitch) { player.transform.position = Vector3.MoveTowards(player.transform.position, new Vector3(player.transform.position.x, player.transform.position.y + 2, 0), Time.deltaTime * 4); } else { player.transform.position = Vector3.MoveTowards(player.transform.position, new Vector3(player.transform.position.x, player.transform.position.y - 2, 0), Time.deltaTime * 4); } } if (move.text.Contains("Turn")) { turned = true; player.transform.Rotate(0, Time.deltaTime * 180, 0); } if (SceneManager.GetSceneByName("LoadingScreen").isLoaded) directionalLight.gameObject.SetActive(false); }
private void CheckPlayerPrefs() { musicPlayer.mute = PlayerPrefs.GetInt(global.Music) != 1; }
// Use this for initialization void Start() { ReadFile("tiedosto"); puhekupla1.interactable = false; puhekupla2.interactable = false; puhekupla3.interactable = false; puhekupla4.interactable = false; // puhekupla5.interactable = false; nearMemoryGame = false; Frame = 0; BobPlayerAnimator = GetComponent <Animator>(); startDestinationX = PlayerPrefs.GetInt("Bobin paikka X"); startDestinationY = PlayerPrefs.GetInt("Bobin paikka Y"); Debug.Log(startDestinationX + " " + startDestinationY); StandingButtonNumberX = PlayerPrefs.GetInt("Bobin paikka X"); StandingButtonNumberY = PlayerPrefs.GetInt("Bobin paikka Y"); GameObject startButton = GameObject.Find("Tile" + startDestinationX + startDestinationY); if (startButton == null) { startButton = GameObject.Find("Tile" + 0 + 1); Debug.Log("Ei löytynyt"); } aboveButtonScale(); gameObject.transform.position = destination; Vector2 kierto; kierto.x = startButton.transform.position.x; kierto.y = startButton.transform.position.y; gameObject.transform.position = kierto; Debug.Log("gameObject" + gameObject.transform.position + "startButton" + startButton.transform.position); memoryGame = GameObject.Find("memoryGame"); //Kohde johon kävellään // map = GameObject.Find("tilemap_parent").GetComponent<map_manager>(); BobPlayer = GameObject.Find("BobPlayer"); // BobPlayer.transform.position = new Vector3(BobPlayer.transform.position.x, BobPlayer.transform.position.y, BobPlayer.transform.position.z); destination = gameObject.transform.position; BobOnButton(); Rakennus1 = GameObject.Find("memoryGame").GetComponent <Collider2D>(); //Viitataan luotuun tagiin //StandingButtonNumber = 0; Debug.Log("StandingButtonNumber = " + StandingButtonNumberX); Debug.Log("StandingButtonNumber2 = " + StandingButtonNumberY); //Button1 = GameObject.Find("Tile").GetComponent<Button>(); //Button2 = GameObject.Find("Tile (1)").GetComponent<Button>(); //Button1 = GameObject.Find("Tile (2)").GetComponent<Button>(); //Button1 = GameObject.Find("Tile (3)").GetComponent<Button>(); // Invoke("Movement", 2); // Instanciate the PathMap object: }
public void OnTriggerEnter2D(Collider2D collision) { // Ending the game when player touches obstacle. Possible only if shield and boost powerups are disabled. if (collision.gameObject.CompareTag("Player") && playerPow.isProtected == false && playerCon.isBoosted == false && isBroken == false && playerCon.isShooted == false) { audioSource.PlayOneShot(clip); Destroy(particles); playerCon.isShooted = true; mainCam.isShaking = true; sprite.enabled = false; playerCon.animator.enabled = false; bc.enabled = false; player.transform.position = new Vector2(player.transform.position.x - 2, player.transform.position.y); // moving player left a little bit,to avoid second collision,just in case collision would not work. Instantiate(particlehit, gameObject.transform.position, Quaternion.identity); if (gM.deathsCounter == 0) // this happens if player dies for the first time. Player have an ability to revive himself. { if (playerCon.distance > PlayerPrefs.GetFloat("Highscore") - 301 && playerCon.distance < PlayerPrefs.GetFloat("Highscore")) { gM.endScore.text = " Only " + (PlayerPrefs.GetFloat("Highscore") - playerCon.distance) + "m left to a new Highscore! "; gM.endScore.gameObject.SetActive(true); } else { gM.endScore.text = "Keep it up !"; gM.endScore.gameObject.SetActive(true); } gM.totalCoins = PlayerPrefs.GetInt("TotalCoins", 0); gM.reviveText.text = " Revive \n300"; gM.lastLive = true; StartCoroutine("reviveQuestion"); } else if (gM.deathsCounter == 1) // after player dies second time, this happens. { gM.deathsCounter++; playerCon.speed /= 10; gM.restartButton.gameObject.SetActive(true); gM.blackScreen.gameObject.SetActive(true); gM.endScore.gameObject.SetActive(true); gM.coinImage.gameObject.SetActive(false); gM.scoreText.gameObject.SetActive(false); gM.coinsText.gameObject.SetActive(false); gM.pauseButton.gameObject.SetActive(false); if (playerCon.distance < PlayerPrefs.GetFloat("Highscore")) { gM.endScore.text = "You rode " + playerCon.distance + "m!"; } else if (playerCon.distance > PlayerPrefs.GetFloat("Highscore")) { gM.endScore.text = "New Highscore! " + playerCon.distance; } playerCon.isAlive = false; playerCon.enabled = false; playerCon.particleSparks.enableEmission = false; playerCon.rb.gravityScale = 1; } } //this happens if player with turbo collides with obstacle else if (collision.gameObject.CompareTag("Player") && playerPow.isProtected == false && playerCon.isBoosted == true && isBroken == false) { sprite.enabled = false; bc.enabled = false; audioSource.PlayOneShot(clip); Instantiate(smallHit, gameObject.transform.position, Quaternion.identity); Destroy(particles); Destroy(gameObject, 2f); } // if shield powerup enabled and player touches obstacle, shield disapears. Only possible if player does not have boost power up. else if ((collision.gameObject.CompareTag("Player") && playerPow.isProtected == true && playerCon.isBoosted == false && isBroken == false)) { mainCam.isShaking = true; bc.enabled = false; playerPow.isProtected = false; sprite.enabled = false; audioSource.PlayOneShot(shieldDestroy); Instantiate(breakingShield, gameObject.transform.position, Quaternion.identity); Instantiate(smallHit, gameObject.transform.position, Quaternion.identity); Destroy(gameObject, 2f); } // this happens after player collides with broken particle,during wall event. if (collision.gameObject.CompareTag("Player") && isBroken == true) { mainCam.isShaking = true; sprite.enabled = false; Instantiate(brokenParticle, gameObject.transform.position, Quaternion.identity); audioSource.PlayOneShot(clip, 0.5f); Destroy(gameObject, 3); } // if obstacle collides with an exclamation point, obstacle it destroyed. It has to be done, to make visibility on the line with an exclamation. { if (collision.gameObject.tag == ("rocket") && isSingle == true) { Destroy(gameObject); } } }
void LoadData() { oldPlayer = GameObject.FindWithTag("Player"); if (oldPlayer) { Destroy(gameObject); } else { lastPosition.x = PlayerPrefs.GetFloat("PlayerX"); lastPosition.y = PlayerPrefs.GetFloat("PlayerY"); lastPosition.z = PlayerPrefs.GetFloat("PlayerZ"); GameObject respawn = Instantiate(player, lastPosition, transform.rotation) as GameObject; respawn.GetComponent <StatusC>().level = PlayerPrefs.GetInt("PlayerLevel"); respawn.GetComponent <StatusC>().atk = PlayerPrefs.GetInt("PlayerATK"); respawn.GetComponent <StatusC>().def = PlayerPrefs.GetInt("PlayerDEF"); respawn.GetComponent <StatusC>().matk = PlayerPrefs.GetInt("PlayerMATK"); respawn.GetComponent <StatusC>().mdef = PlayerPrefs.GetInt("PlayerMDEF"); respawn.GetComponent <StatusC>().mdef = PlayerPrefs.GetInt("PlayerMDEF"); respawn.GetComponent <StatusC>().exp = PlayerPrefs.GetInt("PlayerEXP"); respawn.GetComponent <StatusC>().maxExp = PlayerPrefs.GetInt("PlayerMaxEXP"); respawn.GetComponent <StatusC>().maxHealth = PlayerPrefs.GetInt("PlayerMaxHP"); //respawn.GetComponent<StatusC>().health = PlayerPrefs.GetInt("PlayerHP"); respawn.GetComponent <StatusC>().health = PlayerPrefs.GetInt("PlayerMaxHP"); respawn.GetComponent <StatusC>().maxMana = PlayerPrefs.GetInt("PlayerMaxMP"); respawn.GetComponent <StatusC>().mana = PlayerPrefs.GetInt("PlayerMaxMP"); respawn.GetComponent <StatusC>().statusPoint = PlayerPrefs.GetInt("PlayerSTP"); mainCam = GameObject.FindWithTag("MainCamera").transform; mainCam.GetComponent <ARPGcameraC>().target = respawn.transform; //------------------------------- respawn.GetComponent <InventoryC>().cash = PlayerPrefs.GetInt("Cash"); int itemSize = player.GetComponent <InventoryC>().itemSlot.Length; int a = 0; if (itemSize > 0) { while (a < itemSize) { respawn.GetComponent <InventoryC>().itemSlot[a] = PlayerPrefs.GetInt("Item" + a.ToString()); respawn.GetComponent <InventoryC>().itemQuantity[a] = PlayerPrefs.GetInt("ItemQty" + a.ToString()); //------- a++; } } int equipSize = player.GetComponent <InventoryC>().equipment.Length; a = 0; if (equipSize > 0) { while (a < equipSize) { respawn.GetComponent <InventoryC>().equipment[a] = PlayerPrefs.GetInt("Equipm" + a.ToString()); a++; } } respawn.GetComponent <InventoryC>().weaponEquip = 0; respawn.GetComponent <InventoryC>().armorEquip = PlayerPrefs.GetInt("ArmoEquip"); if (PlayerPrefs.GetInt("WeaEquip") == 0) { respawn.GetComponent <InventoryC>().RemoveWeaponMesh(); } else { respawn.GetComponent <InventoryC>().EquipItem(PlayerPrefs.GetInt("WeaEquip"), respawn.GetComponent <InventoryC>().equipment.Length + 5); } //---------------------------------- Screen.lockCursor = true; //--------------Set Target to Monster--------------- GameObject[] mon; mon = GameObject.FindGameObjectsWithTag("Enemy"); foreach (GameObject mo in mon) { if (mo) { mo.GetComponent <AIsetC>().followTarget = respawn.transform; } } //---------------Set Target to Minimap-------------- GameObject minimap = GameObject.FindWithTag("Minimap"); if (minimap) { GameObject mapcam = minimap.GetComponent <MinimapOnOffC>().minimapCam; mapcam.GetComponent <MinimapCameraC>().target = respawn.transform; } //Load Quest respawn.GetComponent <QuestStatC>().questProgress = new int[PlayerPrefs.GetInt("QuestSize")]; int questSize = respawn.GetComponent <QuestStatC>().questProgress.Length; a = 0; if (questSize > 0) { while (a < questSize) { respawn.GetComponent <QuestStatC>().questProgress[a] = PlayerPrefs.GetInt("Questp" + a.ToString()); a++; } } respawn.GetComponent <QuestStatC>().questSlot = new int[PlayerPrefs.GetInt("QuestSlotSize")]; int questSlotSize = respawn.GetComponent <QuestStatC>().questSlot.Length; a = 0; if (questSlotSize > 0) { while (a < questSlotSize) { respawn.GetComponent <QuestStatC>().questSlot[a] = PlayerPrefs.GetInt("Questslot" + a.ToString()); a++; } } //Load Skill Slot a = 0; while (a <= 2) { respawn.GetComponent <SkillWindowC>().skill[a] = PlayerPrefs.GetInt("Skill" + a.ToString()); a++; } respawn.GetComponent <SkillWindowC>().AssignAllSkill(); Destroy(gameObject); } }
void SetupMainMenu() { GameObject.Find("Play").GetComponent <Button>().onClick.AddListener(DidTapMainMenuPlay); GameObject.Find("Play specific minigames").GetComponent <Button>().onClick.AddListener(DidTapMainMenuPlaySpecificMinigames); GameObject.Find("High score text").GetComponent <TextMeshProUGUI>().text = "High score: " + PlayerPrefs.GetInt("HighScore", 0); }
public void GetHealthVal() { health = PlayerPrefs.GetInt("Health", 3); }
void Start() { //PlayerPrefs.SetInt("leveldone",40); pannelname = gameObject.name; pannel = string.Concat(pannelname[5], pannelname[6]); pannelint = int.Parse(pannel); //levelcheck = (PlayerPrefs.GetInt("leveldone") + 1); levelcheck = AudioManager.instance.leveldone + 1; if(levelcheck / 8 >= pannelint) { for(int i=0; i< 8; i++) { string star; star =(((pannelint - 1) * 8) + i+1).ToString("0"); // Debug.Log(PlayerPrefs.GetInt(star)); this.transform.GetChild(i).gameObject.GetComponent<Button>().interactable = true; this.transform.GetChild(i).gameObject.transform.GetChild(0).gameObject.SetActive(true); //Debug.Log(levelbutton[i].name); if(PlayerPrefs.GetInt(star) == 3) { this.transform.GetChild(i).gameObject.transform.GetChild(1).gameObject.SetActive(true); this.transform.GetChild(i).gameObject.transform.GetChild(4).gameObject.SetActive(true); this.transform.GetChild(i).gameObject.transform.GetChild(5).gameObject.SetActive(true); } if(PlayerPrefs.GetInt(star) == 2) { this.transform.GetChild(i).gameObject.transform.GetChild(2).gameObject.SetActive(true); this.transform.GetChild(i).gameObject.transform.GetChild(3).gameObject.SetActive(true); } if(PlayerPrefs.GetInt(star) == 1) { this.transform.GetChild(i).gameObject.transform.GetChild(1).gameObject.SetActive(true); } } } else if( levelcheck > 8 * (pannelint -1) && levelcheck < 8 * pannelint ) { level = levelcheck % 8; if (level == 0) level = 8; //GameObject.Find("1 (9)").GetComponent<Button>().interactable = true; //PlayerPrefs.SetInt("1",3); //PlayerPrefs.SetInt("2",2); //PlayerPrefs.SetInt("3",3); //Debug.Log("1 " + PlayerPrefs.GetInt("1")); //Debug.Log("2 " + PlayerPrefs.GetInt("2")); //sDebug.Log("3 " + PlayerPrefs.GetInt("3")); //Debug.Log(level ); //levelbutton[0].GetComponent<Button>().interactable = true; for(int i=0; i< level; i++) { string star; star =(((pannelint - 1) * 8) + i+1).ToString("0"); // Debug.Log(PlayerPrefs.GetInt(star)); this.transform.GetChild(i).gameObject.GetComponent<Button>().interactable = true; this.transform.GetChild(i).gameObject.transform.GetChild(0).gameObject.SetActive(true); //Debug.Log(levelbutton[i].name); if(PlayerPrefs.GetInt(star) == 3) { this.transform.GetChild(i).gameObject.transform.GetChild(1).gameObject.SetActive(true); this.transform.GetChild(i).gameObject.transform.GetChild(4).gameObject.SetActive(true); this.transform.GetChild(i).gameObject.transform.GetChild(5).gameObject.SetActive(true); } if(PlayerPrefs.GetInt(star) == 2) { this.transform.GetChild(i).gameObject.transform.GetChild(2).gameObject.SetActive(true); this.transform.GetChild(i).gameObject.transform.GetChild(3).gameObject.SetActive(true); } if(PlayerPrefs.GetInt(star) == 1) { this.transform.GetChild(i).gameObject.transform.GetChild(1).gameObject.SetActive(true); } } } }