//Check turns private static void NCalcExtensionFunctions(string name, FunctionArgs args) { //to avoid bug args.Result = 0; // int turns = 0; if (args.Parameters.Length == 1) { turns = int.Parse(args.Parameters [0].Evaluate().ToString()); } if (args.Parameters.Length == 2) { turns = int.Parse(args.Parameters [1].Evaluate().ToString()); } if (args.Parameters.Length == 3) { turns = int.Parse(args.Parameters [1].Evaluate().ToString()); } NCalcFunctionModel nCalcFunction = new NCalcFunctionModel(name, args); Queue <NCalcFunctionModel> characterQueue = new Queue <NCalcFunctionModel> (); //Depending on turn, add to queue for (int i = 0; i < turns; i++) { characterQueue.Enqueue(nCalcFunction); Debug.Log(name + " ADDED TO QUEUE"); } if (isPlayer) { playerQueueList.Add(characterQueue); Debug.Log("QUEUE ADDED TO PLAYER LIST"); Debug.Log("PLAYERQUEUELIST COUNT: " + playerQueueList.Count); } else { enemyQueueList.Add(characterQueue); Debug.Log("QUEUE ADDED TO ENEMY"); Debug.Log("ENEMYQUEUELIST COUNT: " + enemyQueueList.Count); } }
//activate character if turn is existing public static IEnumerator ActivateCharacters() { if (isPlayer) { if (playerQueueList.Count > 0) { for (int i = 0; i < playerQueueList.Count; i++) { //remove item in list if no queues if (playerQueueList [i].Count == 0) { Debug.Log("NO MORE QUEUES IN THIS PLAYER INDEX"); playerQueueList.RemoveAt(i); break; } Debug.Log("PLAYER QUEUE COUNT IN LIST" + playerQueueList [i].Count); if (playerQueueList [i].Count == 1) { NCalcFunctionModel nCalcFunction = playerQueueList [i].Dequeue(); CalculateCharacter(nCalcFunction.name, nCalcFunction.args); Debug.Log("CALCULATING: " + nCalcFunction.name); ResetPlayer(nCalcFunction.name); } else { NCalcFunctionModel nCalcFunction = playerQueueList [i].Dequeue(); CalculateCharacter(nCalcFunction.name, nCalcFunction.args); Debug.Log("CALCULATING: " + nCalcFunction.name); } } } } else { if (enemyQueueList.Count > 0) { for (int i = 0; i < enemyQueueList.Count; i++) { //remove item in list if no queues if (enemyQueueList [i].Count == 0) { Debug.Log("NO MORE QUEUES IN THIS ENEMY INDEX"); enemyQueueList.RemoveAt(i); break; } Debug.Log("ENEMY QUEUE COUNT IN LIST" + enemyQueueList [i].Count); if (enemyQueueList [i].Count == 1) { NCalcFunctionModel nCalcFunction = enemyQueueList [i].Dequeue(); CalculateCharacter(nCalcFunction.name, nCalcFunction.args); Debug.Log("CALCULATING: " + nCalcFunction.name); } else { NCalcFunctionModel nCalcFunction = enemyQueueList [i].Dequeue(); CalculateCharacter(nCalcFunction.name, nCalcFunction.args); Debug.Log("CALCULATING: " + nCalcFunction.name); } } } } yield break; }