コード例 #1
0
ファイル: Campfire.cs プロジェクト: JohnLeeErg/TrailMix
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "Player" && currentState == CampfireState.AtCampfire)
        {
            //print("player is in");

            GameObject enteredPlayer = collision.gameObject.transform.parent.root.gameObject;

            // check if the player that entered te fire is the same as one that just entered
            if (players.Contains(enteredPlayer) == false)
            {
                players.Add(enteredPlayer);

                PlayerIndicator indicator = enteredPlayer.GetComponentInChildren <PlayerIndicator>();
                playerIndicatorScripts.Add(indicator);
                indicator.ActivateImage();  // Make the indicators on the player visible when they enter the campfire range
            }

            // Check if both players are in the campfire
            if (players.Count >= 2)
            {
                buttonPromptText.SetActive(true); // Activate the text when both players are present
                fModLevelInteractionEvent.start();

                for (int i = 0; i < playerIndicatorScripts.Count; i++)
                {
                    playerIndicatorScripts[i].ChangeImage();
                }
            }
        }
    }
コード例 #2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "Player")
        {
            //print("player is in");

            GameObject enteredPlayer = collision.gameObject.transform.parent.root.gameObject;

            // check if the player that entered te fire is the same as one that just entered
            if (players.Contains(enteredPlayer) == false)
            {
                players.Add(enteredPlayer);
                playerMovementScripts.Add(enteredPlayer.GetComponent <Movement>());

                PlayerIndicator indicator = enteredPlayer.GetComponentInChildren <PlayerIndicator>();
                playerIndicatorScripts.Add(indicator);
                indicator.ActivateImage();  // Make the indicators on the player visible when they enter the campfire range
            }


            // Check if both players are in the campfire
            if (players.Count >= 2)
            {
                ChooseLevelInfoToDisplay(true); // Activate the text when both players are present

                if (InteractionMusic != null)
                {
                    InteractionMusic.Play();    // Play Music
                }

                fModLevelInteractionEvent.start();
                if (SaveManager.instance.save.levelsComplete >= levelCompletionRequirements)
                {
                    //unCompletedLevelInfo.SetActive(true);


                    for (int i = 0; i < playerIndicatorScripts.Count; i++)
                    {
                        playerIndicatorScripts[i].ChangeImage();
                    }
                }
            }
        }
    }