// Use this for initialization void Start() { sceneManagement = GameObject.FindGameObjectWithTag(GlobalVariables.MANAGERTAG).GetComponent <SceneManagement>(); gameLogic = GameObject.FindGameObjectWithTag(GlobalVariables.MANAGERTAG).GetComponent <GameLogic>(); lives = maxLives; livesText.text = lives.ToString(); }
void Start() { damagecounter = 0; turnwhite = false; r = GetComponentsInChildren <Renderer>(); gm = FindObjectOfType <GameManager>(); anim = GetComponent <Animator>(); rb = GetComponent <Rigidbody2D>(); sm = FindObjectOfType <SceneManagement>(); //NinjaController sling = FindObjectOfType<NinjaController>(); enispunching = false; enisidle = true; eniswalking = false; enishurt = false; enisnut = false; enpunchcol.enabled = true; time = 0; punchistriggered = false; yomama = false; player = FindObjectOfType <PlayerMovement>(); haswhistled = false; //player = Transform.FindWithTag("Player").GetComponent<PlayerMovement>(); //player = Transform.FindWithTag("Player").transform; //player = Transform.Find("Player").gameObject; //player = PlayerMovement.Transform.Find("Player").gameObject; playera = GameObject.FindWithTag("playerp"); target = playera.transform; }
IEnumerator OnCollisionEnter2D(Collision2D c) { if (c.gameObject.CompareTag("Obstacle") && health != 0 && !EnemyDeath) //if player hit an obstacle { float sign = GetComponent <Transform>().position.x - c.gameObject.transform.position.x; // get position difference between player and obstacle to see in which direction he hit it float dir = sign / Mathf.Abs(sign); // change the differencethe player to either 1 or -1 rb.AddForce(new Vector2(300 * sign, 300)); // add force according to sign health -= 0.125f; // decrease player health image.fillAmount = health; // change health amount (Image) audio.Play(); // play coins audio // removeCoins(); } if (health == 0 && !isDead) //if player is dead { gameSound.isOver = true; isDead = true; // set player as dead camera.Follow = null; // freeze camera animator.SetTrigger("Dead"); // trigger death animation rb.constraints = RigidbodyConstraints2D.FreezeRotation; //freeze rotation of player rb.constraints = RigidbodyConstraints2D.FreezePositionX; // freeze position of player rb.gameObject.GetComponent <BoxCollider2D>().isTrigger = true; // so that the player rb.gameObject.GetComponent <CircleCollider2D>().isTrigger = true; // doesnt hit the floor yield return(new WaitForSeconds(1)); // wait for 1 sec transition.SetTrigger("End"); // Trigger fade in animation yield return(new WaitForSeconds(2)); gameOver.SetTrigger("gameOver"); yield return(new WaitForSeconds(4)); currentScene = SceneManager.GetActiveScene().buildIndex; SceneManagement.GameOver(); } }
private IEnumerator ThankYouMessage() { GetComponent <AudioSource>().Play(); yield return(new WaitForSeconds(9.5f)); SceneManagement.ReturnToMain(); }
private void Awake() { if (instance == null) { instance = this; } }
private void Start() { sceneManagementScript = GetComponent <SceneManagement>(); currentLvlText.text = "" + sceneManagementScript.currentScene; nextLvlText.text = "" + sceneManagementScript.nextScene; StartCoroutine("SliderIncreaser"); }
//checks collision between the seeker's weapon and scene objects private void OnTriggerEnter(Collider other) { //if the object isn't a player if (other.gameObject.tag.Equals("Untagged") || other.gameObject.tag.Equals("HiderPlaceholder")) { source.PlayOneShot(emptySound, 5f); //destroys the game object Destroy(other.gameObject); //decreases amount of time left timer.DecreaseTime(secondsRemoved); } //if the object is a hider if (other.gameObject.tag.Equals("Hider0") || other.gameObject.tag.Equals("Hider1") || other.gameObject.tag.Equals("Hider2")) { source.PlayOneShot(hiderSound, 5f); Destroy(other.gameObject); //increases number of hiders found SceneManagement.hidersFound += 1; //checks to see if all hiders have been found if (SceneManagement.hidersFound >= 3) { SceneManagement.Win(); } } }
private void OnTriggerEnter2D(Collider2D collision) { if (!collision.gameObject.CompareTag("PlayerProjectile")) { SceneManagement.Tutorial2(); } }
// Use this for initialization void Start() { sm = GameObject.Find("Scenemangaer").GetComponent <SceneManagement>(); Screen.autorotateToPortrait = false; Screen.autorotateToPortraitUpsideDown = false; Screen.orientation = ScreenOrientation.LandscapeLeft; // DontDestroyOnLoad(this); uim = ControlUi.GetComponent <UiManager>(); ControlUi.SetActive(false); for (int i = 0; i < compuestos.Length; i++) { int x = 0; int y = 0; int z = 0; x = compuestos[i].elementosNesesario[0]; y = compuestos[i].elementosNesesario[1]; z = compuestos[i].elementosNesesario[2]; elements[x, y, z] = compuestos[i]; elements[y, x, z] = compuestos[i]; elements[z, x, y] = compuestos[i]; elements[y, z, x] = compuestos[i]; elements[z, y, x] = compuestos[i]; elements[x, z, y] = compuestos[i]; } }
private void OnTriggerEnter(Collider other) { if (other.tag == "Player") { SceneManagement.LevelComplete(); } }
// Update is called once per frame void Update() { // Add order within set amount of time StartCoroutine(TimeBeforeNextOrder()); #if DEBUG ordersInInspector = new List <string>(); for (int i = 0; i < pancakeOrders.Count; i++) { ordersInInspector.Add(pancakeOrders[i].orderNumber.ToString()); } currentOrderCounter = orderCounter; #endif if (GlobalTimer.secondsRemaining < 0) { if (OrderTracker.CompleterdOrders1 > OrderTracker.CompleterdOrders2) { SceneManagement.PlayerOneWin(); } else { SceneManagement.PlayerTwoWin(); } } // check timer count of individual orders CheckTimers(); }
void Start() { int buttonIndex = transform.GetSiblingIndex() + 1; sceneManagement = SceneManagement.instance; button = GetComponent <Button>(); image = GetComponent <Image>(); timePlayedText = GetComponentInChildren <TMP_Text>(); string savePath = Application.persistentDataPath + buttonIndex + ".bin"; if (File.Exists(savePath)) { float playingTime = SaveSystem.LoadGame(buttonIndex).playingTime; string hours = Mathf.Floor((playingTime % 216000) / 3600).ToString("00"); string minutes = Mathf.Floor((playingTime % 3600) / 60).ToString("00"); string seconds = Mathf.Floor(playingTime % 60).ToString("00"); timePlayedText.text = "Tempo de jogo: " + hours + ":" + minutes + ":" + seconds; } else { timePlayedText.text = "Novo jogo"; } string screenshotPath = Application.persistentDataPath + buttonIndex + ".png"; if (File.Exists(screenshotPath)) { byte[] picture = File.ReadAllBytes(screenshotPath); Texture2D texture = new Texture2D(1920, 1080, TextureFormat.RGB24, false); texture.LoadImage(picture); image.sprite = Sprite.Create(texture, new Rect(0f, 0f, texture.width, texture.height), new Vector2(0f, 0f)); } button.onClick.AddListener(delegate { sceneManagement.LoadGameScene(); SceneManagement.index = buttonIndex; }); }
private void OnTriggerEnter2D(Collider2D collision) { if (!collision.gameObject.CompareTag("PlayerProjectile") && !collision.gameObject.CompareTag("PlayerUlt")) { SceneManagement.LevelSelect(); } }
// Use this for initialization void Start() { if (this.GetComponent <AudioSource>() != null) { audio = this.GetComponent <AudioSource>(); } scene = this.GetComponent <SceneManagement>(); fade = GameObject.Find("FadePanel").GetComponent <FadeScript>(); if (SceneManager.GetActiveScene().name == "SelectScene") { menu = GameObject.Find("SelectSceneObj").GetComponent <MenuEvent>(); enter = GameObject.Find("SelectSceneObj").GetComponent <CancelScript>(); //select = GameObject.Find("P1Image").GetComponent<CharacterSelect>(); //select2 = GameObject.Find("P2Image").GetComponent<CharacterSelect>(); } if (SceneManager.GetActiveScene().name == "PlayMenuScene") { datare = GameObject.Find("GameSystem").GetComponent <DataRetention>(); } if (SceneManager.GetActiveScene().name == "PlayScene" || SceneManager.GetActiveScene().name == "PlayMenuScene") { sys = GameObject.Find("GameSystem").GetComponent <PlayMenuSystem>(); } if (SceneManager.GetActiveScene().name == "PlayMenuScene") { sys = GameObject.Find("PlayMenuSystemObj").GetComponent <PlayMenuSystem>(); } //Debug.Log("sys:" + sys); //Debug.Log("datare:" + datare); sceneFlagMenu = false; }
// Update is called once per frame void Update() { if (strawCountRemaining >= 3) { SceneManagement.KillWin(); } }
// Use this for initialization void Start() { DontDestroyOnLoad(gameObject); sceneManagInstance = FindObjectOfType <SceneManagement>(); soundManagInstance = FindObjectOfType <SoundManager>(); currentLevel = -1; }
public SceneManagement() { if (!instance) { instance = this; } }
private void Awake() { Instance = this; Load("Player"); Load("Scene01"); Load("Scene02"); }
private void OnEnable() { sceneManagement = GetComponent <SceneManagement>(); MinePlayer.ResetElement(); OtherPlayer.ResetElement(); roomDetails.ResetElement(); socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); socket.Blocking = false; myEndPoint = new IPEndPoint(IPAddress.Parse(MyAddres), MyPort); socket.Bind(myEndPoint); serverEndPoint = new IPEndPoint(IPAddress.Parse(ServerAddress), ServerPort); DontDestroyOnLoad(this.gameObject); commands = new command[20]; commands[COMMAND_UPDATE] = Update; commands[COMMAND_WELCOME] = Welcome; commands[COMMAND_P_CONNECTED] = OtherPlayerConnected; commands[COMMAND_SETUP_OP] = SetUpOtherPlayer; commands[COMMAND_COUNTDOWN] = Countdown; commands[COMMAND_SPAWN_OBSTACLE] = SpawnObstacle; commands[COMMAND_COLLIDE] = Collided; commands[COMMAND_DESTROY] = DestroyObstacle; commands[COMMAND_INTANGIBLEOP] = IntangibleOP; commands[COMMAND_CHANGEOTHERPLAYERPOSITION] = ChangePosOP; commands[COMMAND_CHECKPING] = CheckLatency; commands[COMMAND_CHECKRESPONSE] = CheckResponse; sceneManagement.LoadGameScene(); SceneManager.activeSceneChanged += LoadGameSceneElements; }
// Use this for initialization void Start() { sceneManagement = GameObject.FindGameObjectWithTag("Manager").GetComponent <SceneManagement>(); gameLogic = GameObject.FindGameObjectWithTag("Manager").GetComponent <GameLogic>(); lives = maxLives; livesText.text = lives.ToString(); }
void Start() { player = FindObjectOfType <PlayerMovement>(); sm = GetComponent <SceneManagement>(); chill.volume = PlayerPrefsController.GetMusicVolume(); fight.volume = 0; }
protected override IEnumerator DeathAnimation() { if (theManager.GetComponent <GhostManager>().LastGhost()) { GetComponent <Collider2D>().enabled = false; GameManager.instance.Win(); dead = true; GameObject.Find("Main Camera").GetComponent <ScreenShake>().Shake(); StartCoroutine(SpawnDeathParticles()); yield return(new WaitForSeconds(2.5f)); yield return(FadeToBlack()); Destroy(gameObject); SceneManagement.Win(); } else { animator.SetBool(clipBool, true); GetComponent <Collider2D>().enabled = false; AnimationClip[] clips = animator.runtimeAnimatorController.animationClips; foreach (AnimationClip clip in clips) { if (clip.name.Equals(deathClip)) { yield return(new WaitForSeconds(clip.length)); } } nextGhosts(); } }
private IEnumerator DisclaimerMessage() { GetComponent <AudioSource>().Play(); yield return(new WaitForSeconds(11f)); SceneManagement.LevelComplete(); }
public void Save() { PlayerData playerData = player.data; LevelData levelData = null; if (SceneManagement.CurrentLevelNumber() > 0) { Enemy[] enemies = enemyManager.GetActiveEnemies(); Tower[] towers = towerManager.GetActiveTowers().ToArray(); Dictionary <string, int> towerPositions = new Dictionary <string, int>(); Dictionary <string, int> enemyPositions = new Dictionary <string, int>(); foreach (Enemy enemy in enemies) { enemyPositions.Add(enemy.transform.position.ToString(), (int)enemy.type); } foreach (Tower tower in towers) { towerPositions.Add(tower.transform.position.ToString(), (int)tower.type); } levelData = new LevelData(SceneManagement.CurrentLevelNumber(), towerPositions, enemyPositions, Round, enemyManager.SpawnRate.ToString(), player.Coins, player.Health); } saveData.playerData = playerData; saveData.levelData = levelData; saveAndLoad.SaveGameData(saveData); }
// Update is called once per frame void Update() { //CameraRotation(); //currentPos = whitePiecesSide.transform.position; turnText.text = $"Player Turn: {currentTurn}"; if (numberOfBlackPiecesOnBoard <= 0) { SceneManagement.GameOver(); } else if (numberOfWhitePiecesOnBoard <= 0) { SceneManagement.Win(); } //if(currentTurn==colorTurn.white) //{ // //whitePiecesSide.enabled = true; // //blackPiecesSide.enabled = false; // //whitePiecesSide.transform.RotateAround(Vector3.zero, Vector3.up, degrees); //} //else if (currentTurn == colorTurn.black) //{ // //whitePiecesSide.enabled = false; // //blackPiecesSide.enabled = true; //} }
private void Awake() { if (instance == null) { instance = this; DontDestroyOnLoad(gameObject); } }
public void EndGame() { //On game ending, saves the last score into player prefs and loads the end scene ScoreObject s = new ScoreObject(CoinManager.instance.GetCoins(), (int)playTime); SaveLoad.SaveLastScore(s.ToString()); SceneManagement.LoadScene(2); }
void Start() { sceneManager = FindObjectOfType <SceneManagement> (); text = textObject.GetComponent <TextMeshProUGUI> (); sprite = this.gameObject.GetComponent <SpriteRenderer> (); light = this.gameObject.GetComponentInChildren <Light> (); }
public void Damage(int damage) { PlayerStats.playerHealth -= damage; if (PlayerStats.playerHealth <= 0) { SceneManagement.loadSceneByIndex(0); } }
void Update() { if (Input.anyKeyDown) { PlayerStats.reset(); SceneManagement.nextScene(); } }