Esempio n. 1
0
        // You must call Initialize before calling this
        public static void UpdateUI(IterationData data)
        {
            UiHandler.ClearGraph();

            uint uTotalActiveUsers = 0;

            List<float> team1 = new List<float>();
            foreach (UserState state in Enum.GetValues(typeof(UserState)))
            {
                team1.Add(data.GetData(Team.Blue, state));
                if ((state == UserState.Active) || (state == UserState.Clicked))
                {
                    uTotalActiveUsers += data.GetData(Team.Blue, state);
                }
            }
            UiHandler.PushBack(team1.ToArray());

            List<float> team2 = new List<float>();
            foreach (UserState state in Enum.GetValues(typeof(UserState)))
            {
                team2.Add(data.GetData(Team.Red, state));
                if ((state == UserState.Active) || (state == UserState.Clicked))
                {
                    uTotalActiveUsers += data.GetData(Team.Red, state);
                }
            }
            UiHandler.PushBack(team2.ToArray());

            Team1Score.text = "" + data.GetScore(Team.Blue);
            Team2Score.text = "" + data.GetScore(Team.Red);
            Lottery.text = "" + data.uLottery;
            Users.text = "" + uTotalActiveUsers;
        }
Esempio n. 2
0
        // ITimeControlledObject
        public void Trigger()
        {
            IterationData data = new IterationData();
            data.uIteration = _cIterations;
            data.uThreshold = _uThreshold;

            _AddUsers();
            foreach (User user in _users)
            {
                UserState state = user.GetState(_uLottery);
                Team team = user.GetTeam();
                data.SetData(team, state);
            }

            _UpdateLottery(data);

            UiController.UpdateUI(data);

            _cIterations++;
        }
Esempio n. 3
0
        private void _UpdateLottery(IterationData data)
        {
            // Here we'll assume there's two teams.

            bool fBlueLoss = data.GetData(Team.Blue, UserState.Clicked) < _uThreshold;
            bool fRedLoss = data.GetData(Team.Red, UserState.Clicked) < _uThreshold;
            if (fBlueLoss && fRedLoss)
            {
                // Both teams lose
                // Grow the lottery even more, keep the threshold the same
                _uLottery = (uint) Math.Ceiling(_uLottery * Mechanics.c_dLotteryLossGrowth);
            }
            else if (fRedLoss)
            {
                // Blue wins
                _uBlueScore += _uLottery;
                _ResetGame();

            }
            else if (fBlueLoss)
            {
                // Red wins
                _uRedScore += _uLottery;
                _ResetGame();
            }
            else
            {
                // No winner
                _uThreshold = (uint) Math.Ceiling(_uThreshold * Mechanics.c_dThresholdGrowth);
                _uLottery = (uint)Math.Ceiling(_uLottery * Mechanics.c_dLotteryGrowth);
            }

            // Update the total lottery
            _uLotteryTotal += _uLottery;

            // Set the data set's scores
            data.SetScore(Team.Blue, _uBlueScore);
            data.SetScore(Team.Red, _uRedScore);
            data.uLottery = _uLottery;
        }