Ejemplo n.º 1
0
	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 ();
			}
		}
	}
Ejemplo n.º 2
0
    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);
                }
            }
        }
    }
Ejemplo n.º 3
0
    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);
    }
Ejemplo n.º 4
0
    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);
    }
Ejemplo n.º 5
0
    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();
            }
        }
    }
Ejemplo n.º 6
0
 /// <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;
            }
        }
Ejemplo n.º 8
0
 public static ResourceIndexingQuery MapAddResourceCommand(ResourceRoot model)
 {
     return(new ResourceIndexingQuery
            (
                model.Id
                , model.Name
                , model.Amount
                , model.Observations
            ));
 }
Ejemplo n.º 9
0
 /// <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;
 }
Ejemplo n.º 10
0
 /// <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;
         }
     }
 }
Ejemplo n.º 11
0
 /// <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);
         }
     }
 }
Ejemplo n.º 12
0
 /// <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);
         }
     }
 }
Ejemplo n.º 13
0
 /// <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;
         }
     }
 }
Ejemplo n.º 14
0
        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());
        }
Ejemplo n.º 15
0
        /// <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;
            }
        }
Ejemplo n.º 16
0
        /// <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;
            }
        }
Ejemplo n.º 17
0
        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);
        }
Ejemplo n.º 18
0
        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"));
        }
Ejemplo n.º 19
0
	public override void ActionCallback (ResourceRoot target)
	{
		StopAllCoroutines ();
		StartCoroutine (Gather (target));
	}
Ejemplo n.º 20
0
 public virtual void ActionCallback(ResourceRoot target)
 {
 }
 public ResourceInitializingEvent(ResourceRoot resource)
 {
     Resource = resource;
 }
Ejemplo n.º 22
0
	public virtual void ActionCallback (ResourceRoot target) {}
Ejemplo n.º 23
0
 public override void ActionCallBack(ResourceRoot target)
 {
     StartCoroutine(Gather(target));
 }
Ejemplo n.º 24
0
 public override void ActionCallback(ResourceRoot target)
 {
     StopAllCoroutines();
     StartCoroutine(Gather(target));
 }