// Update is called once per frame publicoverridevoidUpdate() { if (sequence.Count == 0) return; if(currentIndex < sequence.Count) { sequence[currentIndex].Update(); } }
publicclassSSActionManager : MonoBehaviour { private Dictionary<int, SSAction> actions = new Dictionary<int, SSAction>(); private List<SSAction> waitingAdd = new List<SSAction>(); private List<int> waitingDelete = new List<int>(); // Use this for initialization protectedvoidStart() {
}
// Update is called once per frame protectedvoidUpdate() { foreach (SSAction ac in waitingAdd) { actions[ac.GetInstanceID()] = ac; } waitingAdd.Clear();
foreach(KeyValuePair<int, SSAction> kv in actions) { SSAction ac = kv.Value; if (ac.destory) { waitingDelete.Add(ac.GetInstanceID()); }elseif (ac.enable) { ac.Update(); } }
foreach(int key in waitingDelete) { SSAction ac = actions[key]; actions.Remove(key); Object.Destroy(ac); } waitingDelete.Clear(); }
publicclassCCActionManager : SSActionManager, ISSActionCallback { public FirstController sceneController; public CCMoveToAction moveBoat; public CCSequenceAction moveRole; //移动角色是一个组合动作 // Use this for initialization protected new voidStart() { sceneController = SSDirector.GetInstance().CurrentSceneController as FirstController; sceneController.actionManager = this; }
// Update is called once per frame protected new voidUpdate() { base.Update(); }
publicclassJudger : MonoBehaviour { public FirstController sceneController; // Use this for initialization publicvoidStart() { sceneController = SSDirector.GetInstance().CurrentSceneController as FirstController; }
// Update is called once per frame publicvoidUpdate() { if((sceneController.currentState = Judge()) != 0) { sceneController.gaming = false; } }
publicintJudge() { if (sceneController.moving) return0; //计算两边的牧师和恶魔数量 int rightPriestNum = 0, leftPriestNum = 0, rightDevilNum = 0, leftDevilNum = 0; for (int i = 0; i < 3; i++) { if (sceneController.Priests[i].GetSide() == 1) { rightPriestNum++; } else { leftPriestNum++; }
if (sceneController.Devils[i].GetSide() == 1) { rightDevilNum++; } else { leftDevilNum++; } } if (leftPriestNum + leftDevilNum == 6) { for (int i = 0; i < 3; i++) { sceneController.Devils[i].Lose(); } return1; //win } elseif ((leftPriestNum > 0 && leftDevilNum > leftPriestNum) || (rightPriestNum > 0 && rightDevilNum > rightPriestNum)) { int attackSide; if (leftDevilNum > leftPriestNum) attackSide = -1; else attackSide = 1; for (int i = 0; i < 3; i++) { if (sceneController.Devils[i].GetSide() == attackSide) sceneController.Devils[i].Attack(); } return-1; //lose } else { return0; } } }