Пример #1
0
    private ResourceNode GetResourceNodeNearPosition(Vector3 position, GameResources.ResourceType resourceType)
    {
        float maxDistance = 20f;
        List <ResourceNode> tmpResourceNodeList = new List <ResourceNode>(resourceNodeList);

        for (int i = 0; i < tmpResourceNodeList.Count; i++)
        {
            if (!tmpResourceNodeList[i].HasResources() ||
                Vector3.Distance(position, tmpResourceNodeList[i].GetPosition()) > maxDistance ||
                tmpResourceNodeList[i].GetResourceType() != resourceType)
            {
                // No more resources, or too far, or different resource type
                tmpResourceNodeList.RemoveAt(i);
                i--;
            }
        }
        if (tmpResourceNodeList.Count > 0)
        {
            return(tmpResourceNodeList[UnityEngine.Random.Range(0, tmpResourceNodeList.Count)]);
        }
        else
        {
            return(null);
        }
    }
Пример #2
0
    public ResourceNode(Transform resourceNodeTransform, GameResources.ResourceType resourceType)
    {
        this.resourceNodeTransform = resourceNodeTransform;
        this.resourceType          = resourceType;
        resourceAmountMax          = 3;
        resourceAmount             = resourceAmountMax;
        resourceNodeTransform.GetComponent <Button_Sprite>().ClickFunc = () => {
            if (OnResourceNodeClicked != null)
            {
                OnResourceNodeClicked(this, EventArgs.Empty);
            }
        };

        if (regenerationMethod == RegenerationMethod.Constant)
        {
            FunctionPeriodic.Create(RegenerateSingleResourceAmount, 2f);
        }

        //CMDebug.TextUpdater(() => ""+resourceAmount, Vector3.zero, resourceNodeTransform);
    }
Пример #3
0
 private void GrabResourceFromNode()
 {
     GameResources.ResourceType resourceType = resourceNode.GrabResource();
     inventoryAmountDictionary[resourceType]++;
     UpdateInventoryText();
 }
Пример #4
0
 public static ResourceNode GetResourceNodeNearPosition_Static(Vector3 position, GameResources.ResourceType resourceType)
 {
     return(instance.GetResourceNodeNearPosition(position, resourceType));
 }
Пример #5
0
 public LoadResourcesModel(GameResources.ResourceType Type, string Path)
 {
     this.type = Type;
     this.path = Path;
 }