コード例 #1
0
ファイル: InputHandler.cs プロジェクト: FluFFey/ShiverClock
    public IEnumerator killPlayer()
    {
        if (alive && invulTimer.hasEnded())
        {
            GetComponent <PlayerAnimationHandler>().setHurt();
            remainingLives--;
            lifeRemainderText.GetComponent <Text>().text = "Lives: " + remainingLives.ToString();
            Vector2 positionOfDeath = (Vector2)transform.position + Vector2.up * 0.5f;
            rb.velocity = Vector2.zero;
            alive       = false;
            sc.attemptSound(deathSound);
            cc.isTrigger = true;
            yield return(new WaitForSeconds(0.2f));

            rb.velocity = Vector2.up * 10;
            for (float i = 0; i < 1; i += Time.deltaTime)
            {
                rb.velocity += Vector2.down * Time.deltaTime * 20.0f;
                yield return(null);
            }
            if (remainingLives != 0)
            {
                float      respawnDelay = 4.5f;
                GameObject respawnText  = new GameObject("respawnText");
                respawnText.transform.position = positionOfDeath;
                TextMesh rst = respawnText.AddComponent <TextMesh>(); //restartText
                rst.anchor        = TextAnchor.MiddleRight;
                rst.characterSize = 0.3f;
                rst.fontSize      = 12;
                for (float i = 0; i < respawnDelay; i += Time.deltaTime)
                {
                    rst.text = "Respawn in: " + (respawnDelay - i).ToString("0."); //may not need text
                    yield return(null);
                }
                Destroy(respawnText);
                //respawn
                alive        = true;
                cc.isTrigger = false;

                transform.position = MyGameManager.instance.getSpawnPos();
                ;
                Destroy(Instantiate(respawnParticles, transform), 1.0f);
                StartCoroutine(getInvulnerable());
                rb.velocity = Vector2.zero;
            }
            else
            {
                if (playerID == PlayerID.PlayerOne)
                {
                    MyGameManager.instance.setVictor(2);
                }
                if (playerID == PlayerID.PlayerTwo)
                {
                    MyGameManager.instance.setVictor(1);
                }
            }
        }
    }
コード例 #2
0
ファイル: GuardScript.cs プロジェクト: FluFFey/Tracebook
    public IEnumerator spotGhost(float angle)
    {
        sc.attemptSound(spotGhostSound);
        if (!turning)
        {
            spottedGhost = true;
            if (rb2d.velocity.x > 0)
            {
                angle *= -1;
            }
            Vector2 oldVel = rb2d.velocity;
            rb2d.velocity = Vector2.zero;

            float lookTime = 0.3f;
            float oldAngle = flashLightRotator.transform.rotation.eulerAngles.z;
            float newAngle = oldAngle;
            for (float i = 0; i < lookTime; i += TimeManager.instance.fixedGameDeltaTime)
            {
                float pd = i / lookTime;
                newAngle = oldAngle + angle * pd;
                flashLightRotator.transform.rotation = Quaternion.Euler(0, 0, newAngle);
                yield return(null);
            }
            yield return(new WaitForSeconds(2.2f));

            flashLightRotator.transform.rotation = Quaternion.Euler(0, 0, oldAngle);
            rb2d.velocity = oldVel;
            spottedGhost  = false;
        }
    }
コード例 #3
0
    public IEnumerator nextLevel()
    {
        if (levelIndex >= levelNames.Length)
        {
            TimeManager.instance.pauseGameTime();
            yield return(new WaitForSeconds(1.5f));

            PauseMenuScript.instance.children[3].SetActive(true);
            sc.attemptSound(GameCompleteFanfare);
            if (timeAtStartOfGame != -1)
            {
                GameObject.Find("Hero(Clone)").GetComponent <Rigidbody2D>().velocity = Vector2.zero;
                int min = (int)((Time.time - timeAtStartOfGame) / 60.0f);
                int sec = (int)((Time.time - timeAtStartOfGame) % 60.0f);
                PauseMenuScript.instance.children[3].GetComponentInChildren <Text>().text = "Congratulations! You completed the demo in " + min + ":" + sec + "!";
            }
            else
            {
                PauseMenuScript.instance.children[3].GetComponentInChildren <Text>().text = "Congratulations! You completed the final level! Try from the beginning!";
            }
        }
        else
        {
            if (SceneManager.GetActiveScene().name != "StartGame")
            {
                yield return(StartCoroutine(Camera.main.GetComponent <CameraScript>().fade(false, 4)));
            }

            string nextLvlName = "Scenes/" + levelNames[levelIndex];
            levelIndex++;

            /*
             * string nextLvlName = "Scenes/level" + currentLevel.ToString(); //important: all scenes have to be in Scenes folder
             * currentLevel++;
             */
            //if (!SceneManager.GetSceneByName(nextLvlName).IsValid()) //TODO: can't get this to work for now. cba to fix
            {
                //print(nextLvlName + " not found. end of available levels reached"); //TOOD: add victory screen or whatever
                //  return;
            }
            //else
            {
                print(nextLvlName);
                AsyncOperation asyncLoadLevel = SceneManager.LoadSceneAsync(nextLvlName);
                int            loadingFrames  = 0;
                while (!asyncLoadLevel.isDone)
                {
                    //loading screen stuff. probably fine without loading screen x - D
                    loadingFrames++;
                    print("loading frames:" + loadingFrames);
                    yield return(null);
                }
                MusicManager.instance.playSong(MusicManager.songEnums.MAIN_THEME);
            }
        }
    }
コード例 #4
0
 public void changeHighlightedButton(int newButton)
 {
     if (newButton != highlightedButton)
     {
         menuObjects[highlightedButton].GetComponent <TextPulse>().highlight(false);
         highlightedButton = newButton;
         sc.attemptSound(changeMenuObject[Random.Range(0, changeMenuObject.Length - 1)], 0.02f);
         menuObjects[highlightedButton].GetComponent <TextPulse>().highlight();
     }
 }
コード例 #5
0
ファイル: ObjectSounds.cs プロジェクト: FluFFey/Tracebook
 //Have no good idea on how to make this dynamic atm
 void Update()
 {
     if (soundTimer.hasEnded())
     {
         if (r2d != null && (!Mathf.Approximately(r2d.velocity.x, 0) || !Mathf.Approximately(r2d.velocity.y, 0)))
         {
             if (sc.attemptSound(sounds[Random.Range(0, sounds.Length)], pitchRange))
             {
                 soundTimer.restart();
             }
         }
     }
 }
コード例 #6
0
ファイル: SoundManager.cs プロジェクト: FluFFey/Tracebook
    public void playSound(SOUNDS sound)
    {
        AudioClip clipToPlay = null;

        switch (sound)
        {
        case SOUNDS.NEW_MESSAGE:
            clipToPlay = newMessageSound;
            break;

        case SOUNDS.SHARED_LOCATION:
            clipToPlay = sharedLocationSound;
            break;

        default:
            print("invalid sound requested");
            break;
        }

        sc.attemptSound(clipToPlay, 0.03f, 1.0f);
    }
コード例 #7
0
ファイル: SoundManager.cs プロジェクト: FluFFey/EiT-FD-Gr2
    public void playSound(SOUNDS sound)
    {
        AudioClip clipToPlay = null;

        switch (sound)
        {
        case SOUNDS.CLONE:
            clipToPlay = cloneSound;
            break;

        case SOUNDS.SPLICE:
            clipToPlay = spliceSound;
            break;

        case SOUNDS.FARM:
            clipToPlay = farmSound;
            break;

        case SOUNDS.HARVEST:
            clipToPlay = harvestSound;
            break;

        case SOUNDS.HARVEST_ROTTEN:
            clipToPlay = harvestRottenSound;
            break;

        case SOUNDS.PLACE_IN_SPLICE_MACHINE:
            clipToPlay = placeBaseSpecieInSpliceMachineSound;
            break;

        case SOUNDS.SELECT_SHELF_OBJ:
            clipToPlay = selectShelfObjectSound;
            break;

        case SOUNDS.FEAST:
            clipToPlay = feastSound;
            break;

        case SOUNDS.ERROR_LAB:
            clipToPlay = labErrorSound;
            break;

        case SOUNDS.ENTER_LAB:
            clipToPlay = enterLabSound;
            break;

        case SOUNDS.LEAVE_LAB:
            clipToPlay = enterLabSound;
            break;

        case SOUNDS.NIGHT_DEFAULT:
            clipToPlay = normalNightSound;
            break;

        case SOUNDS.NIGHT_EARTHQUAKE:
            clipToPlay = earthquakeNightSound;
            break;

        case SOUNDS.NIGHT_WIND:
            clipToPlay = windNightSound;
            break;

        case SOUNDS.NIGHT_WATER:
            clipToPlay = waterNightSound;
            break;

        case SOUNDS.DEFAULT_UI:
            clipToPlay = defaultUISound;
            break;

        case SOUNDS.READ_MESSAGE:
            clipToPlay = readBottleMessage;
            break;

        default:
            print("invalid sound requested");
            break;
        }
        sc.attemptSound(clipToPlay, 0.1f);
    }