123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228 |
- using System;
- using System.Collections.Generic;
- using System.Runtime.CompilerServices;
- using UnityEngine;
- [Serializable]
- public class InvGameItem
- {
- public InvGameItem(int id)
- {
- this.mBaseItemID = id;
- }
- public InvGameItem(int id, InvBaseItem bi)
- {
- this.mBaseItemID = id;
- this.mBaseItem = bi;
- }
- public int baseItemID
- {
- get
- {
- return this.mBaseItemID;
- }
- }
- public InvBaseItem baseItem
- {
- get
- {
- if (this.mBaseItem == null)
- {
- this.mBaseItem = InvDatabase.FindByID(this.baseItemID);
- }
- return this.mBaseItem;
- }
- }
- public string name
- {
- get
- {
- if (this.baseItem == null)
- {
- return null;
- }
- return this.quality.ToString() + " " + this.baseItem.name;
- }
- }
- public float statMultiplier
- {
- get
- {
- float num = 0f;
- switch (this.quality)
- {
- case InvGameItem.Quality.Broken:
- num = 0f;
- break;
- case InvGameItem.Quality.Cursed:
- num = -1f;
- break;
- case InvGameItem.Quality.Damaged:
- num = 0.25f;
- break;
- case InvGameItem.Quality.Worn:
- num = 0.9f;
- break;
- case InvGameItem.Quality.Sturdy:
- num = 1f;
- break;
- case InvGameItem.Quality.Polished:
- num = 1.1f;
- break;
- case InvGameItem.Quality.Improved:
- num = 1.25f;
- break;
- case InvGameItem.Quality.Crafted:
- num = 1.5f;
- break;
- case InvGameItem.Quality.Superior:
- num = 1.75f;
- break;
- case InvGameItem.Quality.Enchanted:
- num = 2f;
- break;
- case InvGameItem.Quality.Epic:
- num = 2.5f;
- break;
- case InvGameItem.Quality.Legendary:
- num = 3f;
- break;
- }
- float num2 = (float)this.itemLevel / 50f;
- return num * Mathf.Lerp(num2, num2 * num2, 0.5f);
- }
- }
- public Color color
- {
- get
- {
- Color result = Color.white;
- switch (this.quality)
- {
- case InvGameItem.Quality.Broken:
- result = new Color(0.4f, 0.2f, 0.2f);
- break;
- case InvGameItem.Quality.Cursed:
- result = Color.red;
- break;
- case InvGameItem.Quality.Damaged:
- result = new Color(0.4f, 0.4f, 0.4f);
- break;
- case InvGameItem.Quality.Worn:
- result = new Color(0.7f, 0.7f, 0.7f);
- break;
- case InvGameItem.Quality.Sturdy:
- result = new Color(1f, 1f, 1f);
- break;
- case InvGameItem.Quality.Polished:
- result = NGUIMath.HexToColor(3774856959U);
- break;
- case InvGameItem.Quality.Improved:
- result = NGUIMath.HexToColor(2480359935U);
- break;
- case InvGameItem.Quality.Crafted:
- result = NGUIMath.HexToColor(1325334783U);
- break;
- case InvGameItem.Quality.Superior:
- result = NGUIMath.HexToColor(12255231U);
- break;
- case InvGameItem.Quality.Enchanted:
- result = NGUIMath.HexToColor(1937178111U);
- break;
- case InvGameItem.Quality.Epic:
- result = NGUIMath.HexToColor(2516647935U);
- break;
- case InvGameItem.Quality.Legendary:
- result = NGUIMath.HexToColor(4287627519U);
- break;
- }
- return result;
- }
- }
- public List<InvStat> CalculateStats()
- {
- List<InvStat> list = new List<InvStat>();
- if (this.baseItem != null)
- {
- float statMultiplier = this.statMultiplier;
- List<InvStat> stats = this.baseItem.stats;
- int i = 0;
- int count = stats.Count;
- while (i < count)
- {
- InvStat invStat = stats[i];
- int num = Mathf.RoundToInt(statMultiplier * (float)invStat.amount);
- if (num != 0)
- {
- bool flag = false;
- int j = 0;
- int count2 = list.Count;
- while (j < count2)
- {
- InvStat invStat2 = list[j];
- if (invStat2.id == invStat.id && invStat2.modifier == invStat.modifier)
- {
- invStat2.amount += num;
- flag = true;
- break;
- }
- j++;
- }
- if (!flag)
- {
- list.Add(new InvStat
- {
- id = invStat.id,
- amount = num,
- modifier = invStat.modifier
- });
- }
- }
- i++;
- }
- List<InvStat> list2 = list;
- if (InvGameItem.<>f__mg$cache0 == null)
- {
- InvGameItem.<>f__mg$cache0 = new Comparison<InvStat>(InvStat.CompareArmor);
- }
- list2.Sort(InvGameItem.<>f__mg$cache0);
- }
- return list;
- }
- [SerializeField]
- private int mBaseItemID;
- public InvGameItem.Quality quality = InvGameItem.Quality.Sturdy;
- public int itemLevel = 1;
- private InvBaseItem mBaseItem;
- [CompilerGenerated]
- private static Comparison<InvStat> <>f__mg$cache0;
- public enum Quality
- {
- Broken,
- Cursed,
- Damaged,
- Worn,
- Sturdy,
- Polished,
- Improved,
- Crafted,
- Superior,
- Enchanted,
- Epic,
- Legendary,
- _LastDoNotUse
- }
- }
|