Exemplo n.º 1
0
        public string Purchase(PlayerPerk playerPerk = null, bool usePerkCurrency = true)
        {
            if (purchased > 0 && !repeatable)
            {
                return("Error trying to re-purchase non-repeatable perk");
            }

            if (repeatable && purchased >= limit)
            {
                return("Limit reached");
            }

            if (usePerkCurrency && playerPerk != null)
            {
                if (playerPerk.GetPerkCurrency() < cost)
                {
                    return("Insufficient perk currency");
                }
                playerPerk.SpendCurrency(cost);
            }

            purchased += 1;

            return("");
        }
Exemplo n.º 2
0
        //public static void LevelUp(){ instance._LevelUp(); }
        public void _LevelUp()
        {
            PlayerPerk perk = player.GetPlayerPerk();

            if (perk != null)
            {
                for (int i = 0; i < stats.perkUnlockingAtLevelList.Count; i++)
                {
                    if (level + 1 == stats.perkUnlockingAtLevelList[i].level)
                    {
                        for (int n = 0; n < stats.perkUnlockingAtLevelList[i].perkIDList.Count; n++)
                        {
                            perk.PurchasePerk(stats.perkUnlockingAtLevelList[i].perkIDList[n], false);
                        }

                        break;
                    }
                }
            }

            level += 1;

            if (level > 1)
            {
                player.GainHitPoint(stats.hitPointGain);
                player.GainEnergy(stats.energyGain);

                player.GainPerkCurrency(stats.perkCurrencyGain);

                TDS.PlayerLevelUp(player);
                TDS.OnGameMessage("level Up!");
            }

            GainExp();                  //call the function to make sure if we under level
        }
Exemplo n.º 3
0
 public void EnableAllPerkOnAll()
 {
     for (int i = 0; i < serializedObject.targetObjects.Length; i++)
     {
         PlayerPerk pPerkInstance = (PlayerPerk)serializedObject.targetObjects[i];
         pPerkInstance.unavailableIDList = new List <int>();
     }
 }
Exemplo n.º 4
0
 public void RemoveIDFromPurchasedList(int ID)
 {
     for (int i = 0; i < serializedObject.targetObjects.Length; i++)
     {
         PlayerPerk pPerkInstance = (PlayerPerk)serializedObject.targetObjects[i];
         pPerkInstance.purchasedIDList.Remove(ID);
     }
 }
Exemplo n.º 5
0
 public void AddIDToAvaiList(int ID)
 {
     for (int i = 0; i < serializedObject.targetObjects.Length; i++)
     {
         PlayerPerk pPerkInstance = (PlayerPerk)serializedObject.targetObjects[i];
         pPerkInstance.unavailableIDList.Remove(ID);
     }
 }
Exemplo n.º 6
0
 public void AddIDToPurchasedList(int ID)
 {
     for (int i = 0; i < serializedObject.targetObjects.Length; i++)
     {
         PlayerPerk pPerkInstance = (PlayerPerk)serializedObject.targetObjects[i];
         if (!pPerkInstance.purchasedIDList.Contains(ID))
         {
             pPerkInstance.purchasedIDList.Add(ID);
         }
     }
 }
Exemplo n.º 7
0
 public void RemoveIDFromAvaiList(int ID)
 {
     for (int i = 0; i < serializedObject.targetObjects.Length; i++)
     {
         PlayerPerk pPerkInstance = (PlayerPerk)serializedObject.targetObjects[i];
         if (!pPerkInstance.unavailableIDList.Contains(ID))
         {
             pPerkInstance.unavailableIDList.Add(ID);
         }
     }
 }
Exemplo n.º 8
0
        public void DisableAllPerkOnAll()
        {
            List <int> allIDList = new List <int>();

            for (int i = 0; i < perkDB.perkList.Count; i++)
            {
                allIDList.Add(perkDB.perkList[i].ID);
            }

            for (int i = 0; i < serializedObject.targetObjects.Length; i++)
            {
                PlayerPerk pPerkInstance = (PlayerPerk)serializedObject.targetObjects[i];
                pPerkInstance.unavailableIDList = new List <int>(allIDList);
            }
        }
Exemplo n.º 9
0
        private bool PurchasedListSharesValue(int ID)
        {
            if (!serializedObject.isEditingMultipleObjects)
            {
                return(true);
            }

            PlayerPerk pPerkInstance = (PlayerPerk)serializedObject.targetObjects[0];
            bool       flag          = pPerkInstance.purchasedIDList.Contains(ID);

            for (int i = 1; i < serializedObject.targetObjects.Length; i++)
            {
                pPerkInstance = (PlayerPerk)serializedObject.targetObjects[i];
                if (flag != pPerkInstance.purchasedIDList.Contains(ID))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 10
0
 void Awake()
 {
     instance = (PlayerPerk)target;
     LoadDB();
 }
Exemplo n.º 11
0
 public void SetPlayerPerk(PlayerPerk pPerk)
 {
     perk = pPerk;
 }