-
Notifications
You must be signed in to change notification settings - Fork 0
/
CCActionManager.cs
85 lines (75 loc) · 2.09 KB
/
CCActionManager.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CCActionManager : SSActionManager, ISSActionCallback, IActionManager
{
private FirstSceneController sceneControl;
private List<CCFlyAction> flys = new List<CCFlyAction>();
private int diskNumber = 0;
private List<SSAction> used = new List<SSAction>();
private List<SSAction> free = new List<SSAction>();
public void setDiskNumber(int dn)
{
diskNumber = dn;
}
public int getDiskNumber()
{
return diskNumber;
}
public SSAction getSSAction()
{
SSAction action = null;
if(free.Count > 0)
{
action = free[0];
free.Remove(free[0]);
}
else
{
action = ScriptableObject.Instantiate<CCFlyAction>(flys[0]);
}
used.Add(action);
return action;
}
public void freeSSAction(SSAction action)
{
foreach(SSAction a in used)
{
if(a.GetInstanceID() == action.GetInstanceID())
{
a.reset();
free.Add(a);
used.Remove(a);
break;
}
}
}
protected void Start()
{
sceneControl = (FirstSceneController)Director.getInstance().current;
sceneControl.actionManager = this;
flys.Add(CCFlyAction.getCCFlyAction());
}
private new void Update()
{
if (sceneControl.getGameState() == GameState.RUNNING)
base.Update();
}
public void SSActionEvent(SSAction source, SSActionEventType events = SSActionEventType.Completed, int intPram = 0
, string strParm = null, Object objParm = null)
{
if(source is CCFlyAction)
{
diskNumber--;
Singleton<DiskFactory>.Instance.freeDisk(source.gameObject);
freeSSAction(source);
}
}
public void startThrow(Queue<GameObject> diskQueue)
{
foreach(GameObject i in diskQueue)
{
runAction(i, getSSAction(), (ISSActionCallback)this);
}
}
}