|
@@ -1,16 +1,29 @@
|
|
|
|
|
|
|
|
+using System.Collections.Generic;
|
|
using FairyGUI;
|
|
using FairyGUI;
|
|
|
|
|
|
namespace GFGGame
|
|
namespace GFGGame
|
|
{
|
|
{
|
|
public class RedDotController : SingletonBase<RedDotController>
|
|
public class RedDotController : SingletonBase<RedDotController>
|
|
{
|
|
{
|
|
|
|
+ private List<GComponent> comRedDotPool = new List<GComponent>();
|
|
|
|
+
|
|
public void SetComRedDot(GComponent parentCom, bool isRed)
|
|
public void SetComRedDot(GComponent parentCom, bool isRed)
|
|
{
|
|
{
|
|
GComponent comRedDot;
|
|
GComponent comRedDot;
|
|
- if (parentCom.GetChild("comResDot") == null)
|
|
|
|
|
|
+
|
|
|
|
+ if (isRed)
|
|
{
|
|
{
|
|
- comRedDot = UIPackage.CreateObject("CommonGame", "ComRedDot").asCom;
|
|
|
|
|
|
+ if (parentCom.GetChild("comResDot") != null) return;
|
|
|
|
+ if (comRedDotPool.Count > 0)
|
|
|
|
+ {
|
|
|
|
+ comRedDot = comRedDotPool[0];
|
|
|
|
+ comRedDotPool.RemoveAt(0);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ comRedDot = UIPackage.CreateObject("CommonGame", "ComRedDot").asCom;
|
|
|
|
+ }
|
|
parentCom.AddChild(comRedDot);
|
|
parentCom.AddChild(comRedDot);
|
|
comRedDot.name = "comResDot";
|
|
comRedDot.name = "comResDot";
|
|
comRedDot.SetPosition(parentCom.width - comRedDot.width, 0, 0);
|
|
comRedDot.SetPosition(parentCom.width - comRedDot.width, 0, 0);
|
|
@@ -19,9 +32,14 @@ namespace GFGGame
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- comRedDot = parentCom.GetChild("comResDot").asCom;
|
|
|
|
|
|
+ if (parentCom.GetChild("comResDot") != null)
|
|
|
|
+ {
|
|
|
|
+ comRedDot = parentCom.GetChild("comResDot").asCom;
|
|
|
|
+ comRedDotPool.Add(comRedDot);
|
|
|
|
+ parentCom.RemoveChild(comRedDot);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- comRedDot.visible = isRed;
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|