Example #1
0
    public static Unit getSameIdUnit_Towards_onTable(Unit u1, Vector2Int direction, Unit[,] table)
    {
        Unit tempUnit = BoardUtilities.getUnitOnTable(u1.CurrentColumn + direction.x, u1.CurrentRow + direction.y, table);

        if (tempUnit)
        {
            if (BoardUtilities.hasSameID(u1, tempUnit))
            {
                return(tempUnit);
            }
        }
        return(null);
    }
Example #2
0
    void switchUnit_Towards(Vector2Int direction)
    {
        Unit targetUnit = BoardUtilities.getUnitOnTable(cueUnit.thisUnit.CurrentColumn + direction.x, cueUnit.thisUnit.CurrentRow + direction.y, unitsTable);

        if (targetUnit == null)
        {
            //Debug.Log("out!");
            throw new System.Exception("invalid unit to switch towards");
        }
        else
        {
            /*only need to move the target unit, the cue unit is following the pointer*/
            targetUnit.moveTo(new Vector2Int(-direction.x, -direction.y));
            //BoardUtilities.switchUnitsCoord(cueUnit.thisUnit, targetUnit, unitsTable);//+++++++++++

            //          tryMakeBlock (cueUnit);
            //          tryMakeBlock (targetUnit);
        }
    }