예제 #1
0
    // 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));
    }
예제 #2
0
    // 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);
    }
예제 #3
0
 // Move Character to Cell position
 public void MoveCharacterTo(CharacterScript character, Cell cell, MoveCharacterToCallBack callback /*, caracteristicas*/)
 {
     StartCoroutine(MoveCharacterToAsync(character, cell, callback));
 }
예제 #4
0
 // Automatically show move area, select the destination cell and move to cell
 public void IAMove(CharacterScript character, Cell destiny, MoveCharacterToCallBack callback)
 {
     StartCoroutine(IAMoveAsync(character, destiny, callback));
 }