public int PrecentLayer(AwakeType rType) { if ((int)rType >= currentAwake.Length) { return(0); } var data = currentAwake[(int)rType]; //没有任何数据返回初始层 if (data == null || data.Length == 0) { return(0); } var layer = data.Length - 1; if (CanEnterNextLayer(rType, layer)) { var nextInfo = GetInfosOnLayer(rType, layer + 1); if (nextInfo != null && nextInfo.Count > 0) { return(layer + 1); } } return(layer); }
public bool NeedNoticeType(AwakeType rAwakeType) { var key = new NoticeDefaultKey(NoticeType.AwakeHeart + (int)rAwakeType - 1); moduleNotice.SetNoticeState(key, CanAwake(rAwakeType)); return(moduleNotice.IsNeedNotice(key)); }
public List <AwakeInfo> GetInfosOnLayer(AwakeType rType, int layer) { var list = ConfigManager.FindAll <AwakeInfo>(info => info.type == rType && info.layer == layer); list.RemoveAll(item => item.protoId != modulePlayer.proto && item.protoId != 0); list.Sort((a, b) => a.index.CompareTo(b.index)); return(list); }
public Awake(BinaryReader reader) { Type = (AwakeType)reader.ReadByte(); int count = reader.ReadInt32(); for (int i = 0; i < count; i++) { listAwake.Add(reader.ReadByte()); } }
public bool IsFinishLayer(AwakeType rType, int layer) { var infos = GetInfosOnLayer(rType, layer); foreach (var info in infos) { if (!Check(info)) { return(false); } } return(true); }
public bool CanEnterNextLayer(AwakeType rType, int layer) { var infos = GetInfosOnLayer(rType, layer); foreach (var info in infos) { if (!Check(info) && NextAwakeInfo(info.ID).Count > 0) { return(false); } } //没有下一层的数据必定不能跳转到下一层 return(GetInfosOnLayer(rType, layer + 1).Count > 0); }
public static AwakeHandle Create(AwakeType rType, GameObject rGameObject) { if (current) { if (CurrentType == rType) { current.Refresh(); return(current); } current.Destroy(); } CurrentType = rType; Util.SetLayer(rGameObject, awakeLayer); var handle = Create <AwakeHandle>(rType.ToString(), rGameObject); current = handle; return(handle); }
public int RemoveAwake() { if (listAwake.Count > 0) { listAwake.Remove(listAwake[listAwake.Count - 1]); if (listAwake.Count == 0) { Type = AwakeType.None; } return(1); } else { Type = AwakeType.None; return(0); } }
public int UpgradeAwake(UserItem item, AwakeType type, out bool[] isHit) { //return -1 condition error, -1 = dont upgrade, 0 = failed, 1 = Succeed, isHit = null; if (CheckAwakening(item, type) != true) { return(-1); } Random rand = new Random(DateTime.Now.Millisecond); if (rand.Next(0, 100) <= AwakeSuccessRate) { isHit = Awakening(item); return(1); } else { isHit = MakeHit(1, out _); return(0); } }
public bool CanAwake(AwakeType rType) { var infos = GetInfosOnLayer(rType, PrecentLayer(rType)); foreach (var info in infos) { if (CheckAwakeState(info) == 0) { uint own = 0; var prop = ConfigManager.Get <PropItemInfo>(info.cost.itemId); if (prop.itemType == PropType.Currency) { own = modulePlayer.GetMoneyCount((CurrencySubType)prop.subType); } else { own = moduleAwake.GetBeadCount(prop.subType); } return(info.cost.count <= own); } } return(false); }
public bool CheckAwakening(UserItem item, AwakeType type) { if (item.Info.Bind.HasFlag(BindMode.DontUpgrade)) { return(false); } if (item.Info.CanAwakening != true) { return(false); } if (item.Info.Grade == ItemGrade.None) { return(false); } if (IsMaxLevel()) { return(false); } if (this.Type == AwakeType.None) { if (item.Info.Type == ItemType.Weapon) { if (type == AwakeType.DC || type == AwakeType.MC || type == AwakeType.SC) { this.Type = type; return(true); } else { return(false); } } else if (item.Info.Type == ItemType.Helmet) { if (type == AwakeType.AC || type == AwakeType.MAC) { this.Type = type; return(true); } else { return(false); } } else if (item.Info.Type == ItemType.Armour) { if (type == AwakeType.HPMP) { this.Type = type; return(true); } else { return(false); } } else { return(false); } } else { if (this.Type == type) { return(true); } else { return(false); } } }
public int UpgradeAwake(UserItem item, AwakeType type, out bool[] isHit) { //return -1 condition error, -1 = dont upgrade, 0 = failed, 1 = Succeed, isHit = null; if (CheckAwakening(item, type) != true) return -1; Random rand = new Random(DateTime.Now.Millisecond); if (rand.Next(0, 100) <= AwakeSuccessRate) { isHit = Awakening(item); return 1; } else { int idx; isHit = makeHit(1, out idx); return 0; } }
public Awake() { type = AwakeType.None; }
protected override void ReadPacket(BinaryReader reader) { UniqueID = reader.ReadUInt64(); Type = (AwakeType)reader.ReadByte(); PositionIdx = reader.ReadUInt32(); }
public string getAwakeTypeText(AwakeType type) { string typeName = ""; switch (type) { case AwakeType.DC: typeName = "Bravery Glyph"; break; case AwakeType.MC: typeName = "Magic Glyph"; break; case AwakeType.SC: typeName = "Soul Glyph"; break; case AwakeType.AC: typeName = "Protection Glyph"; break; case AwakeType.MAC: typeName = "EvilSlayer Glyph"; break; case AwakeType.HPMP: typeName = "Body Glyph"; break; default: typeName = "Select Upgrade Item."; break; } return typeName; }
public void ItemCell_Click() { ItemCellClear(); SelectAwakeType.Items.Clear(); if (Items[0] == null) { SelectAwakeType.Items.Add("Select Upgrade Item."); SelectAwakeType.SelectedIndex = SelectAwakeType.Items.Count-1; CurrentAwakeType = AwakeType.None; } else { if (Items[0].Awake.getAwakeLevel() == 0) { SelectAwakeType.Items.Add("Select Upgrade Type."); if (Items[0].Info.Type == ItemType.Weapon) { SelectAwakeType.Items.Add("Bravery Glyph"); SelectAwakeType.Items.Add("Magic Glyph"); SelectAwakeType.Items.Add("Soul Glyph"); } else if (Items[0].Info.Type == ItemType.Helmet) { SelectAwakeType.Items.Add("Protection Glyph"); SelectAwakeType.Items.Add("EvilSlayer Glyph"); } else { SelectAwakeType.Items.Add("Body Glyph"); } } else { SelectAwakeType.Items.Add(getAwakeTypeText(Items[0].Awake.type)); if (CurrentAwakeType != Items[0].Awake.type) { CurrentAwakeType = Items[0].Awake.type; OnAwakeTypeSelect(0); } } } }
public void Awakening(ulong UniqueID, AwakeType type) { if (NPCPage == null || !String.Equals(NPCPage.Key, NPCObject.AwakeningKey, StringComparison.CurrentCultureIgnoreCase)) return; if (type == AwakeType.None) return; for (int i = 0; i < Info.Inventory.Length; i++) { UserItem item = Info.Inventory[i]; if (item == null || item.UniqueID != UniqueID) continue; Awake awake = item.Awake; if (!item.Info.CanAwakening) { Enqueue(new S.Awakening { result = -1, removeID = -1 }); return; } if (awake.IsMaxLevel()) { Enqueue(new S.Awakening { result = -2, removeID = -1 }); return; } if (Info.AccountInfo.Gold < item.AwakeningPrice()) { Enqueue(new S.Awakening { result = -3, removeID = -1 }); return; } if (HasAwakeningNeedMaterials(item, type)) { Info.AccountInfo.Gold -= item.AwakeningPrice(); Enqueue(new S.LoseGold { Gold = item.AwakeningPrice() }); bool[] isHit; switch (awake.UpgradeAwake(item, type, out isHit)) { case -1: Enqueue(new S.Awakening { result = -1, removeID = -1 }); break; case 0: AwakeningEffect(false, isHit); Info.Inventory[i] = null; Enqueue(new S.Awakening { result = 0, removeID = (long)item.UniqueID }); break; case 1: Enqueue(new S.RefreshItem { Item = item }); AwakeningEffect(true, isHit); Enqueue(new S.Awakening { result = 1, removeID = -1 }); break; default: break; } } } }
public void OnAwakeTypeSelect(int Index) { SelectAwakeType.SelectedIndex = Index; AwakeType type = getAwakeType(SelectAwakeType.Items[SelectAwakeType.SelectedIndex]); CurrentAwakeType = type; if (type != AwakeType.None) { Network.Enqueue(new C.AwakeningNeedMaterials { UniqueID = Items[0].UniqueID, Type = type }); } }
public void AwakeningNeedMaterials(ulong UniqueID, AwakeType type) { if (type == AwakeType.None) return; foreach (UserItem item in Info.Inventory) { if (item != null) { if (item.UniqueID == UniqueID) { Awake awake = item.Awake; byte[] materialCount = new byte[2]; int idx = 0; foreach (List<byte> material in Awake.AwakeMaterials[(int)type - 1]) { byte materialRate = (byte)(Awake.AwakeMaterialRate[(int)item.Info.Grade - 1] * (float)awake.getAwakeLevel()); materialCount[idx] = material[(int)item.Info.Grade - 1]; materialCount[idx] += materialRate; idx++; } ItemInfo[] materials = new ItemInfo[2]; foreach (ItemInfo info in Envir.ItemInfoList) { if (item.Info.Grade == info.Grade && info.Type == ItemType.Awakening) { if (info.Shape == (short)type - 1) { materials[0] = info; } else if (info.Shape == 100) { materials[1] = info; } } } Enqueue(new S.AwakeningNeedMaterials { Materials = materials, MaterialsCount = materialCount }); break; } } } }
public Awake(BinaryReader reader) { type = (AwakeType)reader.ReadByte(); int count = reader.ReadInt32(); for (int i = 0; i < count; i++) { listAwake.Add(reader.ReadByte()); } }
public bool HasAwakeningNeedMaterials(UserItem item, AwakeType type) { Awake awake = item.Awake; byte[] materialCount = new byte[2]; int idx = 0; foreach (List<byte> material in Awake.AwakeMaterials[(int)type - 1]) { byte materialRate = (byte)(Awake.AwakeMaterialRate[(int)item.Info.Grade - 1] * (float)awake.getAwakeLevel()); materialCount[idx] = material[(int)item.Info.Grade - 1]; materialCount[idx] += materialRate; idx++; } byte[] currentCount = new byte[2] { 0, 0 }; for (int i = 0; i < Info.Inventory.Length; i++) { UserItem materialItem = Info.Inventory[i]; if (materialItem != null) { if (materialItem.Info.Grade == item.Info.Grade && materialItem.Info.Type == ItemType.Awakening) { if (materialItem.Info.Shape == ((int)type - 1) && materialCount[0] - currentCount[0] != 0) { if (materialItem.Count <= materialCount[0] - currentCount[0]) { currentCount[0] += (byte)materialItem.Count; } else if (materialItem.Count > materialCount[0] - currentCount[0]) { currentCount[0] = (byte)(materialCount[0] - currentCount[0]); } } else if (materialItem.Info.Shape == 100 && materialCount[1] - currentCount[1] != 0) { if (materialItem.Count <= materialCount[1] - currentCount[1]) { currentCount[1] += (byte)materialItem.Count; } else if (materialItem.Count > materialCount[1] - currentCount[1]) { currentCount[1] = (byte)(materialCount[1] - currentCount[1]); } } } } } for (int i = 0; i < materialCount.Length; i++) { if (materialCount[i] != currentCount[i]) { Enqueue(new S.Awakening { result = -4, removeID = -1 }); return false; } } for (int i = 0; i < Info.Inventory.Length; i++) { if (Info.Inventory[i] != null) { if (Info.Inventory[i].Info.Grade == item.Info.Grade && Info.Inventory[i].Info.Type == ItemType.Awakening) { if (Info.Inventory[i].Info.Shape == ((int)type - 1) && currentCount[0] > 0) { if (Info.Inventory[i].Count <= currentCount[0]) { Enqueue(new S.DeleteItem { UniqueID = Info.Inventory[i].UniqueID, Count = Info.Inventory[i].Count }); currentCount[0] -= (byte)Info.Inventory[i].Count; Info.Inventory[i] = null; } else if (Info.Inventory[i].Count > currentCount[0]) { Enqueue(new S.DeleteItem { UniqueID = Info.Inventory[i].UniqueID, Count = (uint)currentCount[0] }); Info.Inventory[i].Count -= currentCount[0]; currentCount[0] = 0; } } else if (Info.Inventory[i].Info.Shape == 100 && currentCount[1] > 0) { if (Info.Inventory[i].Count <= currentCount[1]) { Enqueue(new S.DeleteItem { UniqueID = Info.Inventory[i].UniqueID, Count = Info.Inventory[i].Count }); currentCount[1] -= (byte)Info.Inventory[i].Count; Info.Inventory[i] = null; } else if (Info.Inventory[i].Count > currentCount[1]) { Enqueue(new S.DeleteItem { UniqueID = Info.Inventory[i].UniqueID, Count = (uint)currentCount[1] }); Info.Inventory[i].Count -= currentCount[1]; currentCount[1] = 0; } } } } } return true; }
public bool CheckAwakening(UserItem item, AwakeType type) { if (item.Info.CanAwakening != true) return false; if (item.Info.Grade == ItemGrade.None) return false; if (IsMaxLevel()) return false; if (this.type == AwakeType.None) { if (item.Info.Type == ItemType.Weapon) { if (type == AwakeType.DC || type == AwakeType.MC || type == AwakeType.SC) { this.type = type; return true; } else return false; } else if (item.Info.Type == ItemType.Helmet) { if (type == AwakeType.AC || type == AwakeType.MAC) { this.type = type; return true; } else return false; } else if (item.Info.Type == ItemType.Armour) { if (type == AwakeType.HPMP) { this.type = type; return true; } else return false; } else return false; } else { if (this.type == type) return true; else return false; } }
protected override void ReadPacket(BinaryReader reader) { UniqueID = reader.ReadUInt64(); Type = (AwakeType)reader.ReadByte(); }
public int RemoveAwake() { if (listAwake.Count > 0) { listAwake.Remove(listAwake[listAwake.Count - 1]); if (listAwake.Count == 0) type = AwakeType.None; return 1; } else { type = AwakeType.None; return 0; } }
public uint GetBeadCount(AwakeType rType) { return(GetBeadCount((int)rType - 1)); }