public static void RecordHighScore()
    {
        int score      = 0;
        int numPlayers = 0;

        for (int i = 0; i < DynamicData.MAX_PLAYERS; ++i)
        {
            SessionPlayer p = DynamicData.GetSessionPlayer(i);
            if (p.HasJoined)
            {
                ++numPlayers;
                score += ProgressData.GetPointsForPlayer(i);
            }
        }

        numPlayers = Mathf.Max(ProgressData.MostPlayersUsed, numPlayers);

        if (numPlayers > 1)
        {
            if (score > _highScoreCoop)
            {
                _highScoreCoop = score;
            }
        }
        else
        {
            if (score > _highScoreSinglePlayer)
            {
                _highScoreSinglePlayer = score;
            }
        }
    }
    private void playerScoreUpdated(LocalEventNotifier.Event e)
    {
        PlayerPointsReceivedEvent pointsEvent = e as PlayerPointsReceivedEvent;

        if (pointsEvent.PlayerIndex == this.PlayerIndex)
        {
            this.ScoreText.text = _prefix + ProgressData.GetPointsForPlayer(this.PlayerIndex);
        }
    }
Exemple #3
0
    private void menuSelection(LocalEventNotifier.Event e)
    {
        MenuElementSelectedEvent menuSelectionEvent = e as MenuElementSelectedEvent;

        if (menuSelectionEvent.Element == _menuElement)
        {
            if (this.SlotType != WeaponData.Slot.Empty)
            {
                if (ProgressData.GetPointsForPlayer(this.PlayerIndex) >= _cost)
                {
                    ProgressData.SmartSlot[] smartSlots = ProgressData.GetSmartSlots(this.PlayerIndex);
                    bool ok = true;
                    for (int i = 0; i < smartSlots.Length; ++i)
                    {
                        if (smartSlots[i].SlotType == this.SlotType)
                        {
                            ok = smartSlots[i].Level < WeaponData.GetMaxSlotsByType()[this.SlotType] || smartSlots[i].Ammo < WeaponData.GetSlotDurationsByType()[this.SlotType];
                            break;
                        }
                    }
                    if (ok)
                    {
                        this.SelectionImage.color = _normalColor;
                        ProgressData.ApplyPointsDeltaForPlayer(this.PlayerIndex, -_cost);
                        ProgressData.PickupSlot(this.PlayerIndex, this.SlotType);
                        GlobalEvents.Notifier.SendEvent(new PlayerPointsReceivedEvent(this.PlayerIndex, -_cost));
                        updateDisplay();
                    }
                    else
                    {
                        this.SelectionImage.color = this.NotEnoughColor;
                    }
                }
                else
                {
                    this.SelectionImage.color = this.NotEnoughColor;
                }
            }
            else if (ProgressData.GetHealthForPlayer(this.PlayerIndex) < ProgressData.MAX_HEALTH && ProgressData.GetPointsForPlayer(this.PlayerIndex) >= _cost)
            {
                this.SelectionImage.color = _normalColor;
                ProgressData.SetHealthForPlayer(this.PlayerIndex, ProgressData.GetHealthForPlayer(this.PlayerIndex) + 1);
                ProgressData.ApplyPointsDeltaForPlayer(this.PlayerIndex, -_cost);
                GlobalEvents.Notifier.SendEvent(new PlayerPointsReceivedEvent(this.PlayerIndex, -_cost));
                updateDisplay();
            }
            else
            {
                this.SelectionImage.color = this.NotEnoughColor;
            }
        }
    }
 void Start()
 {
     this.ScoreText.text = _prefix + ProgressData.GetPointsForPlayer(this.PlayerIndex);
 }