private Wind GetNewWindPreferences() { string seasonType = this.seasonService.GetCurrentSeason().SeasonDefinition.SeasonType; Droplist droplist; if (!this.droplistDatabase.TryGetValue("DroplistWindDirectionChange" + seasonType + this.weatherDifficulty, out droplist)) { Diagnostics.LogError("Fail getting wind direction droplist."); return(this.Wind); } Droplist droplist2; if (!this.droplistDatabase.TryGetValue("DroplistWindStrengthChange" + seasonType + this.weatherDifficulty, out droplist2)) { Diagnostics.LogError("Fail getting wind strength droplist."); return(this.Wind); } Droplist droplist3; DroppableInteger droppableInteger = droplist.Pick(null, out droplist3, new object[0]) as DroppableInteger; DroppableInteger droppableInteger2 = droplist2.Pick(null, out droplist3, new object[0]) as DroppableInteger; WorldOrientation worldOrientation = (WorldOrientation)this.Wind.Direction; if (worldOrientation > WorldOrientation.SouthEast || worldOrientation < WorldOrientation.East) { Diagnostics.LogError("ELCP [Server]: Wind orientation {0} at turn {1} is invalid for some reason! Resetting to WorldOrientation.East", new object[] { worldOrientation, this.game.Turn }); worldOrientation = WorldOrientation.East; } worldOrientation = worldOrientation.Rotate(droppableInteger.Value); return(new Wind((int)worldOrientation, droppableInteger2.Value)); }
protected override bool Initialize(QuestBehaviour questBehaviour) { if (string.IsNullOrEmpty(this.ResourceName)) { string text; if (questBehaviour.TryGetQuestVariableValueByName <string>(this.ResourceNameVarName, out text)) { if (string.IsNullOrEmpty(text)) { Diagnostics.LogError("Resource name is null or empty, quest variable (varname: '{0}')", new object[] { this.ResourceNameVarName }); return(false); } this.ResourceName = text; } else { IDroppable droppable; if (!questBehaviour.TryGetQuestVariableValueByName <IDroppable>(this.ResourceNameVarName, out droppable)) { Diagnostics.LogError("Cannot retrieve quest variable (varname: '{0}')", new object[] { this.ResourceNameVarName }); return(false); } DroppableString droppableString = droppable as DroppableString; if (droppableString == null || string.IsNullOrEmpty(droppableString.Value)) { Diagnostics.LogError("Resource name is null or empty, quest variable (varname: '{0}')", new object[] { this.ResourceNameVarName }); return(false); } this.ResourceName = droppableString.Value; } } if (this.Amount == -1) { QuestRegisterVariable questRegisterVariable; IDroppable droppable2; if (questBehaviour.TryGetQuestVariableValueByName <QuestRegisterVariable>(this.AmountVarName, out questRegisterVariable)) { if (questRegisterVariable == null) { Diagnostics.LogError("QuestRegisterVariable is null, quest variable (varname: '{0}')", new object[] { this.ResourceNameVarName }); return(false); } this.Amount = questRegisterVariable.Value; } else if (questBehaviour.TryGetQuestVariableValueByName <IDroppable>(this.AmountVarName, out droppable2)) { if (droppable2 == null) { Diagnostics.LogError("QuestDropListVariableDefinition is null, quest variable (varname: '{0}')", new object[] { this.AmountVarName }); return(false); } DroppableInteger droppableInteger = droppable2 as DroppableInteger; if (droppableInteger == null) { Diagnostics.LogError("QuestDropListVariableDefinition does not contains a DroppableInteger (varname: '{0}')", new object[] { this.AmountVarName }); return(false); } this.Amount = droppableInteger.Value; } else { float f; if (!questBehaviour.TryGetQuestVariableValueByName <float>(this.AmountVarName, out f)) { Diagnostics.LogError("Cannot retrieve quest variable (varname: '{0}')", new object[] { this.AmountVarName }); return(false); } this.Amount = Mathf.RoundToInt(f); } } return(base.Initialize(questBehaviour)); }