Inheritance: MonoBehaviour
示例#1
0
 void EndLevel()
 {
     state            = LevelState.Ending;
     levelEndInstance = Instantiate(levelEndPrefab, transform);
     levelEndInstance.OnAnimationEnded += OnLevelEndEnd;
     levelEndInstance.level             = this;
 }
示例#2
0
    public IEnumerator Die()
    {
        yield return(new WaitForSeconds(2)); //for now

        health = maxHealth;
        LevelEnd.LoadMain();
    }
示例#3
0
    static string GetAchievementId(LevelEnd levelEnd)
    {
        switch (levelEnd)
        {
        case LevelEnd.PATIENT:
            return(AchievementsConstants.achievement_patient_ending);

        case LevelEnd.IMPATIENT:
            return(AchievementsConstants.achievement_impatient_ending);

        case LevelEnd.INTERRUPTED:
            return(AchievementsConstants.achievement_interrupted_ending);

        case LevelEnd.VIOLENT:
            return(AchievementsConstants.achievement_violent_ending);

        case LevelEnd.FIRE:
            return(AchievementsConstants.achievement_fire_ending);

        case LevelEnd.HEART:
            return(AchievementsConstants.achievement_throw_out_ending);

        case LevelEnd.SHAKE:
            return(AchievementsConstants.achievement_dirty_ending);
        }

        return(null);
    }
示例#4
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.S) && nextToPlayer)
        {
            switch (nextScene)
            {
            case 0:
                GlobalControl.Instance.ResetSceneLists();
                SceneManager.LoadScene(GlobalControl.MAIN_SCENE_NUM);
                break;

            case 1:
                SceneManager.LoadScene(GlobalControl.VSHOP_SCENE_NUM);
                break;

            case 2:
                SceneManager.LoadScene(GlobalControl.NSHOP_SCENE_NUM);
                break;

            case 3:
                LevelEnd.LoadLevel();
                break;

            default:
                print("ERROR: shouldn't be here (Update in Gate)");
                break;
            }
        }
    }
示例#5
0
    private GUIStyle timeStyle = new GUIStyle(); //create a new variable

    void Start()
    {
        spawnVector = new Vector2(0, 0);
        spawnPoint  = GameObject.Find("SpawnPoint");
        if (spawnPoint)
        {
            spawnVector = spawnPoint.transform.position;
            // making spawn point box invisible
            spawnPoint.GetComponent <SpriteRenderer>().enabled = false;
        }
        levelEnd = GameObject.FindObjectOfType <LevelEnd>();

        characterLives   = new List <CharacterLife>();
        luigiPrefab      = Resources.Load <GameObject>("very_important_asset");
        lincolnPrefab    = Resources.Load <GameObject>("LincolnPrefab");
        grumpyPrefab     = Resources.Load <GameObject>("GrumpyPrefab");
        barbershopPrefab = Resources.Load <GameObject>("BarbershopPrefab");
        // Debug.Log("truly what");

        keyDoors = new List <KeyDoorController>();
        var keyDoorControllers = GameObject.FindObjectsOfType <KeyDoorController>();

        foreach (var keyDoor in keyDoorControllers)
        {
            keyDoors.Add(keyDoor);
        }

        selectedPrefabCharacter = lincolnPrefab;

        winbarbersource    = gameObject.AddComponent <AudioSource>();
        winbarberclip      = (AudioClip)Resources.Load("winbarber");
        timeStyle.fontSize = 30;
    }
示例#6
0
    void Start()
    {
        thePlayer      = FindObjectOfType <Player> ();
        theLevelEnd    = FindObjectOfType <LevelEnd> ();
        ScoreText.text = "Score " + coinCount.ToString();
        healthCount    = maxHealth;
        objectOnReset  = FindObjectsOfType <ResetOnRespwan> ();

        if (PlayerPrefs.HasKey("CountCoins"))
        {
            coinCount = PlayerPrefs.GetInt("CountCoins");
        }

        ScoreText.text = "Score :" + coinCount.ToString();

        if (PlayerPrefs.HasKey("Live"))
        {
            currentLives = PlayerPrefs.GetInt("Live");
        }
        else
        {
            currentLives = startingLives;
        }

        gameOver.SetActive(false);
        levelMusic.Play();
        gameOverMusic.Stop();
        liveText.text = "Live x " + currentLives.ToString();
    }
 public void EndLevel(bool win)
 {
     if (GameManager.Instance.State == GameManager.GameState.Playing)
     {
         LevelEnd?.Invoke(win);
     }
 }
示例#8
0
	void Start ()
	{
		instance = this;

		player1 = GameObject.Find ("Player1");
		camera = GameObject.Find ("MainCamera_Front");
		anim = this.GetComponent<Animator>();

		controlTutContainer = GameObject.Find ("ControlTutContainer");
		controlTutContainer2 = GameObject.Find ("ControlTutContainer2");

		players= GameObject.FindGameObjectsWithTag ("Player");
		if(players[0].transform.name == "Player1")
		{
			player1 = GameObject.Find ("Player1");
		}
		else if(players[0].transform.name == "Player2")
		{
			player1 = GameObject.Find ("Player2");
		}
		else if(players[0].transform.name == "Player3")
		{
			player1 = GameObject.Find ("Player3");
		}
		else if(players[0].transform.name == "Player4")
		{
			player1 = GameObject.Find ("Player4");
		}	
	}
示例#9
0
 // Use this for initialization
 void Start()
 {
     control      = this;
     buttonListen = GameObject.FindGameObjectWithTag("GameController").GetComponent <ButtonListener>();
     RetryButton.GetComponent <ButtonPress>().isActive = false;
     MenuButton.GetComponent <ButtonPress>().isActive  = false;
     CompleteMenu.SetActive(false);
 }
示例#10
0
    // Use this for initialization
    void Start()
    {
        GameObject end = GameObject.FindGameObjectWithTag("LevelEnd");

        if (end != null)
        {
            levelEnd = end.GetComponent <LevelEnd> ();
        }
    }
示例#11
0
 void Update()
 {
     if (currentHealth <= 0)
     {
         Stats.deaths++;
         Stats.Tdeaths++;
         LevelEnd.reset();
         SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
     }
 }
示例#12
0
 private void Player_PlayerDeath()
 {
     _isPlaying = false;
     StartCoroutine(OnPlayerDeath());
     _haslost = true;
     numberOfAttempts++;
     PlayerPrefs.SetInt(_currentNumberOfAttemptsIndex, numberOfAttempts);
     LevelEnd?.Invoke(false);
     _scriptableEvent.ReloadScene(_waitTimeOnReload);
 }
示例#13
0
    public static void EndGame(LevelEnd levelEnd)
    {
        if (instance.alreadyEnding)
        {
            return;
        }

        instance.alreadyEnding = true;
        LevelEnder.levelEnd    = levelEnd;

        instance.StartCoroutine(instance.EndGameCoroutine(levelEnd));
    }
示例#14
0
 void Awake()
 {
     // Set text variables to blank
     restartText.text   = "";
     levelWinText.text  = "";
     levelLossText.text = "";
     // Find the player gameobject and get the Health script
     player = GameObject.FindWithTag("Player");
     health = player.GetComponent <Health>();
     // Find the level end trigger and get the LevelEnd script
     end         = GameObject.FindWithTag("Finish");
     levelFinish = end.GetComponent <LevelEnd>();
 }
示例#15
0
    private LevelEnd[] GetImplementedEndings()
    {
        LevelEnd[] result = new LevelEnd[endingLabelsParent.transform.childCount];
        int        i      = 0;

        foreach (Transform child in endingLabelsParent.transform)
        {
            result[i] = child.GetComponent <EndingLabel>().levelEnd;
            i++;
        }

        return(result);
    }
    private IEnumerator Start()
    {
        if (levelEnd == null)
        {
            levelEnd = GameObject.FindObjectOfType <LevelEnd>();
        }

        yield return(null);

        yield return(null);

        levelNumber = -1;
        ProgressLevel(levelEnd.teleportPoint);
    }
示例#17
0
    void Update()
    {
        if (CurrentPercentsByTime() == 100)
        {
            LevelEnd levelEnd = DialogueSystem.DialogueStarted() ? LevelEnd.INTERRUPTED : LevelEnd.PATIENT;
            LevelEnder.EndGame(levelEnd);
        }

        if (!dragging)
        {
            UpdateInnerBarPosition();
        }

        UpdatePercentsText();
    }
示例#18
0
    private IEnumerator LevelWon(float time)
    {
        _isPlaying = false;
        _hasWon    = true;
        if (numberOfAttempts < bestNumberOfAttempts || bestNumberOfAttempts == 0)
        {
            PlayerPrefs.SetInt(_bestNumberOfAttemptsIndex, numberOfAttempts);
        }
        if (_time < bestTime || bestTime == 0f)
        {
            PlayerPrefs.SetFloat(_bestTimeIndex, _time);
        }

        yield return(new WaitForSecondsRealtime(time));

        LevelEnd?.Invoke(true);
    }
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.CompareTag(DEATHBOX_TAG))
        {
            levelManager.RespawnPlayer();
        }

        Coin coin = other.GetComponent <Coin>();

        if (coin != null)
        {
            levelManager.AddCoins(coin.coinAmount);
            coin.gameObject.SetActive(false);
        }

        Heart heart = other.GetComponent <Heart>();

        if (heart != null)
        {
            levelManager.AddHealth(heart.healthAmount);
            heart.gameObject.SetActive(false);
        }

        HurtPlayer hurt = other.GetComponent <HurtPlayer>();

        if (hurt != null && hurt.IsActive)
        {
            levelManager.DamagePlayer(hurt.damageAmount);
        }

        LevelEnd end = other.GetComponent <LevelEnd>();

        if (end != null)
        {
            end.Trigger();
        }

        Checkpoint check = other.GetComponent <Checkpoint>();

        if (check != null)
        {
            check.Trigger();
            respawnPoint = check.transform;
            checkpointAudio.Play();
        }
    }
示例#20
0
 public void testCookieScore()
 {
     LevelEnd le = new LevelEnd();
     GameObject gb = new GameObject("stest");
     GameObject gb2 = new GameObject("ctest");
     UnityEngine.UI.Text st = gb.AddComponent<UnityEngine.UI.Text>();
     UnityEngine.UI.Text ct = gb2.AddComponent<UnityEngine.UI.Text>();
     Slider suspicionSlider = gb.AddComponent<Slider>();
     st.text = "Time: 0";
     ct.text = "Cookie: 1";
     suspicionSlider.value = 0;
     le.cookieText = ct;
     le.timeText = st;
     le.suspicionSlider = suspicionSlider;
     le.CalculateScore();
     Assert.AreEqual(6500, le.getScore());
 }
    // Start is called before the first frame update
    void Start()
    {
        playerDead = false;

        playerRigidbody             = GetComponent <Rigidbody2D>();
        legsAnimator                = GetComponentInChildren <Animator>();
        playerSword                 = transform.Find("PlayerBlade").gameObject;
        ammoScript                  = GameObject.Find("Ammo Message").GetComponent <Ammo>();
        levelEndScript              = GameObject.Find("Cart (Level End Trigger)").GetComponent <LevelEnd>();
        gameMaster                  = GameObject.FindGameObjectWithTag("GM").GetComponent <GameMaster>();
        playerDeathControllerScript = gameObject.GetComponent <PlayerDeathController>();

        //spawn the player at the checkpoint position
        gameObject.transform.position = gameMaster.lastCheckPointPosition;

        //get the player state when the level loads
        UpdatePlayerState();
    }
示例#22
0
    void Awake()
    {
        if (SceneManager.GetActiveScene().buildIndex == 0 || instance == null)
        {
            if (instance != null)
            {
                Destroy(instance.gameObject);
            }

            instance = this;
            DontDestroyOnLoad(gameObject);
            audioSource = GetComponent <AudioSource>();
            levelEnd    = LevelEnd.TEST;
        }
        else
        {
            Destroy(gameObject);
        }
    }
示例#23
0
 public void testBoundryThreeStarLevelOne()
 {
     LevelEnd le = new LevelEnd();
     le.threeStarScore = 5000;
     GameObject gb = new GameObject("stest");
     GameObject gb2 = new GameObject("ctest");
     UnityEngine.UI.Text st = gb.AddComponent<UnityEngine.UI.Text>();
     UnityEngine.UI.Text ct = gb2.AddComponent<UnityEngine.UI.Text>();
     Slider suspicionSlider = gb.AddComponent<Slider>();
     st.text = "Time: 30";
     ct.text = "Cookie: 0";
     suspicionSlider.maxValue = 5000f;
     suspicionSlider.value = 198f;
     le.cookieText = ct;
     le.timeText = st;
     le.suspicionSlider = suspicionSlider;
     le.CalculateScore();
     Assert.AreEqual(5001, le.getScore());
     Assert.AreEqual(3, le.getStar());
 }
示例#24
0
    IEnumerator EndGameCoroutine(LevelEnd levelEnd)
    {
        DialogueSystem.CloseDialogue();
        LoadingBar.OnDisableInput();
        AcceptingInputStatus.DisableAcceptingInput();
        BackgroundSoundPlayer.Stop();

        if (levelEnd == LevelEnd.IMPATIENT)
        {
            audioSource.PlayOneShot(fart);
            LoadingBar.FillRestOfLoadingBar(fart.length);
            yield return(new WaitForSeconds(fart.length));
        }

        if (levelEnd != LevelEnd.HEART && levelEnd != LevelEnd.SHAKE)
        {
            audioSource.PlayOneShot(toiletFlushing);
            yield return(new WaitForSeconds(toiletFlushing.length));
        }

        MainCamera.ZoomOut();
        if (levelEnd == LevelEnd.SHAKE)
        {
            Door.OpenDoorCensored();
            dwarf.GetComponentInChildren <Renderer>().material = dwarfToiletPapered;
        }
        else
        {
            Door.OpenDoor();
        }

        audioSource.PlayOneShot(doorSqueak);
        yield return(new WaitForSeconds(doorSqueak.length));

        dwarf.SetActive(true);
        dwarf.GetComponentInChildren <Animator>().speed = 1 / footSteps.length;
        audioSource.PlayOneShot(footSteps);
        yield return(new WaitForSeconds(footSteps.length));

        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
    }
示例#25
0
    private IEnumerator UnlockAchievementCoroutine(LevelEnd levelEnd)
    {
        while (!Social.localUser.authenticated)
        {
            yield return(null);
        }

        #if !UNITY_EDITOR
        Social.ReportProgress(GetAchievementId(levelEnd), 100.0, (success) => {
            if (success)
            {
                Debug.Log("Achievement reported: " + levelEnd);
            }
            else
            {
                Debug.LogError("Achievement NOT reported: " + levelEnd);
            }
        });
        #else
        Debug.Log("Achievement unlocked: " + levelEnd);
        #endif
    }
    private IEnumerator CountdownCoroutine(int seconds = 3)
    {
        Time.timeScale = 0;
        enableOnCountdown.DisableObjects();

        LevelEnd end        = GetComponent <LevelEnd>();
        var      parameters = end.parameters;

        timerText.text = $"Stage {parameters.currentLevelIndex + 1}";
        yield return(new WaitForSecondsRealtime(2f));

        for (int i = seconds; i > 0; i--)
        {
            timerText.text = i.ToString();
            yield return(new WaitForSecondsRealtime(1f));
        }

        timerText.text = "GO!";
        yield return(new WaitForSecondsRealtime(1f));

        Time.timeScale = 1;
        enableOnCountdown.EnableObjects();
        timerText.gameObject.SetActive(false);
    }
    // Update is called once per frame
    void Update()
    {
        Scene      currentScene = SceneManager.GetActiveScene();
        GameObject player       = GameObject.Find("Player");

        if (player)
        {
            TimeBehaviour timeScript     = player.GetComponent <TimeBehaviour> ();
            LevelEnd      levelEndScript = player.GetComponent <LevelEnd> ();

            if (currentScene.name == "TestScene2" && timePassed == false)
            {
                scene = 2;
                timeScript.timeLeft = timeAtEndLevelOne;
                timePassed          = true;
            }

            if (levelEndScript.levelEnded && setTime == false && scene == 1)
            {
                SettingsForSecondLevel(timeScript.timeLeft);
            }
        }

        GameObject scoreControlObject = GameObject.Find("ScoreControlObject");

        if (scoreControlObject)
        {
            ScoreControl scoreControlScript = scoreControlObject.GetComponent <ScoreControl> ();
            scoreControlScript.objectsHit = objectsHit;
        }

        if (currentScene.name == "TestScene")
        {
            scene = 1;
        }
    }
示例#28
0
    public static void Trigger(LevelEnd topic)
    {
        if (instance.isDialogueShown)
        {
            return;
        }

        if (topic != instance.currentLevelEnd)
        {
            instance.currentLinesIndex = 0;
        }

        instance.currentLevelEnd = topic;
        instance.isDialogueShown = true;

        if (instance.currentLinesIndex >= instance.currentDialogueLines.Length)
        {
            Debug.Log("No more dialogue lines.");
            return;
        }

        DialogueLine currentLine = instance.currentDialogueLines[instance.currentLinesIndex];

        if (currentLine.showNextLineAfterThis)
        {
            LoadingBar.DestroySelf();
            BackgroundSoundPlayer.Stop();
        }

        instance.text.text          = currentLine.text;
        instance.timeLastLineShowed = Time.time;

        instance.wrapper.SetActive(true);
        instance.closeButton.gameObject.SetActive(false);
        instance.StartCoroutine(instance.ShowButton());
    }
示例#29
0
 public void BackButton()
 {
     LevelEnd.LoadMain();
 }
 private void Start()
 {
     levelEndScript = GameObject.Find("Cart (Level End Trigger)").GetComponent <LevelEnd>();
 }
示例#31
0
 void Start()
 {
     theLevelEnd = transform.parent.GetComponent <LevelEnd>();
 }
示例#32
0
    // Use this for initialization
    void Awake()
    {
        levelEnd=this;

        endDoor = EndRoom.endRoom.endRoomDoor;
    }
示例#33
0
 public static void UnlockAchievement(LevelEnd levelEnd)
 {
     instance.StartCoroutine(instance.UnlockAchievementCoroutine(levelEnd));
 }
示例#34
0
 private void Start()
 {
     lvlEnd = FindObjectOfType <LevelEnd>();
 }