示例#1
0
        void Awake()
        {
            Instance            = this;
            currentTime         = 0f;
            _secondsToNextPhase = secondsOfPhases [GetCurrentState() - 1];

            _clockDescriptionTexts          = GameObject.FindGameObjectWithTag("Canvas").transform.GetChild(4).GetComponentsInChildren <Text> ();
            _clockDescriptionTexts [0].text = "Welcome!\n\nYou woke up in this Village...\n\nExplore it! Meet the other villagers! Chat with them!\n\nTo dismiss this panel, click the button below.";
            _clockDescriptionTexts[1].transform.parent.gameObject.SetActive(false);
            _hourglass = GameObject.FindGameObjectWithTag("Canvas").transform.GetChild(4).GetChild(2);
            _sun       = GetComponentInChildren <Light>();
            _moon      = transform.GetChild(1);
            _moon.transform.localPosition = new Vector3(0, 0, moonDistance);
            _moon.transform.localScale    = new Vector3(moonScale, moonScale, moonScale);
            _stars       = GetComponentInChildren <ParticleSystem> ();
            _audioSource = GetComponent <AudioSource> ();

            pivotPoint.localRotation = Quaternion.Euler(0f, 0f, 360f * -currentTime);
        }
示例#2
0
        /// <summary>
        /// The front fabrik prevents player from going out at night, and conceals the player that plays a role during night.
        /// </summary>
        bool FrontFabrikActive()
        {
            PlayerManager pM = _owner.GetComponent <PlayerManager> ();

            if (!pM.isAlive)
            {
                return(false);
            }

            bool frontFabricActive = false;

            if (DayNightCycle.GetCurrentState() == 5)
            {
                if (!ownerInside && _owner == PlayerManager.LocalPlayerInstance)
                {
                    pM.isAlive = false;
                }
                else
                {
                    frontFabricActive = true;
                }
            }
            else if (DayNightCycle.GetCurrentState() == 6 && pM.role != "Seer")
            {
                frontFabricActive = true;
            }
            else if (DayNightCycle.GetCurrentState() == 7 && pM.role != "Werewolf")
            {
                frontFabricActive = true;
            }
            else if (DayNightCycle.GetCurrentState() == 8 && pM.role != "Witch")
            {
                frontFabricActive = true;
            }

            return(frontFabricActive);
        }
示例#3
0
        /// <summary>
        /// All the buttons and images on the front panel are udpated here.
        /// </summary>
        void UpdateOwnerInfo()
        {
            PlayerManager ownerPM       = _owner.GetComponent <PlayerManager> ();
            string        displayedRole = "";

            if (ownerPM.isDiscovered)
            {
                displayedRole = ownerPM.role;
            }
            else
            {
                displayedRole = "Card";
            }
            Sprite roleSprite = Resources.Load("Cards/" + displayedRole, typeof(Sprite)) as Sprite;

            if (roleSprite != null)
            {
                _roleImage.sprite = roleSprite;
            }
            else
            {
                Debug.Log("No image was found for " + roleSprite.name);
            }

            foreach (GameObject btn in _actionButtons)
            {
                btn.SetActive(false);
            }

            if (ownerPM.isAlive)
            {
                _deadImage.SetActive(false);
                _mayorImage.gameObject.SetActive(true);
                if (VoteManager.Instance != null && _owner.name == VoteManager.Instance.mayorName)
                {
                    _mayorImage.sprite = isMayor [0];
                }
                else
                {
                    _mayorImage.sprite = isMayor [1];
                }

                PlayerManager localPM = PlayerManager.LocalPlayerInstance.GetComponent <PlayerManager> ();
                if (localPM.isAlive)
                {
                    if (DayNightCycle.GetCurrentState() == 2 || DayNightCycle.GetCurrentState() == 3 || (DayNightCycle.GetCurrentState() == 7 && localPM.role == "Werewolf"))
                    {
                        if (_owner.name != localPM.votedPlayer)
                        {
                            _actionButtons [0].SetActive(true);
                        }
                    }
                    if (DayNightCycle.GetCurrentState() == 6 && localPM.seerRevealingAvailable && ownerPM.isDiscovered == false)
                    {
                        _actionButtons [3].SetActive(true);
                    }

                    if (_owner.name == VoteManager.Instance.mostVotedPlayer)
                    {
                        _mostVotedImage.SetActive(true);
                        if (DayNightCycle.GetCurrentState() == 8 && localPM.lifePotionAvailable)
                        {
                            _actionButtons [1].SetActive(true);
                        }
                    }
                    else
                    {
                        _mostVotedImage.SetActive(false);
                        if (DayNightCycle.GetCurrentState() == 8 && localPM.deathPotionAvailable)
                        {
                            _actionButtons [2].SetActive(true);
                        }
                    }
                }
            }
            else
            {
                _deadImage.SetActive(true);
                _mayorImage.gameObject.SetActive(false);
                _mostVotedImage.SetActive(false);
            }
        }
示例#4
0
        /// <summary>
        /// This function handles the nomination of the Mayor, the killing of the Villager or Werewolf vote and the switching of Chat canals
        /// </summary>
        void VoteSystem()
        {
            if (_formerState != DayNightCycle.GetCurrentState())
            {
                _formerState = DayNightCycle.GetCurrentState();
                DayNightCycle.Instance.UpdateClockText(true);

                if (_formerState == 1)
                {
                    // This prevents the Witch from being detected because she's outside before anyone else
                    if (_localPM.role == "Witch")
                    {
                        _localPM.GoHome();
                    }
                    if (mostVotedPlayer != "")
                    {
                        if (PhotonNetwork.isMasterClient)
                        {
                            GameObject[] players = GameObject.FindGameObjectsWithTag("Player");
                            foreach (GameObject player in players)
                            {
                                if (player.name == mostVotedPlayer)
                                {
                                    player.GetComponent <PhotonView> ().RPC("KillPlayer", PhotonTargets.All, new object[] { });
                                }
                                else
                                {
                                    player.GetComponent <PhotonView> ().RPC("ResetPlayerVote", PhotonTargets.All, new object[] { });
                                }
                            }
                        }
                    }
                    else
                    {
                        _localPM.votedPlayer = "";
                    }
                    _localPM.gameObject.GetComponent <Light> ().enabled = false;
                    _minimapHidingSeal.SetActive(false);
                    countDay++;
                    if (!_localPM.isAlive || _localPM.role == "Werewolf")
                    {
                        ChatManager.Instance.SwitchVillagerToWerewolf(true);
                    }
                    else
                    {
                        ChatManager.Instance.SwitchVillagerToWerewolf(false);
                    }
                }
                else if (_formerState == 2)
                {
                    if (countDay > 1 && singleVotes.Find(v => v.reason == "Mayor") == null)
                    {
                        CheckOrSetMayor();
                    }

                    if (_localPM.isAlive)
                    {
                        resetVoteButton.SetActive(true);
                    }

                    _formerState = DayNightCycle.GetCurrentState();
                }
                else if (_formerState == 4)
                {
                    if (countDay == 1 && PhotonNetwork.isMasterClient)
                    {
                        mayorName = mostVotedPlayer;
                    }
                    else if (countDay > 1 && _localPM.gameObject.name == mostVotedPlayer)
                    {
                        _localPM.isAlive = false;
                    }

                    resetVoteButton.SetActive(false);
                }
                else if (_formerState == 5)
                {
                    _localPM.votedPlayer = "";
                    _localPM.gameObject.GetComponent <Light> ().enabled = true;
                    countNight++;
                    if (!_localPM.isAlive || _localPM.role == "Werewolf")
                    {
                        ChatManager.Instance.SwitchVillagerToWerewolf(true);
                    }
                    else
                    {
                        ChatManager.Instance.SwitchVillagerToWerewolf(false);
                    }

                    // Each night, the Seer can reveal someone's role
                    if (_localPM.role == "Seer")
                    {
                        _localPM.seerRevealingAvailable = true;
                    }

                    // The first night, all Werewolves discover each other
                    if (countNight == 1 && _localPM.role == "Werewolf")
                    {
                        GameObject[] players = GameObject.FindGameObjectsWithTag("Player");
                        foreach (GameObject player in players)
                        {
                            PlayerManager pM = player.GetComponent <PlayerManager> ();
                            if (pM.role == "Werewolf")
                            {
                                pM.isDiscovered = true;
                            }
                        }
                    }
                }
                else if (_formerState == 6)
                {
                    if (_localPM.isAlive && _localPM.role != "Seer")
                    {
                        _minimapHidingSeal.SetActive(true);
                    }
                }
                else if (_formerState == 7)
                {
                    _audioSource.PlayOneShot(_audioSource.clip);                      // wolf howling

                    // This prevents the Seer from being detected because she's outside when the Werewolves go out
                    if (_localPM.role == "Seer")
                    {
                        _localPM.GoHome();
                        _minimapHidingSeal.SetActive(true);
                    }
                    else if (_localPM.role == "Werewolf")
                    {
                        _minimapHidingSeal.SetActive(false);
                        if (_localPM.isAlive)
                        {
                            resetVoteButton.SetActive(true);
                        }
                    }

                    // During this phase, the Little Girl can spy the Werewolves by clicking the button "Spy"
                    if (_localPM.role == "LittleGirl" && _localPM.isAlive)
                    {
                        _spyButton.SetActive(true);
                    }
                }
                else if (_formerState == 8)
                {
                    // This prevents Werewolves from being detected because they are outside when the Witch go out
                    if (_localPM.role == "Werewolf")
                    {
                        _localPM.GoHome();
                        _minimapHidingSeal.SetActive(true);
                        resetVoteButton.SetActive(false);
                    }

                    if (_localPM.role == "LittleGirl")
                    {
                        _minimapHidingSeal.SetActive(true);
                        _localPM.littleGirlSpying = false;
                        _spyButton.SetActive(false);
                    }

                    if (_localPM.role == "Witch")
                    {
                        _minimapHidingSeal.SetActive(false);
                    }
                }
            }
        }
示例#5
0
        /// <summary>
        /// Searches through all the players, updates the voted player list and check if there is a most voted player.
        /// </summary>
        void RefreshVotedPlayers()
        {
            _votedPlayers.Clear();

            GameObject[] players = GameObject.FindGameObjectsWithTag("Player");
            _infoText.text = "";
            foreach (GameObject player in players)
            {
                PlayerManager pM = player.GetComponent <PlayerManager> ();
                if (pM.votedPlayer != "" && pM.isAlive)
                {
                    _votedPlayers.Add(pM.votedPlayer);
                    // Double vote of the Mayor doesn't count during the night if he's a Werewolf!
                    if (DayNightCycle.GetCurrentState() < 5 && player.name == mayorName)
                    {
                        _votedPlayers.Add(pM.votedPlayer);
                    }
                }
                if (player.name == mayorName)
                {
                    _infoText.text += "[M] ";
                }
                _infoText.text += PlayerManager.GetProperName(player.name) + " > " + PlayerManager.GetProperName(pM.votedPlayer) + "\n";
            }

            // This part checks if there is a most voted player
            if (_votedPlayers.Count == 0)
            {
                mostVotedPlayer = "";
            }
            else
            {
                int           previousCount    = _votedPlayers.FindAll(p => p == _votedPlayers [0]).Count;
                List <string> mostVotedPlayers = new List <string> ();
                mostVotedPlayers.Add(_votedPlayers [0]);

                for (int i = 1; i < _votedPlayers.Count; i++)
                {
                    int newCount = _votedPlayers.FindAll(p => p == _votedPlayers [i]).Count;
                    if (newCount > previousCount)
                    {
                        mostVotedPlayers.Remove(_votedPlayers [i - 1]);
                        mostVotedPlayers.Add(_votedPlayers [i]);
                        previousCount = newCount;
                    }
                    else if (newCount == previousCount && !mostVotedPlayers.Contains(_votedPlayers [i]))
                    {
                        mostVotedPlayers.Add(_votedPlayers [i]);
                    }
                }

                if (mostVotedPlayers.Count > 1)
                {
                    mostVotedPlayer = "";
                }
                else
                {
                    mostVotedPlayer = mostVotedPlayers [0];
                }
            }
        }