public void SpawnResources(Planet.ResourceType resourceType)
    {
        var cloud = PrefabController.Instance.GetPrefabInstance <ResourceCloud>(PrefabType.ResourceCloud);

        cloud.SpawnWithType(resourceType);
        cloud.transform.position = new Vector3(Random.Range(-90.0f, 90.0f), Random.Range(-90.0f, 90.0f), Random.Range(-90.0f, 90.0f));
    }
Beispiel #2
0
    public void ChangeResource(Planet.ResourceType type, bool take)
    {
        if (_resourceTimer < 0.0f)
        {
            int amount = 5;
            int change = take ? -amount : amount;
            switch (type)
            {
            case Planet.ResourceType.Environment:
                if ((take && _currentPlanet.Data.EnvironmentResource >= amount) || (!take && EnvironmentAmount >= amount))
                {
                    _currentPlanet.Data.EnvironmentResource += change;
                    EnvironmentAmount -= change;
                    _currentPlanet.Data.EnvironmentResource = Mathf.Max(0, _currentPlanet.Data.EnvironmentResource);
                }
                break;

            case Planet.ResourceType.Tech:
                if ((take && _currentPlanet.Data.TechResource >= amount) || (!take && TechAmount >= amount))
                {
                    _currentPlanet.Data.TechResource += change;
                    TechAmount -= change;
                    _currentPlanet.Data.TechResource = Mathf.Max(0, _currentPlanet.Data.TechResource);
                }
                break;
            }
            _resourceTimer = _currentResourceTimer;
            _totalResourceCount++;
        }
        else
        {
            _resourceTimer -= Time.deltaTime;

            if (_totalResourceCount > 20)
            {
                _currentResourceTimer = FASTEST_RESOURCE_TIMER;
            }
            else if (_totalResourceCount > 3)
            {
                _currentResourceTimer = FAST_RESOURCE_TIMER;
            }
        }
    }