private IEnumerator Gather (ResourceRoot source) { properties.currentResource = source.resource; print ("called"); while (!source.IsEmpty) { yield return StartCoroutine (MoveTo (new Vector3[1] { source.transform.position })); while(!properties.IsFull) { int unitsThatWillBeGathered = Mathf.Min(properties.unitsGatheredPerSecond, (properties.resourceCapacity - properties.currentResourceAmount)); properties.currentResourceAmount += source.GatherFromHere (unitsThatWillBeGathered); yield return new WaitForSeconds(1); } IResourceReceiver resourceReceiver = UnitController.GetClosestResourceReceiver (properties.currentResource, transform.position); if (resourceReceiver != null) { yield return StartCoroutine (MoveTo (new Vector3[1] { (resourceReceiver as StorageBuilding).transform.position })); properties.GiveResources (resourceReceiver); } else { StopAllCoroutines (); } } }
void Update() { if (Input.GetButtonUp("Fire2")) { Ray ray = MainCamera.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray.origin, ray.direction, out hit)) { ResourceRoot source = hit.transform.GetComponent <ResourceRoot>(); if (source != null) { foreach (BaseUnit unit in _selectedUnits) { unit.ActionCallBack(source); } return; } foreach (BaseUnit unit in _selectedUnits) { unit.ActionCallBack(hit.point); } } } }
public Object Load(string objectName, ResourceRoot type = ResourceRoot.Root) { Object ob = null; switch (type) { case ResourceRoot.Root: ob = Resources.Load(objectName); break; case ResourceRoot.PrefabRoot: ob = Resources.Load("Prefabs/" + objectName); break; case ResourceRoot.JsonRoot: ob = Resources.Load("Jsons/" + objectName); break; case ResourceRoot.TextureRoot: ob = Resources.Load("Textures/" + objectName); break; case ResourceRoot.AnimationRoot: ob = Resources.Load("Animations/" + objectName); break; case ResourceRoot.AudioRoot: ob = Resources.Load("Audios/" + objectName); break; } return(ob); }
public T Load <T> (string objectName, ResourceRoot type = ResourceRoot.Root) where T : Object { T ob = default(T); switch (type) { case ResourceRoot.Root: ob = Resources.Load <T>(objectName); break; case ResourceRoot.PrefabRoot: ob = Resources.Load <T>("Prefabs/" + objectName); break; case ResourceRoot.JsonRoot: ob = Resources.Load <T>("Jsons/" + objectName); break; case ResourceRoot.TextureRoot: ob = Resources.Load <T>("Textures/" + objectName); break; case ResourceRoot.AnimationRoot: ob = Resources.Load <T>("Animations/" + objectName); break; case ResourceRoot.AudioRoot: ob = Resources.Load <T>("Audios/" + objectName); break; } return(ob); }
private IEnumerator Gather(ResourceRoot source) { properties.currentResource = source.resource; print("called"); while (!source.IsEmpty) { yield return(StartCoroutine(MoveTo(new Vector3[1] { source.transform.position }))); while (!properties.IsFull) { int unitsThatWillBeGathered = Mathf.Min(properties.unitsGatheredPerSecond, (properties.resourceCapacity - properties.currentResourceAmount)); properties.currentResourceAmount += source.GatherFromHere(unitsThatWillBeGathered); yield return(new WaitForSeconds(1)); } IResourceReceiver resourceReceiver = UnitController.GetClosestResourceReceiver(properties.currentResource, transform.position); if (resourceReceiver != null) { yield return(StartCoroutine(MoveTo(new Vector3[1] { (resourceReceiver as StorageBuilding).transform.position }))); properties.GiveResources(resourceReceiver); } else { StopAllCoroutines(); } } }
/// <summary> /// Updates the font style for both face and value text. /// </summary> protected override void UpdateFontStyle() { for (int i = 0; i <= 4; i++) { TextBlock tb = ResourceRoot.FindName("_txt" + i) as TextBlock; CopyFontDetails(tb); } CopyFontDetails(textBlock); }
/// <summary> /// Updates the mark on the scale object. /// </summary> private void UpdateScaleMark() { Scale s = ResourceRoot.FindName("_scale") as Scale; if (s != null) { s.Mark = Mark; } }
public static ResourceIndexingQuery MapAddResourceCommand(ResourceRoot model) { return(new ResourceIndexingQuery ( model.Id , model.Name , model.Amount , model.Observations )); }
/// <summary> /// Initialize references to controls we expect to find in the child /// </summary> private void InitialiseRefs() { this.grabHandleCanvas = ResourceRoot.FindName("_grabHandle") as Canvas; this.grabHighlightShape = ResourceRoot.FindName("_grabHighlight") as Shape; this.textBlock = ResourceRoot.FindName("_text") as TextBlock; this.faceHighColorGradientStop = ResourceRoot.FindName("_colourRangeStart") as GradientStop; this.faceLowColorGradientStop = ResourceRoot.FindName("_colourRangeEnd") as GradientStop; this.needleHighColorGradientStop = ResourceRoot.FindName("_needleHighColour") as GradientStop; this.needleLowColorGradientStop = ResourceRoot.FindName("_needleLowColour") as GradientStop; }
/// <summary> /// Sets the text visibility to that of the TextVisibility property /// </summary> protected override void UpdateTextVisibility() { textBlock.Visibility = ValueTextVisibility; for (var i = 0; i < 5; i++) { if (ResourceRoot.FindName("_txt" + i) is TextBlock tb) { tb.Visibility = FaceTextVisibility; } } }
/// <summary> /// Set our text color to that of the TextColorProperty /// </summary> protected override void UpdateTextColor() { textBlock.Foreground = new SolidColorBrush(ValueTextColor); for (var i = 0; i < 5; i++) { if (ResourceRoot.FindName("_txt" + i) is TextBlock tb) { tb.Foreground = new SolidColorBrush(FaceTextColor); } } }
/// <summary> /// Set our text color to that of the TextColorProperty /// </summary> protected override void UpdateTextColor() { this.textBlock.Foreground = new SolidColorBrush(ValueTextColor); for (int i = 0; i < 5; i++) { TextBlock tb = ResourceRoot.FindName("_txt" + i) as TextBlock; if (tb != null) { tb.Foreground = new SolidColorBrush(FaceTextColor); } } }
/// <summary> /// Sets the text visibility to that of the TextVisibility property /// </summary> protected override void UpdateTextVisibility() { this.textBlock.Visibility = ValueTextVisibility; for (int i = 0; i < 5; i++) { TextBlock tb = ResourceRoot.FindName("_txt" + i) as TextBlock; if (tb != null) { tb.Visibility = FaceTextVisibility; } } }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } ResourceRoot = await _context.ResourceRoot.FirstOrDefaultAsync(m => m.Id == id); if (ResourceRoot == null) { return(NotFound()); } return(Page()); }
/// <summary> /// The format string for the value has changed /// </summary> protected override void UpdateTextFormat() { for (var i = 0; i <= 4; i++) { if (ResourceRoot.FindName("_txt" + i) is TextBlock tb && FaceTextFormat != null) { tb.Text = string.Format(FaceTextFormat, RealMinimum + (i * ((RealMaximum - RealMinimum) / 4))); } } if (textBlock != null) { textBlock.Text = IsGrabbed ? FormattedCurrentValue : FormattedValue; } }
/// <summary> /// The format string for the value has changed /// </summary> protected override void UpdateTextFormat() { for (int i = 0; i <= 4; i++) { TextBlock tb = ResourceRoot.FindName("_txt" + i) as TextBlock; if (tb != null && FaceTextFormat != null) { tb.Text = String.Format(FaceTextFormat, RealMinimum + (i * ((RealMaximum - RealMinimum) / 4))); } } if (this.textBlock != null) { this.textBlock.Text = this.IsGrabbed ? FormattedCurrentValue : FormattedValue; } }
public async Task <CommandResult> Handle(AddResourceCommand request, CancellationToken cancellationToken) { var model = new ResourceRoot(request); base.CommandResult.ValidationResult = await model.ValidateNewResourceAsync(_resourceReadOnlyRepository); if (base.HasErrors) { return(base.CommandResult); } _resourcePersistentRepository.Add(model); await _resourcePersistentRepository.SaveChangesAsync(); return(base.CommandResult); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } ResourceRoot = await _context.ResourceRoot.FindAsync(id); if (ResourceRoot != null) { _context.ResourceRoot.Remove(ResourceRoot); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public override void ActionCallback (ResourceRoot target) { StopAllCoroutines (); StartCoroutine (Gather (target)); }
public virtual void ActionCallback(ResourceRoot target) { }
public ResourceInitializingEvent(ResourceRoot resource) { Resource = resource; }
public virtual void ActionCallback (ResourceRoot target) {}
public override void ActionCallBack(ResourceRoot target) { StartCoroutine(Gather(target)); }
public override void ActionCallback(ResourceRoot target) { StopAllCoroutines(); StartCoroutine(Gather(target)); }