|
@@ -3,6 +3,7 @@ using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
using System.IO;
|
|
|
using System.Linq;
|
|
|
+using System.Text;
|
|
|
using System.Xml;
|
|
|
using Sfs2X.Entities.Data;
|
|
|
using UnityEngine;
|
|
@@ -83,10 +84,61 @@ public class ChestData
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+public class ChestOperateData
|
|
|
+{
|
|
|
+ public long ChestID;
|
|
|
+ public bool Received;
|
|
|
+ public int DatabaseRoomID;
|
|
|
+ public int? GuessedAmt;
|
|
|
+ public DateTime? LastActivatedTime; //只有系统宝箱才用
|
|
|
+
|
|
|
+ public ChestOperateData(string str)
|
|
|
+ {
|
|
|
+ string[] strings = str.Split('|');
|
|
|
+ ChestID = long.Parse(strings[0]);
|
|
|
+ DatabaseRoomID = int.Parse(strings[1]);
|
|
|
+ Received = int.Parse(strings[2]).ToBool();
|
|
|
+ if (strings.Length > 3)
|
|
|
+ {
|
|
|
+ GuessedAmt = int.Parse(strings[3]);
|
|
|
+ }
|
|
|
+ if (strings.Length > 4)
|
|
|
+ {
|
|
|
+ LastActivatedTime = DateUtil.GetTimeFromSecends(strings[4]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public ChestOperateData(bool received, long chestID, int databaseRoomID)
|
|
|
+ {
|
|
|
+ Received = received;
|
|
|
+ ChestID = chestID;
|
|
|
+ DatabaseRoomID = databaseRoomID;
|
|
|
+ }
|
|
|
+
|
|
|
+ public override string ToString()
|
|
|
+ {
|
|
|
+ StringBuilder stringBuilder = new StringBuilder();
|
|
|
+ stringBuilder.Append(ChestID);
|
|
|
+ stringBuilder.Append('|' + DatabaseRoomID);
|
|
|
+ if (GuessedAmt != null)
|
|
|
+ {
|
|
|
+ stringBuilder.Append('|' + GuessedAmt);
|
|
|
+ }
|
|
|
+ if (LastActivatedTime != null)
|
|
|
+ {
|
|
|
+ stringBuilder.Append('|' + LastActivatedTime.ToString());
|
|
|
+ }
|
|
|
+ return stringBuilder.ToString();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
public class ChestMge : Regist
|
|
|
{
|
|
|
#region Config
|
|
|
|
|
|
+ public static int PlayerMaxGuessAmt = 3;
|
|
|
+
|
|
|
private static Text Desc;
|
|
|
private static Text BtnLab;
|
|
|
private static Text SliderValueLab;
|
|
@@ -99,8 +151,8 @@ public class ChestMge : Regist
|
|
|
|
|
|
public static List<PlazaRoomChest> PlazaRoomChests = new List<PlazaRoomChest>();
|
|
|
|
|
|
- private static List<int> RefundRoomIDs = new List<int>();
|
|
|
- private static Dictionary<long, int> ChestRoomDictionary = new Dictionary<long, int>();
|
|
|
+ public static List<int> RefundRoomIDs = new List<int>();
|
|
|
+ public static Dictionary<long, ChestOperateData> OperateDataDictionary = new Dictionary<long, ChestOperateData>();
|
|
|
|
|
|
#endregion
|
|
|
|
|
@@ -114,9 +166,8 @@ public class ChestMge : Regist
|
|
|
}
|
|
|
for (int i = 0; i < ReceivedNodes.Count; i++)
|
|
|
{
|
|
|
- string[] strings = ReceivedNodes[i].InnerText.Split('|');
|
|
|
- long chestID = long.Parse(strings[0]);
|
|
|
- ChestRoomDictionary.Add(chestID, int.Parse(strings[1]));
|
|
|
+ ChestOperateData chestOperateData = new ChestOperateData(ReceivedNodes[i].InnerText);
|
|
|
+ OperateDataDictionary.Add(chestOperateData.ChestID, chestOperateData);
|
|
|
}
|
|
|
//foreach (var VARIABLE in RefundRoomIDs)
|
|
|
//{
|
|
@@ -304,12 +355,12 @@ public class ChestMge : Regist
|
|
|
|
|
|
private static void GetChestExpireStatus()
|
|
|
{
|
|
|
- if (ChestRoomDictionary.Keys.Count == 0)
|
|
|
+ if (OperateDataDictionary.Keys.Count == 0)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- SFSManager.GardenSmartFox.EventManager.PlazaRoomEvent.GetChestExpireStatus(ChestRoomDictionary.Keys.ToList());
|
|
|
+ SFSManager.GardenSmartFox.EventManager.PlazaRoomEvent.GetChestExpireStatus(OperateDataDictionary.Keys.ToList());
|
|
|
}
|
|
|
|
|
|
public static void OnReceiveChestExpireStatus(List<long> chestIDs)
|
|
@@ -317,7 +368,7 @@ public class ChestMge : Regist
|
|
|
foreach (var chestID in chestIDs)
|
|
|
{
|
|
|
//Debug.LogWarning("expire " + chestID);
|
|
|
- ChestRoomDictionary.Remove(chestID);
|
|
|
+ OperateDataDictionary.Remove(chestID);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -335,19 +386,31 @@ public class ChestMge : Regist
|
|
|
{
|
|
|
if (chestData.ChestType != ChestType.System)
|
|
|
{
|
|
|
- if (ChestRoomDictionary.Keys.Contains(chestData.ID))
|
|
|
+ if (chestData.RemainRound <= 0 || chestData.RemainValue <= 0)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if (chestData.RemainRound <= 0 || chestData.RemainValue <= 0)
|
|
|
+ ChestOperateData chestOperateData;
|
|
|
+ OperateDataDictionary.TryGetValue(chestData.ID, out chestOperateData);
|
|
|
+
|
|
|
+ if (chestOperateData == null || chestOperateData.Received == false)
|
|
|
{
|
|
|
- return;
|
|
|
+ PlazaRoomChest chest = ManaReso.GetPlazaRoomChest(chestData.Position);
|
|
|
+ chest.Init(chestData);
|
|
|
+ PlazaRoomChests.Add(chest);
|
|
|
+
|
|
|
+ if (chestOperateData.GuessedAmt == null || chestOperateData.GuessedAmt < PlayerMaxGuessAmt)
|
|
|
+ {
|
|
|
+ chest.Active();
|
|
|
+ chest.TurnNormalColor();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ chest.Deactive();
|
|
|
+ chest.TurnGray();
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- PlazaRoomChest chest = ManaReso.GetPlazaRoomChest(chestData.Position);
|
|
|
- chest.Init(chestData);
|
|
|
- PlazaRoomChests.Add(chest);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -370,7 +433,6 @@ public class ChestMge : Regist
|
|
|
|
|
|
public static void ActivateSystemChest()
|
|
|
{
|
|
|
-
|
|
|
if (!SFSManager.GardenSmartFox.PlazaRoomManager.JoinedPlazaRoom)
|
|
|
{
|
|
|
return;
|
|
@@ -381,12 +443,13 @@ public class ChestMge : Regist
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if (ChestRoomDictionary.Keys.Contains(PlazaRoomChest.SystemChest.ChestData.ID))
|
|
|
+ if (OperateDataDictionary.Keys.Contains(PlazaRoomChest.SystemChest.ChestData.ID))
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
PlazaRoomChest.SystemChest.Active();
|
|
|
+ PlazaRoomChest.SystemChest.TurnNormalColor();
|
|
|
}
|
|
|
|
|
|
public static void ReactivateSystemChest()
|
|
@@ -401,8 +464,9 @@ public class ChestMge : Regist
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- ChestRoomDictionary.Remove(PlazaRoomChest.SystemChest.ChestData.ID);
|
|
|
+ OperateDataDictionary.Remove(PlazaRoomChest.SystemChest.ChestData.ID);
|
|
|
PlazaRoomChest.SystemChest.Active();
|
|
|
+ PlazaRoomChest.SystemChest.TurnNormalColor();
|
|
|
}
|
|
|
|
|
|
public static void DeactivateSystemChest()
|
|
@@ -417,13 +481,14 @@ public class ChestMge : Regist
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- //PlazaRoomChest.SystemChest.SetColliders(false);
|
|
|
PlazaRoomChest.SystemChest.Deactive();
|
|
|
+ PlazaRoomChest.SystemChest.TurnGray();
|
|
|
}
|
|
|
|
|
|
public static void ReceiveChestAward(int award, long chestID)
|
|
|
{
|
|
|
- ChestRoomDictionary.Add(PlazaRoomChest.CurrentChest.ChestData.ID, PlazaRoomChest.CurrentChest.ChestData.DatabaseRoomID);
|
|
|
+ ChestOperateData chestOperateData = new ChestOperateData(true, PlazaRoomChest.CurrentChest.ChestData.ID, PlazaRoomChest.CurrentChest.ChestData.DatabaseRoomID);
|
|
|
+ OperateDataDictionary.Add(chestOperateData.ChestID, chestOperateData);
|
|
|
|
|
|
ManaReso.Get<CanvasGroup>("Y_Chest").interactable = true;
|
|
|
|
|
@@ -494,7 +559,7 @@ public class ChestMge : Regist
|
|
|
node.InnerText = id.ToString();
|
|
|
ManaData.PlayerNode.AppendChild(node);
|
|
|
}
|
|
|
- foreach (var kv in ChestRoomDictionary)
|
|
|
+ foreach (var kv in OperateDataDictionary)
|
|
|
{
|
|
|
node = ManaData.PlayerDoc.CreateNode(XmlNodeType.Element, ReceivedNodeName, null);
|
|
|
node.InnerText = $"{kv.Key}|{kv.Value}";
|