public override bool Effect(CGObject s, Actor p1, Actor p2) { //GameManager.DebugLog("Modifying Resource"); //GameManager.DebugLog("Source is " + s.CGType); //GameManager.DebugLog("Parameter is " + p1.CGType); Resource target_resource = GetResourceFromParameter(target, s, p1, p2, 0); Resource op1 = GetResourceFromParameter(param1, s, p1, p2, 1); //Resource op2 = GetResourceFromParameter(param2, s, p1, p2, 2); // string type = target_resource.CGType; if (target_resource != null && op1 != null) { if (target_resource is ResourceBool && op1 is ResourceBool) { return(ModifyBool((ResourceBool)target_resource, (ResourceBool)op1, operation)); } if (target_resource is ResourceNumber && op1 is ResourceNumber) { return(ModifyNumber((ResourceNumber)target_resource, (ResourceNumber)op1, operation)); } if (target_resource is ResourceText && op1 is ResourceText) { return(ModifyText((ResourceText)target_resource, (ResourceText)op1, operation)); } } GameManager.DebugLog("Modify Resource failed"); return(false); }
// PUBLIC FUNCTIONS private void Iterate() { PhaseIterator++; // go to next phase GameManager.DebugLog(PhaseIterator.ToString()); if (PhaseIterator >= Phases_Size) { PhaseIterator = 0; // go to phase zero } }
public void AddResource(Resource resource, string target) { //GameManager.DebugLog("Game add resource to" + " :: " + target); //TODO fix this..... Actor actor = (Actor)FindObject(target); if (actor != null) { actor.AddResource(resource); GameManager.DebugLog("Adding " + resource.CGType + " to " + actor.CGType); } }
private bool CompareText(ResourceText target, ResourceText op1, CompareOperation operation) { switch (operation) { case CompareOperation.Equals: return(target.Value == op1.Value); default: GameManager.DebugLog("Error - operator invalid"); break; } return(false); }
private Resource GetByFixedValue(Resource res, int p) { bool bv = false; int iv = 0; string sv = null; if (p == 0) { GameManager.DebugLog("Eror - Invalid fixed value on Target resource"); } if (p == 1) { bv = bool_mod; iv = number_mod; sv = text_mod; } if (p == 2) { bv = bool_mod2; iv = number_mod2; sv = text_mod2; } Resource return_resource = null; if (res is ResourceAction) { GameManager.DebugLog("Modifying a Resource Action is not currently supported"); return(null); } else if (res is ResourceBool) { return_resource = new ResourceBool(); (return_resource as ResourceBool).Value = bv; } else if (res is ResourceNumber) { return_resource = new ResourceNumber(); (return_resource as ResourceNumber).Value = iv; } else if (res is ResourceText) { return_resource = new ResourceText(); (return_resource as ResourceText).Value = sv; } return(return_resource); }
private Resource GetBySelected(Resource res, Actor p1, string resource_type) { //string type = res.CGType; CGObject obj = p1.FindResource(resource_type); if (obj == null || !(obj is Resource)) { GameManager.DebugLog("Error (selected) - " + res.CGType + " not found in " + p1.CGType); return(null); } return(obj as Resource); }
private bool ModifyText(ResourceText target, ResourceText op1, ModifyOperation operation) { switch (operation) { case ModifyOperation.Set: target.Value = op1.Value; return(true); case ModifyOperation.Sum: target.Value += op1.Value; return(true); default: GameManager.DebugLog("Error - operator invalid"); break; } return(false); }
public override bool Effect(CGObject s, Actor p1, Actor p2) { IF.ParentAction = this; THEN.ParentAction = this; ELSE.ParentAction = this; if (IF.Run(s, p1, p2)) { THEN.Run(s, p1, p2); } else { GameManager.DebugLog("ELSE"); ELSE.Run(s, p1, p2); } return(true); }
public override bool Effect(CGObject s, Actor p1, Actor p2) { CGObject source_obj = GetFromSource(source, source_string, s, p1, p2); CGObject dest_obj = GetFromSource(destination, dest_string, s, p1, p2); if (source_obj != null && dest_obj != null) { GameManager.DebugLog("Transfering " + source_obj.CGType + " to " + dest_obj.CGType); if (manager.CommandTransferObject(source_obj as Actor, dest_obj as Actor) == true) { return(true); } } GameManager.DebugLog("Transfer Action Failed"); return(false); }
public bool Run(CGObject s, Actor p1, Actor p2) { manager = GameManager.GetInstance(); GameManager.DebugLog("Running Action: " + this.cgtype + " :: Armed: " + armed + ":: Enabled: " + Enabled);; if (Enabled && armed) { if (!persistent) { Disarm(); } return(Effect(s, p1, p2)); } return(false); }
private Resource GetBySource(Resource res, CGObject s, string resource_type) { //string type = res.CGType; if (s is Actor) { CGObject obj = (s as Actor).FindResource(resource_type); if (obj != null && (obj is Resource)) { return(obj as Resource); } GameManager.DebugLog("Error (source) -" + res.CGType + " not found in " + s.CGType); } GameManager.DebugLog("Error - " + s.CGType + " is not an Actor"); return(null); }
private Resource GetResourceFromParameter(ResourceSource param, CGObject s, Actor p1, Actor p2, int p) { CGObject obj = null; CGLibrary lib = manager.Library; string resource_type = "null"; if (p == 0) { obj = lib.GetResource(target_resource_index); resource_type = lib.GetResourceType(target_resource_index); //GameManager.DebugLog("Finding on target - " + resource_type); } if (p == 1) { obj = lib.GetResource(operation_resource_index); resource_type = lib.GetResourceType(operation_resource_index); //GameManager.DebugLog("Finding on operation - " + resource_type); } if (obj == null || !(obj is Resource)) { GameManager.DebugLog("Error - " + resource_type + " not found in library"); return(null); } Resource res = obj as Resource; switch (param) { case ResourceSource.FixedValue: return(GetByFixedValue(res, p)); case ResourceSource.Selected: return(GetBySelected(res, p1, resource_type)); case ResourceSource.Original: return(GetBySource(res, s, resource_type)); } return(null); }