Beispiel #1
0
    private void CreateSettable(ResourceSettable resource)
    {
        if (!resource.CheckAmount(-1))
        {
            return;
        }

        if (resourceSettable == null)
        {
            resourceSettable = resource;
            setObject        = Instantiate(resource.prefab, transform);

            resource.ChangeAmount(-1);
        }
    }
Beispiel #2
0
    private void GatherSlot()
    {
        if (resourcePlantable != null && paramsData.havePlantGrown)
        {
            int pos = Array.IndexOf(resourcePlantable.gatherToolsID, toolsManager.activeTool.id);
            if (pos > -1)
            {
                resourcesManager.AddResourcePlantable(resourcePlantable.id, 1);

                notificationsManager.CreateNotificationGatherable(this.transform, resourcePlantable, 1);

                Destroy(plantObject);
                resourcePlantable         = null;
                paramsData.havePlantGrown = false;
            }
        }

        if (resourceSettable != null)
        {
            int pos = Array.IndexOf(resourceSettable.gatherToolsID, toolsManager.activeTool.id);
            if (pos > -1)
            {
                if (resourcePlantable != null)
                {
                    resourcesManager.AddResourcePlantable(resourcePlantable.id, 1);

                    if (paramsData.havePlantGrown)
                    {
                        notificationsManager.CreateNotificationGatherable(this.transform, resourcePlantable, 1);
                    }
                }

                resourcesManager.AddResourceSettable(resourceSettable.id, 1);

                Destroy(setObject);
                Destroy(plantObject);
                resourceSettable          = null;
                resourcePlantable         = null;
                paramsData.havePlantGrown = false;

                if (plantGrow != null)
                {
                    StopCoroutine(plantGrow);
                    plantGrow = null;
                }
            }
        }
    }
Beispiel #3
0
    private void Spawn()
    {
        foreach (var resource in resourcesConfig.resourcesSettable)
        {
            ResourceSettable newRes = Instantiate(resourcesConfig.prefabSettable, originSettable).GetComponent <ResourceSettable>();

            if (SetIntoList(ref resourcesSettable, newRes, resource.id))
            {
                newRes.Initialize(resource);

                newRes.prefab        = resource.prefab;
                newRes.gatherToolsID = resource.gatherToolsID;
            }
        }

        foreach (var resource in resourcesConfig.resourcesPlantable)
        {
            ResourcePlantable newRes = Instantiate(resourcesConfig.prefabPlantable, originPlantable).GetComponent <ResourcePlantable>();

            if (SetIntoList(ref resourcesPlantable, newRes, resource.id))
            {
                newRes.Initialize(resource);

                newRes.growTimeSeconds = resource.growTimeSeconds;
                newRes.needSettableID  = resource.needSettableID;
                newRes.gatherToID      = resource.gatherToID;
                newRes.gatherToolsID   = resource.gatherToolsID;
                newRes.prefabs         = resource.prefabs;
            }
        }

        foreach (var resource in resourcesConfig.resourcesGatherable)
        {
            ResourceGatherable newRes = Instantiate(resourcesConfig.prefabGatherable, originGatherable).GetComponent <ResourceGatherable>();

            if (SetIntoList(ref resourcesGatherable, newRes, resource.id))
            {
                newRes.Initialize(resource);
            }
        }
    }