예제 #1
0
        public Guest()
            : base()
        {
            // When a guest is first created, give them a random name!
            Name = NameGenerator.NextName();

            // Give this guest a wallet with 100 bucks
            Wallet = new Wallet();

            // Give an empty inventory
            Inventory = new GuestInventory();

            // Give a guest basics stats
            foreach (StatType statType in StatTypes.FindByTarget(GameObjectType.Guest))
            {
                float asd = statType.GetBaseValue(this);

                CurrentStats.Add(new Stat()
                {
                    Type  = statType,
                    Value = asd
                });
            }

            Desires = new ObservableQueue <Desire>();
            // React when an item is added or removed from the queue
            Desires.CollectionChanged += Guest_DesiresChanged;

            RefreshDesires();
        }
예제 #2
0
        private void RefreshStats(Expression <Func <GameResult, bool> > filter = null)
        {
            var expr = filter ?? GetFilterExpression();

            Task.Run(() => CurrentStats.RefreshFrom(dbContext, expr));
            Task.Run(() => this.totals.Update(dbContext, expr));
        }
예제 #3
0
 void Start()
 {
     this.currentStats        = gameObject.AddComponent(typeof(CurrentStats)) as CurrentStats;
     this.currentStats.health = 200;
     this.healthBar           = GetComponentInChildren <HealthBar>();
     this.healthBar.SetMaxHealth(this.currentStats.health);
 }
예제 #4
0
 public void ResetSessionStats(Stats stats)
 {
     SessionStats = stats;
     InitialStats = CurrentStats.Copy();
     InitialStats.GamesStarted         -= SessionStats.GamesStarted;
     InitialStats.GamesFinished        -= SessionStats.GamesFinished;
     InitialStats.TimesCrewmate        -= SessionStats.TimesCrewmate;
     InitialStats.TimesImpostor        -= SessionStats.TimesImpostor;
     InitialStats.CrewmateVoteWins     -= SessionStats.CrewmateVoteWins;
     InitialStats.CrewmateTaskWins     -= SessionStats.CrewmateTaskWins;
     InitialStats.ImpostorKillWins     -= SessionStats.ImpostorKillWins;
     InitialStats.ImpostorVoteWins     -= SessionStats.ImpostorVoteWins;
     InitialStats.ImpostorSabotageWins -= SessionStats.ImpostorSabotageWins;
 }
예제 #5
0
        /// <summary>
        /// Odbiera nagrodę od wydziału za wykonaną pracę
        /// </summary>
        /// <param name="departmentIndex"></param>
        public void GetRewardFromDepartment(int departmentIndex)
        {
            // Lista z poszczególnymi wartościami zasobów do odbioru
            List <int> payloadList = new List <int>
            {
                DepartmentList[departmentIndex].GetMoneyPayload(),
                DepartmentList[departmentIndex].GetPrestigePointsPayload(),
                DepartmentList[departmentIndex].GetStudentsPayload(),
                DepartmentList[departmentIndex].GetSciencePapersPayload(),
                DepartmentList[departmentIndex].GetInventionsPayload()
            };

            CurrentStats.Update(payloadList);
        }
예제 #6
0
        /// <summary>
        /// Zatrudniania pracownika na wydziale
        /// </summary>
        /// <param name="departmentIndex"></param>
        public void HireWorkerInDepartment(int departmentIndex)
        {
            // Lista z wartościami poszczególnych zasobów do zabrania
            List <int> priceList = new List <int>
            {
                DepartmentList[departmentIndex].GetCurrentMoneyPrice() * (-1),
                DepartmentList[departmentIndex].GetCurrentPrestigePointsPrice() * (-1),
                0,
                0,
                0
            };

            CurrentStats.Update(priceList);
            DepartmentList[departmentIndex].HireNewWorker();
        }
예제 #7
0
        /// <summary>
        /// Wywołuje event katastrofę
        /// </summary>
        /// <param name="eventID"></param>
        public void SummonGameEvent(int eventID)
        {
            IncomingEventForm = new FormGameEvent(eventID, CurrentStats.GetAvailableStatsList());
            IncomingEventForm.ShowDialog();
            List <int> penaltyList = new List <int>
            {
                0,
                0,
                0,
                0,
                0
            };

            switch (IncomingEventForm.SelectedPenaltyStatName)
            {
            case "Pieniądze":
            {
                penaltyList[0] = -1 * (CurrentStats.MoneyCollected * IncomingEventForm.SelectedPenaltyPercentage / 100);
                break;
            }

            case "Prestiż":
            {
                penaltyList[1] = -1 * (CurrentStats.PrestigePointsCollected * IncomingEventForm.SelectedPenaltyPercentage / 100);
                break;
            }

            case "Studenci":
            {
                penaltyList[2] = -1 * (CurrentStats.StudentsCollected * IncomingEventForm.SelectedPenaltyPercentage / 100);
                break;
            }

            case "Prace naukowe":
            {
                penaltyList[3] = -1 * (CurrentStats.SciencePapersCollected * IncomingEventForm.SelectedPenaltyPercentage / 100);
                break;
            }

            case "Wynalazki":
            {
                penaltyList[4] = -1 * (CurrentStats.InventionsCollected * IncomingEventForm.SelectedPenaltyPercentage / 100);
                break;
            }
            }
            CurrentStats.Update(penaltyList);
            IncomingEventForm.Dispose();
        }
예제 #8
0
        private void RefreshStats(Expression <Func <ArenaSession, bool> > filter = null)
        {
            needStatsRefresh = true;
            var expr = filter ?? GetFilterExpression();

            Application.Current.Dispatcher.BeginInvoke(
                (Action)(() =>
            {
                if (needStatsRefresh)
                {
                    needStatsRefresh = false;
                    Task.Run(() => totals.Update(dbContext, expr));
                    Task.Run(() => CurrentStats.RefreshFrom(dbContext, expr));
                }
            }), DispatcherPriority.ContextIdle);
        }
예제 #9
0
    void Start()
    {
        if (!this.IsEnemy())
        {
            this.soldierConfig = SkillTreeManager.current.GetSoldierConfigWithUpgrades(this.soldierConfig);
        }

        this.body         = GetComponent <Rigidbody2D>();
        this.currentStats = gameObject.AddComponent(typeof(CurrentStats)) as CurrentStats;
        this.currentStats.currentSpeed = this.soldierConfig.maxSpeed;
        this.currentStats.health       = this.soldierConfig.health;
        this.timeOfPreviousAttack      = 0;
        this.relativAttackPosition     = this.transform.Find("Body").transform.localPosition;
        this.earnerGameObject          = GameObject.Find("Earner");
        this.healthBar = GetComponentInChildren <HealthBar>();
        this.healthBar.SetMaxHealth(this.soldierConfig.health);
        this.animator             = GetComponent <Animator>();
        this.nextSoldiersToAttack = new List <RaycastHit2D>();
        this.bloodSplashObject    = this.transform.Find("BloodSplash").gameObject;
    }
예제 #10
0
 void Start()
 {
     playerStats = PlayerManager.instance.player.GetComponent <CurrentStats> ();
 }
예제 #11
0
 public MemberState(int id, IStats baseStats, int initialHp)
 {
     MemberId   = id;
     _baseStats = baseStats;
     _counters[TemporalStatType.HP.ToString()]               = new BattleCounter(TemporalStatType.HP, initialHp, () => CurrentStats.MaxHp());
     _counters[TemporalStatType.Shield.ToString()]           = new BattleCounter(TemporalStatType.Shield, 0, () => CurrentStats.Toughness() * 2);
     _counters[TemporalStatType.TurnStun.ToString()]         = new BattleCounter(TemporalStatType.TurnStun, 0, () => int.MaxValue);
     _counters[TemporalStatType.CardStun.ToString()]         = new BattleCounter(TemporalStatType.CardStun, 0, () => int.MaxValue);
     _counters[TemporalStatType.Evade.ToString()]            = new BattleCounter(TemporalStatType.Evade, 0, () => int.MaxValue);
     baseStats.ResourceTypes?.ForEach(r => _counters[r.Name] = new BattleCounter(r.Name, r.StartingAmount, () => r.MaxAmount));
     _counters["None"] = new BattleCounter("None", 0, () => 0);
     _counters[""]     = new BattleCounter("", 0, () => 0);
 }
예제 #12
0
 public void TakeRawDamage(int amount) => ChangeHp(-amount * CurrentStats.Damagability());
예제 #13
0
        public void Simulate()
        {
            if (authoritativeTimeline.Last == null)     // Not initialized yet
            {
                return;
            }

            logger.Debug("Simulate: time: {0}, commands: {1}"
                         , time
                         , nextCommandFrame != null ? nextCommandFrame.Commands.Count : 0);

            int lastAcknowledgedCommandTime = -1;       // Dequeue acknowledge commands and get last time that command is predicted

            if (lastAcknowledgedCommandSeq != null)
            {
                lastAcknowledgedCommandTime = DequeueAcknowledgedCommands();
            }

            if (lastAcknowledgedCommandTime >= 0)
            {
                var authoritativeSnapshot = authoritativeTimeline.Last.Snapshot;

                var predictiveTimepoint = predictiveTimeline.InterpolatePoint(lastAcknowledgedCommandTime);
                if (predictiveTimepoint == null)
                {
                    throw new InvalidOperationException();          // TODO: Message
                }
                var currentSnapshot = predictiveTimeline.Last.Snapshot;

                if (!authoritativeSnapshot.IsApproximate(predictiveTimepoint.Snapshot))        // Rollback and replay
                {
                    predictiveTimeline = new Timeline();
                    predictiveTimeline.AddPoint(lastAcknowledgedCommandTime, authoritativeSnapshot);

                    RecoverSnapshot((SimulatorSnapshot)authoritativeSnapshot);

                    // TODO: Use SceneDesc.ReconciliationDeltaTime to optimize replay performance
                    var deltaTime = Scene.Desc.SimulationDeltaTime;
                    for (var replayTime = lastAcknowledgedCommandTime; replayTime < time; replayTime += deltaTime)
                    {
                        if (replayTime + deltaTime > time)
                        {
                            deltaTime = time - replayTime;
                        }

                        Simulate(from command in unacknowledgedCommands
                                 where command.Time >= replayTime && command.Time < replayTime + deltaTime
                                 select command);

                        predictiveTimeline.AddPoint(replayTime + deltaTime, CreateSnapshot());
                    }
                }

                // TODO: Get jitter detail for analysis
                if (!currentSnapshot.IsApproximate(predictiveTimeline.Last.Snapshot))
                {
                    logger.Debug("Correction done with possible jitter");
                }
            }

            if (nextCommandFrame != null || predictiveTimeline != null)
            {
                SimulatorSnapshot snapshot;
                if (predictiveTimeline != null)
                {
                    snapshot = (SimulatorSnapshot)predictiveTimeline.InterpolatePoint(time).Snapshot;

                    logger.Debug("RecoverSnapshot from predictive timeline");
                }
                else
                {
                    snapshot = (SimulatorSnapshot)authoritativeTimeline.InterpolatePoint(time).Snapshot;

                    predictiveTimeline = new Timeline();
                    predictiveTimeline.AddPoint(time, snapshot);

                    logger.Debug("RecoverSnapshot from authoritative timeline");
                }

                RecoverSnapshot(snapshot);

                Simulate(nextCommandFrame != null ? nextCommandFrame.Commands : null);

                snapshot = CreateSnapshot();

                if (unacknowledgedCommands.Count > 0)
                {
                    predictiveTimeline.AddPoint(time + Scene.Desc.SimulationDeltaTime, snapshot);
                    nextConvergenceTime = time + Scene.Desc.ConvergenceTime;

                    logger.Debug("Simulate and CreateSnapshot for predictive timeline");
                }
                else if (time < nextConvergenceTime)
                {
                    /*
                     * var authoritativeSnapshot = authoritativeTimeline.Last.Snapshot;
                     *
                     * // TODO: Need a better convergence algorithm
                     * //snapshot = (SimulatorSnapshot)((ISnapshotArgs)snapshot).Interpolate(authoritativeSnapshot, Scene.Desc.ConvergenceRate);
                     *
                     * if (authoritativeSnapshot.IsApproximate(snapshot))
                     * {
                     *  logger.Debug("All commands are acknowledged and convergence is done in advance: {0} < {1}", time, nextConvergenceTime);
                     *
                     *  snapshot = (SimulatorSnapshot)authoritativeSnapshot;
                     *
                     *  predictiveTimeline = null;
                     *  nextConvergenceTime = null;
                     * }
                     * else
                     * {
                     *  predictiveTimeline.AddPoint(time + Scene.Desc.SimulationDeltaTime, snapshot);
                     *
                     *  logger.Info("All commands are acknowledged and convergence predictive timeline");
                     * }
                     */
                }
                else
                {
                    predictiveTimeline  = null;
                    nextConvergenceTime = null;

                    snapshot = (SimulatorSnapshot)authoritativeTimeline.InterpolatePoint(time + Scene.Desc.SimulationDeltaTime).Snapshot;

                    logger.Debug("RecoverSnapshot from authoritative timeline and remove predictive timeline");
                }

                RecoverSnapshot(snapshot);
            }
            else
            {
                var snapshot = (SimulatorSnapshot)authoritativeTimeline.InterpolatePoint(time + Scene.Desc.SimulationDeltaTime).Snapshot;

                logger.Debug("RecoverSnapshot from authoritative timeline");

                RecoverSnapshot(snapshot);
            }

            CurrentStats.Time         = time;
            CurrentStats.DeltaTime    = Scene.Desc.SimulationDeltaTime;
            CurrentStats.SimulateTime = DateTime.UtcNow;
            CurrentStats.AdvanceStats(StatsFrames.Current);

            Scene.OnLateUpdate();

            StatsFrames.CreateNextFrame();
            StatsFrames.Current.AddStats <ClientSimulatorStats>();
            CurrentStats.CreateTime = DateTime.UtcNow;

            time += Scene.Desc.SimulationDeltaTime;

            commandFrame     = nextCommandFrame;
            nextCommandFrame = null;

            lastAcknowledgedCommandSeq = null;
        }