コード例 #1
0
        /// <summary>
        /// Called when the score of player has been changed.
        /// </summary>
        public void ScoreChanged(int Count)
        {
            this.Score = Math.Max(this.Score + Count, 0);

            if (this.Score > this.MaxScore)
            {
                this.SetMaxScore(this.Score);
            }
        }
コード例 #2
0
        /// <summary>
        ///     Gets the speed up cost.
        /// </summary>
        public int GetSpeedUpCost(int RemainingTime)
        {
            if (RemainingTime <= 0)
            {
                return(0);
            }

            return(Math.Clamp((this.TotalTimeTakenSeconds + 600 * RemainingTime - 1) / this.TotalTimeTakenSeconds, 1, this.TotalTimeTakenSeconds / 600));
        }
コード例 #3
0
        /// <summary>
        /// Updates the logic tick.
        /// </summary>
        public void IncreaseTick()
        {
            if (this.Time == 0)
            {
                this.GameMode.Time = new Time();
                this.SendSectorState();
            }

            this.GameMode.UpdateSectorTicks(this.Time);

            if (this.Time == 10 * (this.Time / 10))
            {
                this.Queue.Commands.ForEach(Command =>
                {
                    Command.TickWhenGiven = Math.Clamp(Command.TickWhenGiven, Command.TickWhenGiven - 5, Command.TickWhenGiven + 20);
                    this.GameMode.CommandManager.AddCommand(Command);
                });

                this.SendSectorHeartbeat(this.Time / 10, this.GameMode.Checksum, this.Queue.Commands.ToArray());
            }

            this.Time.IncreaseTick();
        }
コード例 #4
0
        /// <summary>
        /// Executes this instance.
        /// </summary>
        public override byte Execute(GameMode GameMode)
        {
            Home   Home   = GameMode.Home;
            Player Player = GameMode.Player;

            TreasureChestData TreasureChestData = null;

            if (Home == null)
            {
                return(1);
            }

            if (Player == null)
            {
                return(2);
            }

            switch (this.ChestType)
            {
            case 2:
            {
                if (GameMode.Home.FreeChest != null)
                {
                    TreasureChestData = GameMode.Home.FreeChest.Data;

                    if (TreasureChestData == null)
                    {
                        goto End;
                    }
                }

                break;
            }

            case 3:
            {
                if (GameMode.Home.StarChest != null)
                {
                    TreasureChestData = GameMode.Home.StarChest.Data;

                    if (TreasureChestData == null)
                    {
                        goto End;
                    }
                }

                break;
            }

            case 4:
            {
                if (GameMode.Home.PurchasedChest != null)
                {
                    TreasureChestData = GameMode.Home.PurchasedChest.Data;

                    if (TreasureChestData == null)
                    {
                        goto End;
                    }
                }

                break;
            }
            }

            if (this.Reward.Spells == null)
            {
                goto End;
            }

            this.Reward.Spells.ForEach(Spell =>
            {
                if (!Spell.Data.NotInUse)
                {
                    Spell Existing = Home.GetSpellByData(Spell.Data);
                    int RefundGold;

                    if (Existing == null)
                    {
                        Existing = new Spell(Spell.Data);
                        Existing.SetShowNewIcon(true);

                        RefundGold = Existing.AddMaterial(Spell.Count);

                        Home.AddSpell(Existing);
                    }
                    else
                    {
                        RefundGold = Existing.AddMaterial(Spell.Count);
                    }

                    RefundGold *= Existing.Data.RarityData.GoldConversionValue;

                    if (RefundGold > 0)
                    {
                        if (Player.Gold + RefundGold > Player.MaxGold)
                        {
                            RefundGold = Math.Max(Player.MaxGold - Player.Gold, 0);
                        }

                        Player.AddFreeGold(RefundGold);
                    }
                }
            });

End:

            if (Player.Gold + this.Reward.Gold > Player.MaxGold)
            {
                this.Reward.Gold = Math.Max(Player.MaxGold - Player.Gold, 0);
            }

            if (this.Reward.Gold > 0)
            {
                Player.AddFreeGold(this.Reward.Gold);
            }

            if (this.Reward.Diamonds > 0)
            {
                Player.AddFreeDiamonds(this.Reward.Diamonds);
            }

            Home.SetClaimingReward(false);

            switch (this.ChestType)
            {
            case 2:
            {
                Home.FreeChestCollected();
                break;
            }

            case 3:
            {
                Home.CrownChestCollected();
                break;
            }

            case 4:
            {
                Home.PurchasedChestCollected();
                break;
            }
            }

            if (TreasureChestData != null)
            {
                Player.XpGainHelper(TreasureChestData.Exp);
            }

            return(0);
        }