You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
1.6 KiB
69 lines
1.6 KiB
3 years ago
|
using System;
|
||
|
using FairyGUI.Utils;
|
||
|
|
||
|
namespace FairyGUI
|
||
|
{
|
||
|
public class ControllerAction
|
||
|
{
|
||
|
public enum ActionType
|
||
|
{
|
||
|
PlayTransition,
|
||
|
ChangePage
|
||
|
}
|
||
|
|
||
|
public string[] fromPage;
|
||
|
public string[] toPage;
|
||
|
|
||
|
public static ControllerAction CreateAction(ActionType type)
|
||
|
{
|
||
|
switch (type)
|
||
|
{
|
||
|
case ActionType.PlayTransition:
|
||
|
return new PlayTransitionAction();
|
||
|
|
||
|
case ActionType.ChangePage:
|
||
|
return new ChangePageAction();
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
public ControllerAction()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
public void Run(Controller controller, string prevPage, string curPage)
|
||
|
{
|
||
|
if ((fromPage == null || fromPage.Length == 0 || Array.IndexOf(fromPage, prevPage) != -1)
|
||
|
&& (toPage == null || toPage.Length == 0 || Array.IndexOf(toPage, curPage) != -1))
|
||
|
Enter(controller);
|
||
|
else
|
||
|
Leave(controller);
|
||
|
}
|
||
|
|
||
|
virtual protected void Enter(Controller controller)
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
virtual protected void Leave(Controller controller)
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
virtual public void Setup(ByteBuffer buffer)
|
||
|
{
|
||
|
int cnt;
|
||
|
|
||
|
cnt = buffer.ReadShort();
|
||
|
fromPage = new string[cnt];
|
||
|
for (int i = 0; i < cnt; i++)
|
||
|
fromPage[i] = buffer.ReadS();
|
||
|
|
||
|
cnt = buffer.ReadShort();
|
||
|
toPage = new string[cnt];
|
||
|
for (int i = 0; i < cnt; i++)
|
||
|
toPage[i] = buffer.ReadS();
|
||
|
}
|
||
|
}
|
||
|
}
|