// void OnTriggerEnter2D(Collider2D obj) // { // if (obj.name.Equals("Ship")) // { // if (levelCompleteScreen.activeInHierarchy == false) // { // Pause (); // } // } // } private void Pause() { playerObj.GetComponent <Timer>().enabled = false; timeLeftText.text = timer.GetTimeString(); originalPrestige = ship.GetCurrentPrestige(); prestigeText.text = System.Convert.ToString(ship.GetCurrentPrestige()); int bonusPrestige = System.Convert.ToInt32(timer.GetTimeLeft()) * 3; finalPrestige = originalPrestige + bonusPrestige; ship.SetCurrentPrestige(finalPrestige); timeLeft = timer.GetTimeLeft(); startTime = Time.time; levelCompleteScreen.SetActive(true); storeSelected = continueButton; ES.SetSelectedGameObject(storeSelected); Time.timeScale = 0; Debug.Log("calling level complete"); }
// Update is called once per frame void Update() { if (GameObject.Find("Dragon") == null) { GameObject.Find("Ship").transform.Find("Camera").GetComponent <Camera>().orthographicSize = 5; ShipActions ship = playerObj.GetComponent <ShipActions> (); Timer timeClass = playerObj.GetComponent <Timer> (); PlayerPrefs.SetInt(Constants.HULLCURRVALUE, ship.hullcurrent); PlayerPrefs.SetInt(Constants.DYNAMITECURRCOOLDOWN, 0); PlayerPrefs.SetInt(Constants.PRESTIGEEARN, ship.GetCurrentPrestige()); PlayerPrefs.SetFloat(Constants.TIMELEFT, timeClass.GetTimeLeft()); PlayerPrefs.SetInt(Constants.CURRCREWSAVED, ship.crewsaved); //Debug.Log ("ReturnParentLevelTrigger is "+PlayerPrefs.GetInt (Constants.CURRCREWSAVED,0)); SceneManager.LoadScene("Level 1"); } }
void OnTriggerEnter2D(Collider2D other) { ShipActions ship = playerObj.GetComponent <ShipActions> (); //Debug.Log ("EnemyDragonFightTrigger bf PlayerPrefs.GetInt(Constants.DEFEATDRAGON,0)="+PlayerPrefs.GetInt(Constants.DEFEATDRAGON,0)); if (other.name.StartsWith("Ship") && PlayerPrefs.GetInt(Constants.DEFEATDRAGON, 0) == 0) { camera = GameObject.Find("Ship").transform.Find("Camera").GetComponent <Camera>(); camera.orthographicSize = 8; Timer timeClass = playerObj.GetComponent <Timer> (); PlayerPrefs.SetInt(Constants.HULLCURRVALUE, ship.hullcurrent); PlayerPrefs.SetInt(Constants.DYNAMITECURRCOOLDOWN, 0); PlayerPrefs.SetInt(Constants.PRESTIGEEARN, ship.GetCurrentPrestige()); PlayerPrefs.SetFloat(Constants.TIMELEFT, timeClass.GetTimeLeft()); PlayerPrefs.SetInt(Constants.CURRCREWSAVED, ship.crewsaved); PlayerPrefs.SetInt(Constants.DEFEATDRAGON, 1); //Debug.Log ("EnemyDragonFightTrigger af PlayerPrefs.GetInt(Constants.DEFEATDRAGON,0)="+PlayerPrefs.GetInt(Constants.DEFEATDRAGON,0)); enabled = false; SceneManager.LoadScene("DragonFight"); } }
// Update is called once per frame void Update() { if (upgradeScreen.gameObject.activeInHierarchy == true) { if (PlayerPrefs.GetInt(Constants.ISLAND, 0) == islandNo) { if (ES.currentSelectedGameObject != storeSelected) { if (ES.currentSelectedGameObject == null) { ES.SetSelectedGameObject(storeSelected); } else { storeSelected = ES.currentSelectedGameObject; } } int currentPrestige = ship.GetCurrentPrestige(); prestigeLeftText.text = System.Convert.ToString(currentPrestige); crewText.text = ship.crewsaved + "/" + ship.crewtosave; searchButton.GetComponent <Button> ().interactable = true; if (currCrewSaveOnIsland >= totalNoOfCrewOnIsland) //reach max no of crew on island { searchButton.GetComponent <Button> ().interactable = false; } Debug.Log("Current state " + currentState); if (currentState == MenuStates.Main) { mainIsland.SetActive(true); searchIsland.SetActive(false); upgradeMenu.SetActive(false); triggeredBackToIsland = false; } else if (currentState == MenuStates.Shop) { mainIsland.SetActive(false); searchIsland.SetActive(false); upgradeMenu.SetActive(true); triggeredBackToIsland = false; DisablePurchaseButton(); } else if (currentState == MenuStates.Search) { mainIsland.SetActive(false); searchIsland.SetActive(true); upgradeMenu.SetActive(false); int player1ControlNo = PlayerPrefs.GetInt("Player1", 1); int player2ControlNo = PlayerPrefs.GetInt("Player2", 2); if (player2ControlNo == 4) { if (player1ControlNo != 3) { player2ControlNo = 3; } } if (!triggeredBackToIsland) { returnToIsland.SetActive(false); if (Time.realtimeSinceStartup - startTime > 1) { if (InputManager.GetButtonDown("Interact" + player1ControlNo) && !player1Pressed) { player1Pressed = true; player1Time = Time.realtimeSinceStartup; Debug.Log("Player 1 Time is " + player1Time); } if (InputManager.GetButtonDown("Interact" + player2ControlNo) && !player2Pressed) { player2Pressed = true; player2Time = Time.realtimeSinceStartup; Debug.Log("Player 2 Time" + player2Time); } } if (player1Pressed && player2Pressed) { if (Mathf.Abs(player1Time - player2Time) < 0.1) { //success int number = totalNoOfCrewOnIsland - currCrewSaveOnIsland; int i = Random.Range(1, number); currCrewSaveOnIsland += i; resultText.text = "You have found " + i + " crews"; ship.crewsaved += i; } else { if ((player1Time - player2Time) > 0) { resultText.text = "Painty pressed too fast"; } else { resultText.text = "Sharpie pressed too fast"; } } crewText.text = ship.crewsaved + "/" + ship.crewtosave; player1Pressed = false; player2Pressed = false; triggeredBackToIsland = true; startTime = Time.realtimeSinceStartup; } } else { //trigger back to island returnToIsland.SetActive(true); if (Time.realtimeSinceStartup - startTime > 2) { currentState = MenuStates.Main; resultText.text = ""; ES.SetSelectedGameObject(shopButton); } } } } } }