public override void tick() { if (toLaunch != null) { // If we're not waiting to receive event finished from Mover. if (movement == null) { // That means that, we're in the right position so... IsoUnity.Game.main.enqueueEvent(toLaunch); toLaunch = null; // Look to the action if (actionCell || actionEntity) { IsoUnity.Entities.Mover.Direction toLook = IsoUnity.Entities.Mover.getDirectionFromTo(Entity.transform, actionEntity ? actionEntity.transform : actionCell.transform); IsoUnity.GameEvent ge = new IsoUnity.GameEvent("turn"); ge.setParameter("mover", Entity.mover); ge.setParameter("direction", toLook); IsoUnity.Game.main.enqueueEvent(ge); } actionCell = null; actionEntity = null; } } if (!registered) { IsoUnity.ControllerManager.onControllerEvent += this.onControllerEvent; registered = true; } }
// Get cell where character is right now public Cell GetCellAtCharacter(CharacterScript character) { IsoUnity.Cell characterCell = character.transform.parent.transform.GetComponent(typeof(IsoUnity.Cell)) as IsoUnity.Cell; Cell cell = new Cell(characterCell.Map.getCoords(characterCell.gameObject).x, characterCell.Map.getCoords(characterCell.gameObject).y); return(cell); }
// Ralizamos la animacion de ataque, defensa... /*public void triggerAnimation(Character character, Cell cell) * { * * }*/ // Get character at selected cell public CharacterScript GetCharacterAtCell(Cell cell) { IsoUnity.Cell selectedCell = SearchCellInMap(cell); CharacterScript character = selectedCell.transform.GetComponentInChildren <CharacterScript>(); return(character); }
// Async method for IA Move private IEnumerator IAMoveAsync(CharacterScript character, Cell destiny, MoveCharacterToCallBack callback) { Entity entity = character.transform.GetComponent(typeof(Entity)) as Entity; IsoUnity.Cell characterCurrentCell = character.transform.parent.transform.GetComponent(typeof(IsoUnity.Cell)) as IsoUnity.Cell; IsoUnity.Cell destinyCell = SearchCellInMap(destiny); try { entity.mover.maxJumpSize = character.character.attributesWithFormulas.Find(x => x.attribute.id == moveHeight.id).value; } catch (NullReferenceException e) { Debug.Log("Character '" + character.character.name + "' doesn't have attribute '" + moveHeight.name + "'"); } try { CalculateDistanceArea(entity, characterCurrentCell, EventTypes.IA_MOVE, character.character.attributesWithFormulas.Find(x => x.attribute.id == moveRange.id).value, character.character.attributesWithFormulas.Find(x => x.attribute.id == moveHeight.id).value); } catch (NullReferenceException e) { Debug.Log("Character '" + character.character.name + "' doesn't have some or any of this attributes: '" + moveHeight.name + "', '" + moveRange.name + "', '" + attackHeight.name + "', '" + attackRange.name + "'"); } yield return(new WaitForSeconds(1f)); GameObject arrowObject = destinyCell.addDecoration(destinyCell.transform.position + new Vector3(0, destinyCell.WalkingHeight, 0), 0, false, true, arrow); yield return(new WaitForSeconds(1f)); GameObject.Destroy(arrowObject); cleanCells(); yield return(MoveCharacterToAsync(character, destiny, callback)); }
// Paint the cell in function of the event type private void PaintCell(IsoUnity.Cell cell, EventTypes eventType) { showSelector(cell, eventType); IsoTexture texture = null; switch (eventType) { case EventTypes.ATTACK: case EventTypes.IA_ATTACK: texture = colorAttack; break; case EventTypes.MOVE: case EventTypes.IA_MOVE: texture = colorMove; break; case EventTypes.SKILL: texture = colorSkill; break; } cell.Properties.faces[cell.Properties.faces.Length - 1].TextureMapping = texture; cell.Properties.faces[cell.Properties.faces.Length - 1].Texture = texture.getTexture(); cell.forceRefresh(); }
// Pathfinding from one character to other // Returns cells of the path (in order) public List <Cell> GetPathFromCharToChar(CharacterScript character, CharacterScript target) { Entity entity = character.transform.GetComponent(typeof(Entity)) as Entity; IsoUnity.Cell currentCell = character.transform.parent.transform.GetComponent(typeof(IsoUnity.Cell)) as IsoUnity.Cell; IsoUnity.Cell targetCell = target.transform.parent.transform.GetComponent(typeof(IsoUnity.Cell)) as IsoUnity.Cell; List <CellWithDistance> openList = new List <CellWithDistance>(); List <CellWithDistance> closeList = new List <CellWithDistance>(); float attackRan = character.character.attributesWithFormulas.Find(x => x.attribute.id == moveRange.id).value; float heighMax = character.character.attributesWithFormulas.Find(x => x.attribute.id == moveHeight.id).value; openList.Add(new CellWithDistance(currentCell, 0, null)); while (openList.Count > 0) { CellWithDistance current = openList[0]; openList.Remove(current); closeList.Add(current); if (current.cell == targetCell) { List <Cell> path = new List <Cell>(); while (current.previousCell != null) { path.Add(new Cell(current.cell.Map.getCoords(current.cell.gameObject).x, current.cell.Map.getCoords(current.cell.gameObject).y)); current = current.previousCell; } path.Reverse(); return(path); } float distanceManhattan = Mathf.Abs(current.cell.Map.getCoords(current.cell.gameObject).x - targetCell.Map.getCoords(targetCell.gameObject).x) + Mathf.Abs(current.cell.Map.getCoords(current.cell.gameObject).y - targetCell.Map.getCoords(targetCell.gameObject).y); foreach (IsoUnity.Cell neighbour in current.cell.Map.getNeightbours(current.cell)) { if (neighbour != null && !closeList.Any(x => x.cell == neighbour) && neighbour.Walkable && ((neighbour != currentCell && neighbour != targetCell && neighbour.transform.GetComponentInChildren <CharacterScript>() == null) || (neighbour == currentCell || neighbour == targetCell))) { float distanceManhattanFromCurrentToNeigh = Mathf.Abs(current.cell.Map.getCoords(current.cell.gameObject).x - neighbour.Map.getCoords(neighbour.gameObject).x) + Mathf.Abs(current.cell.Map.getCoords(current.cell.gameObject).y - neighbour.Map.getCoords(neighbour.gameObject).y); if (distanceManhattanFromCurrentToNeigh <= 1 && Mathf.Abs(neighbour.Height - current.cell.Height) <= heighMax) { if (!openList.Any(x => x.cell == neighbour)) { CellWithDistance neigh = new CellWithDistance(neighbour, current.distanceFromCharacter + distanceManhattanFromCurrentToNeigh, current); openList.Add(neigh); } else { CellWithDistance neigh = openList.Find(x => x.cell == neighbour); if (current.distanceFromCharacter + distanceManhattanFromCurrentToNeigh < neigh.distanceFromCharacter) { neigh.distanceFromCharacter = current.distanceFromCharacter + distanceManhattanFromCurrentToNeigh; neigh.previousCell = current; } } } } } } return(null); }
// Show an arrow in selectables cells private void showSelector(IsoUnity.Cell cell, EventTypes eventType, CallbackSelector callback = null) { SelectableCell selectableCell = cell.transform.gameObject.AddComponent <SelectableCell>(); selectableCell.arrow = arrow; selectableCell.selectedCellEvent = selectedCellEvent; selectableCell.previousTexture = cell.Properties.faces[cell.Properties.faces.Length - 1].TextureMapping; selectableCell.cell = cell; selectableCell.eventType = eventType; selectableCell.callback = callback; }
// Async method for teleport private IEnumerator SetCharacterPositionAsync(CharacterScript character, Cell cell, SetCharacterPositionCallBack callback) { Entity entity = character.transform.GetComponent(typeof(Entity)) as Entity; IsoUnity.Cell destinyCell = SearchCellInMap(cell); var setCharacterPositionEvent = new GameEvent("teleport", new Dictionary <string, object>() { { "mover", entity.mover }, { "cell", destinyCell }, { "synchronous", true } }); Game.main.enqueueEvent(setCharacterPositionEvent); yield return(new WaitForEventFinished(setCharacterPositionEvent)); callback(true); }
// Async method for show area private IEnumerator ShowAreaAsync(CharacterScript character, EventTypes eventType, Skills skill, ShowAreaCallBack callback) { Entity entity = character.transform.GetComponent(typeof(Entity)) as Entity; IsoUnity.Cell characterCurrentCell = character.transform.parent.transform.GetComponent(typeof(IsoUnity.Cell)) as IsoUnity.Cell; try { entity.mover.maxJumpSize = character.character.attributesWithFormulas.Find(x => x.attribute.id == moveHeight.id).value; } catch (NullReferenceException e) { Debug.Log("Character '" + character.character.name + "' doesn't have attribute '" + moveHeight.name + "'"); } selectedCellEvent = new GameEvent("selected cell", new Dictionary <string, object>() { { "synchronous", true } }); Game.main.enqueueEvent(selectedCellEvent); try { if (eventType == EventTypes.MOVE) { CalculateDistanceArea(entity, characterCurrentCell, eventType, character.character.attributesWithFormulas.Find(x => x.attribute.id == moveRange.id).value, character.character.attributesWithFormulas.Find(x => x.attribute.id == moveHeight.id).value); } else if (eventType == EventTypes.ATTACK) { CalculateDistanceArea(entity, characterCurrentCell, eventType, character.character.attributesWithFormulas.Find(x => x.attribute.id == attackRange.id).value, character.character.attributesWithFormulas.Find(x => x.attribute.id == attackHeight.id).value); } } catch (NullReferenceException e) { Debug.Log(e); } Dictionary <string, object> outParams; yield return(new WaitForEventFinished(selectedCellEvent, out outParams)); cleanCells(); IsoUnity.Cell selectedCell = outParams["cell"] as IsoUnity.Cell; Cell returnCell = new Cell((int)selectedCell.Map.getCoords(selectedCell.gameObject).x, (int)selectedCell.Map.getCoords(selectedCell.gameObject).y); callback(returnCell, true); }
private void cleanSkillCells() { SelectableCell[] selectableCells = FindObjectsOfType <SelectableCell>(); foreach (SelectableCell selectableCell in selectableCells) { IsoUnity.Cell cell = selectableCell.cell; if (selectableCell.previousTexture != null) { cell.Properties.faces[cell.Properties.faces.Length - 1].TextureMapping = selectableCell.previousTexture; cell.Properties.faces[cell.Properties.faces.Length - 1].Texture = selectableCell.previousTexture.getTexture(); } else { cell.Properties.faces[cell.Properties.faces.Length - 1].TextureMapping = null; cell.Properties.faces[cell.Properties.faces.Length - 1].Texture = null; } cell.forceRefresh(); } }
// Async method for move character private IEnumerator MoveCharacterToAsync(CharacterScript character, Cell cell, MoveCharacterToCallBack callback) { // Get entity of character Entity entity = character.transform.GetComponent(typeof(Entity)) as Entity; IsoUnity.Cell destinyCell = SearchCellInMap(cell); // Set event var moveCharacterTo = new GameEvent("move", new Dictionary <string, object>() { { "mover", entity.mover }, { "cell", destinyCell }, { "synchronous", true } }); // Launch event Game.main.enqueueEvent(moveCharacterTo); yield return(new WaitForEventFinished(moveCharacterTo)); callback(true); }
private IsoUnity.Cell SearchCellInMap(Cell cell) { // Get map of scene IsoUnity.Map map = GameObject.Find("Map").GetComponent <IsoUnity.Map>(); // Search cell with same coords IsoUnity.Cell isoCell = null; foreach (IsoUnity.Cell c in map.Cells) { var coords = map.getCoords(c.gameObject); if (coords.x == cell.x && coords.y == cell.y) { isoCell = c; } } if (isoCell == null) { Debug.Log("The cell selected (coords x: " + cell.x + ", y: " + cell.y + ") doesn't exists in the current map!"); } return(isoCell); }
// Get characters in attack range of the character // Returns the list of all the characters in the attack range public List <CharacterScript> GetAttackRangeTargets(CharacterScript character) { List <CharacterScript> characters = new List <CharacterScript>(); Entity entity = character.transform.GetComponent(typeof(Entity)) as Entity; IsoUnity.Cell currentCell = character.transform.parent.transform.GetComponent(typeof(IsoUnity.Cell)) as IsoUnity.Cell; List <CellWithDistance> openList = new List <CellWithDistance>(); List <CellWithDistance> closeList = new List <CellWithDistance>(); float attackRan = character.character.attributesWithFormulas.Find(x => x.attribute.id == attackRange.id).value; float heighMax = character.character.attributesWithFormulas.Find(x => x.attribute.id == attackHeight.id).value; openList.Add(new CellWithDistance(currentCell, 0, null)); while (openList.Count > 0) { CellWithDistance current = openList[0]; openList.Remove(current); closeList.Add(current); foreach (IsoUnity.Cell neighbour in current.cell.Map.getNeightbours(current.cell)) { if (neighbour != null && !closeList.Any(x => x.cell == neighbour) && neighbour.Walkable) { float distanceManhattanFromCurrentToNeigh = Mathf.Abs(current.cell.Map.getCoords(current.cell.gameObject).x - neighbour.Map.getCoords(neighbour.gameObject).x) + Mathf.Abs(current.cell.Map.getCoords(current.cell.gameObject).y - neighbour.Map.getCoords(neighbour.gameObject).y); float distanceManhattanFromCharacterToNeigh = current.distanceFromCharacter + distanceManhattanFromCurrentToNeigh; if (distanceManhattanFromCurrentToNeigh <= 1 && distanceManhattanFromCharacterToNeigh <= attackRan && Mathf.Abs(neighbour.Height - current.cell.Height) <= heighMax) { if (!openList.Any(x => x.cell == neighbour)) { CharacterScript charAtCell = GetCharacterAtCell(new Cell(neighbour.Map.getCoords(neighbour.gameObject).x, neighbour.Map.getCoords(neighbour.gameObject).y)); if (charAtCell != null) { characters.Add(charAtCell); } openList.Add(new CellWithDistance(neighbour, distanceManhattanFromCharacterToNeigh, null)); } } } } } return(characters); }
/******************* PRIVATE AUX METHODS *******************/ // Calculate the area of the event type private List <CharacterScript> CalculateDistanceArea(Entity entity, IsoUnity.Cell currentCell, EventTypes eventType, int distanceMax, int heighMax) { List <CellWithDistance> openList = new List <CellWithDistance>(); List <CellWithDistance> closeList = new List <CellWithDistance>(); List <CharacterScript> charactersInArea = new List <CharacterScript>(); charactersInArea.Add(currentCell.transform.GetComponentInChildren <CharacterScript>()); openList.Add(new CellWithDistance(currentCell, 0, null)); while (openList.Count > 0) { CellWithDistance current = openList[0]; openList.Remove(current); closeList.Add(current); foreach (IsoUnity.Cell neighbour in current.cell.Map.getNeightbours(current.cell)) { if (neighbour != null && !closeList.Any(x => x.cell == neighbour) && neighbour.Walkable) { float distanceManhattanFromCurrentToNeigh = Mathf.Abs(current.cell.Map.getCoords(current.cell.gameObject).x - neighbour.Map.getCoords(neighbour.gameObject).x) + Mathf.Abs(current.cell.Map.getCoords(current.cell.gameObject).y - neighbour.Map.getCoords(neighbour.gameObject).y); float distanceManhattanFromCharacterToNeigh = current.distanceFromCharacter + distanceManhattanFromCurrentToNeigh; if (distanceManhattanFromCurrentToNeigh <= 1 && distanceManhattanFromCharacterToNeigh <= distanceMax && Mathf.Abs(neighbour.Height - current.cell.Height) <= heighMax && (((eventType == EventTypes.IA_MOVE || eventType == EventTypes.MOVE) && neighbour.transform.GetComponentInChildren <CharacterScript>() == null) || (eventType != EventTypes.MOVE && eventType != EventTypes.IA_MOVE))) { if (!openList.Any(x => x.cell == neighbour)) { PaintCell(neighbour, eventType); openList.Add(new CellWithDistance(neighbour, distanceManhattanFromCharacterToNeigh, null)); CharacterScript character = neighbour.transform.GetComponentInChildren <CharacterScript>(); if (character != null) { charactersInArea.Add(character); } } } } } } return(charactersInArea); }
public void paintCells(Cell cell, Skill skill, IsoTexture color, Entity entity = null) { Vector2 position = cell.Map.getCoords(cell.gameObject); changedCells = new Cell[((skill.getDistance() * 2) + 1) * ((skill.getDistance() * 2) + 1)]; oldTextures = new IsoTexture[((skill.getDistance() * 2) + 1) * ((skill.getDistance() * 2) + 1)]; int contador = 0; //busqueda directa float xcentral = position.x; float ycentral = position.y; //Vamos a marcar todas las casillas que esten en la distancia de la habilidad for (float i = position.x - skill.getDistance(); i <= position.x + skill.getDistance(); i++) { //vamos aumentando el radio de casillas hasta la distancia de la habilidad for (float j = position.y - skill.getDistance(); j <= position.y + skill.getDistance(); j++) { IsoUnity.Cell celdaAPintar = cell.Map.getCell(new Vector2(i, j)); if (celdaAPintar != null) { if (entity != null) { if (RoutePlanifier.planifyRoute(entity.mover, celdaAPintar)) { int distance = 0; Cell measuring; while (distance <= skill.getDistance() && (measuring = RoutePlanifier.next(entity.mover))) { entity.Position = measuring; distance++; } entity.Position = cell; RoutePlanifier.cancelRoute(entity.mover); if (distance > skill.getDistance()) { continue; } } else { continue; } } if ((int)Mathf.Abs(Mathf.Abs(i - xcentral) + Mathf.Abs(j - ycentral)) <= skill.getDistance()) { changedCells[contador] = celdaAPintar; oldTextures[contador] = celdaAPintar.Properties.faces[celdaAPintar.Properties.faces.Length - 1].TextureMapping; celdaAPintar.Properties.faces[celdaAPintar.Properties.faces.Length - 1].TextureMapping = color; celdaAPintar.Properties.faces[celdaAPintar.Properties.faces.Length - 1].Texture = color.getTexture(); celdaAPintar.forceRefresh(); contador++; } } } } }
public void onControllerEvent(IsoUnity.ControllerEventArgs args) { // # Avoid responding controller event when inactive if (!active) { return; } // # Normal threatment // Multiple controller events only give one launch result per tick if (toLaunch == null) { if (args.cell != null) { var cell = args.cell; if (args.cell.VirtualNeighbors.Count > 0) { cell = args.cell.VirtualNeighbors[0].Destination; } GameEvent ge = new GameEvent(); ge.setParameter("mover", this.Entity.mover); ge.setParameter("cell", cell); ge.Name = "teleport"; Game.main.enqueueEvent(ge); } // Otherwise, the controller event should contain keys pressed else { int to = -1; if (args.LEFT) { to = 0; } else if (args.UP) { to = 1; } else if (args.RIGHT) { to = 2; } else if (args.DOWN) { to = 3; } if (to > -1) { if (movement == null || !movingArrow) { if (Entity == null) { Debug.Log("Null!"); } IsoUnity.Cell destination = Entity.Position.Map.getNeightbours(Entity.Position)[to]; // Can move to checks if the entity can DIRECT move to this cells. // This should solve bug #29 IsoUnity.Entities.Mover em = this.Entity.GetComponent <IsoUnity.Entities.Mover>(); if (em != null && em.CanMoveTo(destination)) { IsoUnity.GameEvent ge = new IsoUnity.GameEvent(); ge.setParameter("mover", this.Entity.mover); ge.setParameter("cell", destination); ge.setParameter("synchronous", true); ge.Name = "move"; IsoUnity.Game.main.enqueueEvent(ge); movement = ge; } else { IsoUnity.GameEvent ge = new IsoUnity.GameEvent(); ge.setParameter("mover", this.Entity.mover); ge.setParameter("direction", fromIndex(to)); ge.setParameter("synchronous", true); ge.Name = "turn"; IsoUnity.Game.main.enqueueEvent(ge); movement = ge; } movingArrow = true; } } } } }
void OnSceneGUI() { /*SceneView sceneView = SceneView.currentDrawingSceneView; * if(Event.current.button == 0 ) * if(Event.current.rawType == EventType.MouseDrag){ * movingObject = true; * * for(int i = 0; i<cell.Length; i++){ * //if(Selection.Contains(c.gameObject)); * cell[i].Map.updateCell(cell[i], Event.current.type == EventType.MouseUp); * } * sceneView.Repaint(); * //Event.current.Use(); * }else if(Event.current.rawType == EventType.mouseMove){ * ratonMovido = true; * }else if(Event.current.rawType == EventType.mouseMove && HandleUtility.niceMouseDelta > 0 && movingObject){ * * }else if(Event.current.rawType == EventType.MouseUp){ * if(movingObject) * movingObject = false; * }*/ Cell c = (Cell)target; if (target == cell[0]) { Bounds bounds = new Bounds(cell[0].GetComponent <Renderer>().bounds.center, new Vector3(0, 0, 0)); for (int i = 0; i < cell.Length; i++) { bounds.Encapsulate(cell[i].GetComponent <Renderer>().bounds); } MyHandles.DragHandleResult dhResult; Vector3 screenStart = SceneView.currentDrawingSceneView.camera.WorldToScreenPoint(bounds.center); Vector3 end = SceneView.currentDrawingSceneView.camera.ScreenToWorldPoint(screenStart + new Vector3(0, 120, 0)); float height = (end - bounds.center).magnitude; end = bounds.center + new Vector3(0, height, 0); Handles.DrawLine(bounds.center, end); Vector3 newPosition = MyHandles.DragHandle(end, angle, 0.1f * height, Handles.CubeCap, Color.white, Color.gray, out dhResult); switch (dhResult) { case MyHandles.DragHandleResult.LMBPress: heights.Clear(); origin = newPosition; break; case MyHandles.DragHandleResult.LMBDrag: if (justCreated) { heights.Clear(); origin = newPosition; justCreated = false; } diference = (newPosition - origin) * 2; break; case MyHandles.DragHandleResult.LMBRelease: diference = ident; break; } } if (!heights.ContainsKey(c)) { heights.Add(c, c.Height); } if (diference.y != 0) { Undo.RecordObject(target, "Cell height changed..."); float height = c.Height; c.Height = heights[c] + diference.y; EditorUtility.SetDirty(c); if (c.Height != height) { c.gameObject.BroadcastMessage("Update"); } } }
public CellWithDistance(IsoUnity.Cell cell, float distance, CellWithDistance previous) { this.cell = cell; this.distanceFromCharacter = distance; this.previousCell = previous; }
// Async method for skills private IEnumerator SkillsAsync(CharacterScript character, EventTypes eventType, Skills skill, SkillsCallBack callback) { Entity entity = character.transform.GetComponent(typeof(Entity)) as Entity; IsoUnity.Cell characterCurrentCell = character.transform.parent.transform.GetComponent(typeof(IsoUnity.Cell)) as IsoUnity.Cell; try { entity.mover.maxJumpSize = character.character.attributesWithFormulas.Find(x => x.attribute.id == moveHeight.id).value; } catch (NullReferenceException e) { Debug.Log("Character '" + character.character.name + "' doesn't have attribute '" + moveHeight.name + "'"); } selectedCellEvent = new GameEvent("selected cell", new Dictionary <string, object>() { { "synchronous", true } }); Game.main.enqueueEvent(selectedCellEvent); // Get all characters List <CharacterScript> characters = FindObjectsOfType <CharacterScript>().ToList(); List <CharacterScript> targets = null; // Switch if (skill.skillType == SkillTypes.SINGLE_TARGET) { foreach (CharacterScript target in characters) { IsoUnity.Cell targetCell = target.transform.parent.transform.GetComponent(typeof(IsoUnity.Cell)) as IsoUnity.Cell; PaintCell(targetCell, eventType); } } else if (skill.skillType == SkillTypes.AREA) { targets = CalculateDistanceArea(entity, characterCurrentCell, eventType, skill.areaRange, int.MaxValue); PaintCell(characterCurrentCell, eventType); } else if (skill.skillType == SkillTypes.AREA_IN_OBJETIVE) { foreach (IsoUnity.Cell cell in characterCurrentCell.Map.Cells) { showSelector(cell, eventType, ((result) => { cleanSkillCells(); targets = CalculateDistanceArea(null, result, eventType, skill.areaRange, int.MaxValue); PaintCell(cell, eventType); })); } } Dictionary <string, object> outParams; yield return(new WaitForEventFinished(selectedCellEvent, out outParams)); cleanCells(); IsoUnity.Cell selectedCell = outParams["cell"] as IsoUnity.Cell; Cell returnCell = new Cell((int)selectedCell.Map.getCoords(selectedCell.gameObject).x, (int)selectedCell.Map.getCoords(selectedCell.gameObject).y); if (skill.skillType == SkillTypes.SINGLE_TARGET) { targets = new List <CharacterScript>(); targets.Add(selectedCell.transform.GetComponentInChildren <CharacterScript>()); } var showDecoration = new GameEvent("show decoration animation", new Dictionary <string, object>() { { "objective", targets[0].gameObject }, { "animation", skill.animationName }, { "synchronous", true } }); Game.main.enqueueEvent(showDecoration); yield return(new WaitForEventFinished(showDecoration)); callback(returnCell, true, targets); }