示例#1
0
 void Start()
 {
     if (isConstant == true)
     {
         ConstantItem();
     }
     else
     {
         _Scriptable = GenerateRandomItem();
     }
     spriteRenderer.sprite = _Scriptable.Artwork;
 }
示例#2
0
    void grabObjt(ItemsSO _Scriptable)
    {
        itemType       = _Scriptable.itemType;
        consumableType = _Scriptable.consumableType;
        activeName     = _Scriptable.activeItemName;

        if (itemType == ItemTypeEnum.CacWeapon)
        {
            attackCaC.DamageCaC                 = _Scriptable.damageCac;
            attackCaC.impactTime                = _Scriptable.ImpactTime;
            attackCaC.attackIntervale           = _Scriptable.cooldownCac;
            imgCacWepon.sprite                  = _Scriptable.Artwork;
            imgCacWepon.rectTransform.sizeDelta = new Vector2(imgCacWepon.preferredWidth, imgCacWepon.preferredHeight);

            isUsed = true;
        }

        if (itemType == ItemTypeEnum.DistanceWeapon)
        {
            attackDist.DamageDist                 = _Scriptable.damageDistance;
            attackDist.bulletPrefab               = _Scriptable.bulletPrefab;
            attackDist.shootIntervale             = _Scriptable.weaponCooldownDistance;
            imgDistWeapon.sprite                  = _Scriptable.Artwork;
            imgDistWeapon.rectTransform.sizeDelta = new Vector2(imgDistWeapon.preferredWidth * 2, imgDistWeapon.preferredHeight * 2);
            isUsed = true;
        }

        if (itemType == ItemTypeEnum.ActiveItem)
        {
            activeObject.sprite = _Scriptable.Artwork;
            activeObject.rectTransform.sizeDelta = new Vector2(activeObject.preferredWidth * 2, activeObject.preferredHeight * 2);
            numberOfCharges = _Scriptable.numberOfCharges;
            chargeScript.chargesColor();

            if (_Scriptable.colorBomb == true)
            {
                ColorBomb   = true;
                musicBox    = false;
                mirror      = false;
                MGSBox      = false;
                map         = false;
                iceFlower   = false;
                fatherWatch = false;
                chrono      = false;
                spinach     = false;
                Debug.Log("ColorBomb Taken");
            }
            if (_Scriptable.chrono == true)
            {
                chrono      = true;
                ColorBomb   = false;
                musicBox    = false;
                mirror      = false;
                MGSBox      = false;
                map         = false;
                iceFlower   = false;
                fatherWatch = false;
                spinach     = false;
            }
            if (_Scriptable.fatherWatch == true)
            {
                ColorBomb   = false;
                fatherWatch = true;
                musicBox    = false;
                mirror      = false;
                MGSBox      = false;
                map         = false;
                iceFlower   = false;
                chrono      = false;
                spinach     = false;
            }
            if (_Scriptable.iceFlower == true)
            {
                ColorBomb   = false;
                iceFlower   = true;
                musicBox    = false;
                mirror      = false;
                MGSBox      = false;
                map         = false;
                fatherWatch = false;
                chrono      = false;
                spinach     = false;
            }
            if (_Scriptable.map == true)
            {
                ColorBomb   = false;
                map         = true;
                musicBox    = false;
                mirror      = false;
                MGSBox      = false;
                iceFlower   = false;
                fatherWatch = false;
                chrono      = false;
                spinach     = false;
            }
            if (_Scriptable.MGSBox == true)
            {
                ColorBomb   = false;
                MGSBox      = true;
                musicBox    = false;
                mirror      = false;
                map         = false;
                iceFlower   = false;
                fatherWatch = false;
                chrono      = false;
                spinach     = false;
                Debug.Log("CapeTaken");
            }
            if (_Scriptable.mirror == true)
            {
                ColorBomb   = false;
                mirror      = true;
                musicBox    = false;
                MGSBox      = false;
                map         = false;
                iceFlower   = false;
                fatherWatch = false;
                chrono      = false;
                spinach     = false;
            }
            if (_Scriptable.musicBox == true)
            {
                ColorBomb   = false;
                musicBox    = true;
                mirror      = false;
                MGSBox      = false;
                map         = false;
                iceFlower   = false;
                fatherWatch = false;
                chrono      = false;
                spinach     = false;
            }
            if (_Scriptable.spinach == true)
            {
                spinach     = true;
                ColorBomb   = false;
                musicBox    = false;
                mirror      = false;
                MGSBox      = false;
                map         = false;
                iceFlower   = false;
                fatherWatch = false;
                chrono      = false;
                Debug.Log("Potiondeforce Taken");
            }
            isUsed = true;
        }

        else if (itemType == ItemTypeEnum.Consumables)
        {
            if (consumableType == ConsumablesTypesEnum.Heal && health.PlayerLife != health.maxPlayerLife && _Scriptable.IsPermanent == false)
            {
                health.PlayerLife += _Scriptable.healingPoints;
                isUsed             = true;
            }

            else if (consumableType == ConsumablesTypesEnum.Heal && _Scriptable.IsPermanent == true)
            {
                health.maxPlayerLife          += _Scriptable.healingPoints;
                health.PlayerLife             += _Scriptable.healingPoints;
                passiveObject[imgIndex].sprite = _Scriptable.Artwork;
                passiveObject[imgIndex].rectTransform.sizeDelta = new Vector2(passiveObject[imgIndex].preferredWidth * 2, passiveObject[imgIndex].preferredHeight * 2);
                imgIndex++;
                isUsed = true;
            }

            else if (consumableType == ConsumablesTypesEnum.Speed && _Scriptable.IsPermanent == false)
            {
                controller.moveSpeed *= _Scriptable.speedMultiplication;
                isUsed = true;
            }

            else if (consumableType == ConsumablesTypesEnum.Speed && _Scriptable.IsPermanent == true)
            {
                controller.moveSpeed          *= _Scriptable.speedMultiplication;
                passiveObject[imgIndex].sprite = _Scriptable.Artwork;
                passiveObject[imgIndex].rectTransform.sizeDelta = new Vector2(passiveObject[imgIndex].preferredWidth * 2, passiveObject[imgIndex].preferredHeight * 2);
                imgIndex++;
                isUsed = true;
            }

            else if (consumableType == ConsumablesTypesEnum.Strengh && _Scriptable.IsPermanent == false)
            {
                attackCaC.DamageCaC   *= _Scriptable.damageMultiplication;
                attackDist.DamageDist *= _Scriptable.damageMultiplication;
                isUsed = true;
            }

            else if (consumableType == ConsumablesTypesEnum.Strengh && _Scriptable.IsPermanent == true)
            {
                attackCaC.DamageCaC           *= _Scriptable.damageMultiplication;
                attackDist.DamageDist         *= _Scriptable.damageMultiplication;
                passiveObject[imgIndex].sprite = _Scriptable.Artwork;
                passiveObject[imgIndex].rectTransform.sizeDelta = new Vector2(passiveObject[imgIndex].preferredWidth * 2, passiveObject[imgIndex].preferredHeight * 2);
                imgIndex++;
                isUsed = true;
            }

            else if (consumableType == ConsumablesTypesEnum.Coin)
            {
                currentCoins += _Scriptable.coinValue;
                FindObjectOfType <AudioManager>().Play("LootGold");
                isUsed = true;
            }
        }
    }