private void Awake()
    {
        if (instance == null)
        {
            instance = GameObject.FindObjectOfType <ResourcesOverseer>();
        }

        DontDestroyOnLoad(instance);

        resourceCountStatic    = resourceCount;
        maxResourceCountStatic = maxResourceCount;
    }
Beispiel #2
0
    private void SpawnWeapon(Vector2 position)
    {
        if (!ResourcesOverseer.DecreaseResourceEvent(currentWeapon.WeaponCost))
        {
            return;
        }

        var weapons    = objectPool.GetUnits(currentWeapon.WeaponType, 1);
        var weaponMode = UnitMode.CreateUnitMode(currentWeapon.WeaponMode);

        foreach (var weapon in weapons)
        {
            weapon.SpawnObject(0, position, weaponMode);
        }
    }
Beispiel #3
0
    public void GetResource()
    {
        var miss = Random.Range(0, 100);

        if (miss < resource.BustRate)
        {
            return;
        }

        if (currentResourceCount > 0)
        {
            currentResourceCount -= resource.GivenResource;
            ResourcesOverseer.IncreaseResourceEvent(resource.GivenResource);
        }
        else
        {
            ReturnObject();
        }
    }
Beispiel #4
0
    private void ShowUpgrade(WeaponLite weapon)
    {
        var heavy       = objectPool.GetHeavyUnit(weapon.HeavyReference.Type, weapon.HeavyReference.Level + 1) as Weapon;
        var cost        = heavy.Cost;
        var okToUpgrade = weapon.CanUpgrade() && ResourcesOverseer.CanChangeResourceCount(false, cost);
        var resize      = 2.5f;

        spawnCursor.ToggleOkSpawn(okToUpgrade, resize);

        if (Input.GetMouseButtonDown(0) && okToUpgrade)
        {
            ResourcesOverseer.DecreaseResourceEvent(cost);
            weapon.Upgrade(objectPool.GetHeavyUnit(weapon.HeavyReference.Type, weapon.HeavyReference.Level + 1));
            return;
        }

        if (Input.GetMouseButtonDown(1))
        {
            ResourcesOverseer.IncreaseResourceEvent((weapon.HeavyReference as Weapon).Cost / 5);
            weapon.Sell();
            return;
        }
    }
Beispiel #5
0
 public void GiveDroppedResource()
 {
     ResourcesOverseer.IncreaseResourceEvent(drop.ResourceCount);
     ReturnObject();
 }