/// <summary> /// Executes this instance. /// </summary> internal override void Execute(Level Level) { if (this.Data != null) { if (!this.Data.PremiumCurrency) { // if (string.IsNullOrEmpty(this.Data.WarRefResource)) { int Cost = GamePlayUtil.GetResourceCost(this.Data, this.Count, this.Data.VillageType); if (Level.Player.HasEnoughDiamonds(this.Count)) { if (Level.Player.GetAvailableResourceStorage(this.Data) >= this.Count) { Level.Player.UseDiamonds(this.Count); Level.Player.Resources.Add(this.Data, this.Count); if (this.Command != null) { if (this.Command.ExecuteSubTick == -1) { this.Command.ExecuteSubTick = this.ExecuteSubTick; try { if (!this.Command.IsServerCommand) { this.Command.Execute(Level); } } catch (Exception Exception) { Logging.Error(this.GetType(), "An error has been throwed when the process of command type " + this.Command.Type + ". " + Exception); } } } } } #if DEBUG else { Logging.Error(this.GetType(), "Unable to buy resources. You don't have enough diamond."); } #endif } } #if DEBUG else { Logging.Error(this.GetType(), "Unable to buy resources. Premium resources is not buyable."); } #endif } #if DEBUG else { Logging.Error(this.GetType(), "Unable to buy resources. Data is null or invalid."); } #endif }
internal override void Execute() { if (this.Data != null) { if (!this.Data.PremiumCurrency) { // if (string.IsNullOrEmpty(this.Data.WarRefResource)) { Level Level = this.Device.GameMode.Level; int Cost = GamePlayUtil.GetResourceCost(this.Data, this.Count, this.Data.VillageType); if (Level.Player.HasEnoughDiamonds(Cost)) { if (Level.Player.GetAvailableResourceStorage(this.Data) >= this.Count) { Level.Player.UseDiamonds(Cost); Level.Player.Resources.Add(this.Data, this.Count); if (this.Command != null) { try { if (!this.Command.IsServerCommand) { this.Command.Execute(); /* * Logging.Info(this.GetType(), "Embedded Command is handled! (" + this.Command.Type + ")"); */ } else { Logging.Error(this.GetType(), "Unable to execute server command as embedded command! (" + this.Command.Type + ")"); } } catch (Exception Exception) { Logging.Error(this.GetType(), "An error has been throwed when the process of command type " + this.Command.Type + ". " + Exception); } } } } else { Logging.Error(this.GetType(), "Unable to buy resources. The player don't have enough diamond."); } } } else { Logging.Error(this.GetType(), "Unable to buy resources. Premium resources is not buyable."); } } else { Logging.Error(this.GetType(), "Unable to buy resources. Data is null or invalid."); } }