Ejemplo n.º 1
0
        /// <summary>
        /// Set the player possibility to win the game.
        /// </summary>
        private void SetWinnerPossibility()
        {
            int finishSpawnPointId = Random.Range(0, MapManager.Instance.FinishSpawnPoints.Length);

            if (_openedFinishPortal == null)
            {
                _openedFinishPortal = Instantiate(_finishPortalPrefab, MapManager.Instance.FinishSpawnPoints[finishSpawnPointId].transform.position, Quaternion.identity).GetComponent <FinishPortal>();

                // Open the door.
                List <Collider2D> colliders = new List <Collider2D>();
                colliders.Add(PossiblePlayerWinner.MyCollider);
                colliders.Add(PossiblePlayerWinner.MyOutsideCollider);
                _ghostHouseDoor.OpenDoor(colliders);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Check all player fragment count and open the finish portal if it is possible.
        /// TODO: This method is probably not on the correct place.
        /// </summary>
        private void CheckPlayerFragmentCount()
        {
            HasAnyPlayerAllFragments = false;

            // Go through all players.
            for (int i = 0; i < Players.Length; i++)
            {
                if (Players[i] == null || Players[i].PlayerComponent == null)
                {
                    continue;
                }

                if (Players[i].PlayerComponent.FragmentCounter >= MapManager.Instance.TotalFragmentCount)
                {
                    // Show notification.
                    if (PossiblePlayerWinner == null || PossiblePlayerWinner.Identifier != Players[i].PlayerComponent.Identifier)
                    {
                        UserInterfaceGameplayManager.Instance.NotificationPanelReference.ShowNotification("PACMAN IS WAITING FOR YOU, " + Players[i].PlayerComponent.Name.ToUpper() + "!");

                        // Apply winner aura effect.
                        StatusEffectManager.Instance.ApplyStatusEffect(Players[i].PlayerComponent, null, _winnerAuraEffect);
                    }

                    HasAnyPlayerAllFragments = true;

                    PossiblePlayerWinner = Players[i].PlayerComponent;
                    SetWinnerPossibility();

                    break;
                }
            }

            // Unless any of players have all fragments, destroy portal.
            if (!HasAnyPlayerAllFragments && _openedFinishPortal != null)
            {
                // Destroy the portal.
                Destroy(_openedFinishPortal.gameObject);
                _openedFinishPortal = null;

                UnsetWinnerPossibility();
                PossiblePlayerWinner = null;
            }
        }