예제 #1
0
    public void GenerateAdditionIcon(collectableTypes _type, int _qty, Collect _colletRef)
    {
        if (_type == collectableTypes.Amber || // the different collectible types
            _type == collectableTypes.FuelTank ||
            _type == collectableTypes.FuelTankBig ||
            _type == collectableTypes.Heal ||
            _type == collectableTypes.Meteorite)
        {
            return;
        }

        if (additionPanel.transform.childCount >= 3)
        {
            holdType          = _type;
            holdCollectScript = _colletRef;
            holdQty           = _qty;
            StartCoroutine("WaitToSpawnBadge");
        }
        else
        {
            GameObject badge = Instantiate(weaponBadgeAddition) as GameObject;
            badge.transform.SetParent(additionPanel.transform, false);
            badge.transform.localScale = new Vector3(1, 1, 1);
            WeaponBadgeAddition badgeScr = badge.GetComponent <WeaponBadgeAddition>();

            badgeScr.SetIconImage(_colletRef.icon);
            badgeScr.SetName(_colletRef.displayName);
            badgeScr.SetQuantity(_qty);
        }
    }
예제 #2
0
    // Ading the collectibles to the players loadout (Currency, Ammo, Fuel)
    public void AddCollectedItem(collectableTypes _type, int _qty, Collect _colletRef)
    {
        switch (_type)
        {
        case collectableTypes.Amber: m_amber += _qty;         FindObjectOfType <LevelManager>().AmberCollected(_qty); break;

        case collectableTypes.Meteorite: m_meteorite += _qty; FindObjectOfType <LevelManager>().meteoriteCollected += _qty; break;

        case collectableTypes.FuelTank:
            player.GetComponent <RTCTankController>().CurrentFuel += _qty;
            if (player.GetComponent <RTCTankController>().CurrentFuel > player.GetComponent <RTCTankController>().maxFuel)
            {
                player.GetComponent <RTCTankController>().CurrentFuel = player.GetComponent <RTCTankController>().maxFuel;
            }
            break;

        case collectableTypes.FuelTankBig:
            player.GetComponent <RTCTankController>().CurrentFuel += _qty;
            if (player.GetComponent <RTCTankController>().CurrentFuel > player.GetComponent <RTCTankController>().maxFuel)
            {
                player.GetComponent <RTCTankController>().CurrentFuel = player.GetComponent <RTCTankController>().maxFuel;
            }
            break;

        case collectableTypes.FuelObj:
            player.GetComponent <RTCTankController>().CurrentFuel += _qty;
            if (player.GetComponent <RTCTankController>().CurrentFuel > player.GetComponent <RTCTankController>().maxFuel)
            {
                player.GetComponent <RTCTankController>().CurrentFuel = player.GetComponent <RTCTankController>().maxFuel;
            }
            break;

        case collectableTypes.Heal:
            if (player)
            {
                player.GetComponent <RTCTankController>().SetLife(player.GetComponent <RTCTankController>().CurrentLife + _qty);
                if (player.GetComponent <RTCTankController>().CurrentLife > player.GetComponent <RTCTankController>().MaxLife)
                {
                    player.GetComponent <RTCTankController>().SetLife(player.GetComponent <RTCTankController>().MaxLife);
                }
            }
            break;

        default:
            // we do this if we are adding a weapon that already has a prefab in Resources and we need to add it
            FindOrAddWepon(_type.ToString(), _qty);
            break;
        }
        SavePlayerPrefs();
        EventManager.TriggerEvent("RefreshLoadout");
    }