private void CallActionsThread(object state) { ICall call = (ICall)state; if (call.ActionProvider.ActionPacks == null || call.ActionProvider.ActionPacks.Length == 0) { call.Hangup(); return; } List <ActionPack> actions = new List <ActionPack>(call.ActionProvider.ActionPacks); while (actions.Count > 0 && call.CallState != CallState.Error && call.CallState != CallState.Disconnected && call.CallState != CallState.HangUp) { ActionPack current = actions[0]; if (current.TriggeredExecution(call)) { actions.RemoveAt(0); } Thread.Sleep(500); } if (call.CallState != CallState.Error && call.CallState != CallState.Disconnected && call.CallState != CallState.HangUp) { call.Hangup(); } }
public IAction SwapFieldObjects(Vector2Int aCell, Vector2Int bCell) { ActionPack swapAnimationActionPack = GetSwapAnimationActionPack(aCell, bCell); fieldMatrix.SwapObjectsInStorage(aCell, bCell); return(swapAnimationActionPack); }
protected void InitializeActionPack <A>() where A : ActionPack, new() { actionPack = new A(); actionPack.actionController = this; actionPack.actor = controllerPack.controlledCharacter; actionPack.OnInitialize(); }
public static ActionPack New() { GameObject pack = new GameObject { name = "ActionPack" }; ActionPack actionpack = pack.AddComponent <ActionPack>(); ActionPlayer player = pack.AddComponent <ActionPlayer>(); ActionList list = pack.AddComponent <ActionList>(); actionpack.PackPlayer = player; actionpack.PackActions = list; actionpack.ActionName = "动作套件"; return(actionpack); }
private ActionPack GetSwapAnimationActionPack(Vector2Int aCell, Vector2Int bCell) { Vector2 aCellPosition = fieldProperties.CalculateLocalFieldObjectPosition(aCell); Vector2 bCellPosition = fieldProperties.CalculateLocalFieldObjectPosition(bCell); GameObject aObject = fieldMatrix.GetObjectFromStorage(aCell).GetGameObject(); GameObject bObject = fieldMatrix.GetObjectFromStorage(bCell).GetGameObject(); ActionPack swapActionPack = new ActionPack(); swapActionPack.AddAction((callback) => { coroutinePlayer.PlayCoroutine(CoroutineAnimations.MovementWithEasingFunction(aObject, aCellPosition, bCellPosition, swapDuration, EasingFunctions.EaseOutBack, callback)); }); swapActionPack.AddAction((callback) => { coroutinePlayer.PlayCoroutine(CoroutineAnimations.MovementWithEasingFunction(bObject, bCellPosition, aCellPosition, swapDuration, EasingFunctions.EaseOutBack, callback)); }); return(swapActionPack); }
private IAction CreateNewFieldObjectsAndFillEmptyCells() { ActionPack updateActions = new ActionPack(); for (int i = 0; i < fieldProperties.GetFieldSize().x; i++) { int emptyCellsCount = 0; for (int j = 0; j < fieldProperties.GetFieldSize().y; j++) { if (fieldMatrix.GetObjectFromStorage(i, j) == null) { emptyCellsCount++; } else if (emptyCellsCount > 0) { Vector2Int newCellForCurrentObject = new Vector2Int(i, j - emptyCellsCount); Vector2Int currentCell = new Vector2Int(i, j); Vector2 newPositionForCurrentObject = fieldProperties.CalculateLocalFieldObjectPosition(newCellForCurrentObject); Vector2 currentPosition = fieldProperties.CalculateLocalFieldObjectPosition(currentCell); GameObject targetObject = fieldMatrix.GetObjectFromStorage(i, j).GetGameObject(); fieldMatrix.SwapObjectsInStorage(currentCell, newCellForCurrentObject); updateActions.AddAction((callback) => { coroutinePlayer.PlayCoroutine(CoroutineAnimations.AcceleratedMovement(targetObject, currentPosition, newPositionForCurrentObject, fieldObjectFallingStartSpeed, fieldObjectFallingVelocity, callback)); }); } } for (int j = fieldProperties.GetFieldSize().y - emptyCellsCount; j < fieldProperties.GetFieldSize().y; j++) { Vector2Int imaginaryCell = new Vector2Int(i, j + emptyCellsCount); Vector2Int actualCell = new Vector2Int(i, j); Vector2 positionToCreateObject = fieldProperties.CalculateLocalFieldObjectPosition(imaginaryCell); Vector2 positionToMoveObject = fieldProperties.CalculateLocalFieldObjectPosition(actualCell); fieldObjectCreator.CreateFieldObject(actualCell, positionToCreateObject); GameObject targetObject = fieldMatrix.GetObjectFromStorage(i, j).GetGameObject(); updateActions.AddAction((callback) => { coroutinePlayer.PlayCoroutine(CoroutineAnimations.AcceleratedMovement(targetObject, positionToCreateObject, positionToMoveObject, fieldObjectFallingStartSpeed, fieldObjectFallingVelocity, callback)); }); } } return(updateActions); }
private void Run() { JsonSerializerSettings settings = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All }; try { BehaviourConfiguration configuration = JsonConvert.DeserializeObject <BehaviourConfiguration>(File.ReadAllText(Project.ProjectFolder + "\\Behaviours.dat"), settings); Project.BehaviourConfiguration = configuration; List <ActionPack> buildInActionPacks = studio.ProjectTypeProvider.GetBuildInActionPacks(); if (buildInActionPacks != null) { Project.BehaviourConfiguration.InternalWebActionPacks.AddRange(buildInActionPacks); } } catch (Exception ex) { Dialog.CancelAllTasks("Could not load web behaviour configuration:\n" + ex.Message); } List <string> assembliesToLoad = Project.BehaviourConfiguration.WebActionpacks.FindAll(pack => pack != "BasicWebActionsPack"); if (assembliesToLoad.Count > 0) { List <LoadedAssembly> loadedAssemblies = studio.GetDLLManager().LoadAssemblies(assembliesToLoad, Studio.extensionRepresentingStudio); foreach (LoadedAssembly assembly in loadedAssemblies) { try { Type packType = assembly.Assembly.GetExportedTypes().First(ass => ass.BaseType.Name == "WebActionPack"); ActionPack pack = Activator.CreateInstance(packType) as ActionPack; Project.BehaviourConfiguration.InternalWebActionPacks.Add(pack); } catch (Exception ex) { Dialog.CancelAllTasks($"Could not load web action pack from assembly {assembly.Path}:\n\n{ex.Message}"); } } } Project.BehaviourConfiguration.Behaviours = JsonConvert.DeserializeObject <List <Behaviour> >(Project.BehaviourConfiguration.BehavioursJson, settings); }
private IAction RemoveCombinations(List <RectInt> combinations) { ActionPack removalActions = new ActionPack(); foreach (RectInt combination in combinations) { for (int i = combination.position.x; i < combination.position.x + combination.size.x; i++) { for (int j = combination.position.y; j < combination.position.y + combination.size.y; j++) { Vector2Int currentCell = new Vector2Int(i, j); if (fieldMatrix.GetObjectFromStorage(currentCell) != null) { removalActions.AddAction(fieldObjectRemover.RemoveFieldObject(currentCell)); } } } } return(removalActions); }
public static void AddLoop() { ActionPack newpack = LoopAction.NewObject(); Set2Object(newpack.gameObject); }
public static void AddActionPack() { ActionPack newpack = ActionPack.New(); Set2Object(newpack.gameObject); }
void Awake() { actio = Genel.GetComponent <ActionPack> (); }