예제 #1
0
    private void Awake()
    {
        if (Instance != null)
        {
            DebugTools.LogError("Two instances of GameManager found in current scene. Second one is getting disabled.");
            return;
        }

        Instance = this;
    }
예제 #2
0
    private bool IsConditionMet(SerializedProperty property)
    {
        switch (property.propertyType)
        {
        case SerializedPropertyType.Boolean:
            return(property.boolValue);

        case SerializedPropertyType.ObjectReference:
            return(property.objectReferenceValue != null);

        default:
            DebugTools.LogError("Data type of the property used for conditional hiding [{0}] is currently not supported", property.propertyType);
            return(true);
        }
    }
예제 #3
0
    static public Queue <Tile> GetPathToDestination(Tile destination, Tile origin, bool canUseDiagonals, Queue <Tile> pathQueue = null)
    {
        if (pathQueue == null)
        {
            pathQueue = new Queue <Tile>();
        }
        else
        {
            pathQueue.Clear();
        }

        int minDistance = GridUtils.GetDistanceBetweenTiles(origin, destination);

        List <Node> tilesToCheck = new List <Node>(minDistance);
        List <Node> checkedTiles = new List <Node>(minDistance);

        tilesToCheck.Add(new Node(origin));

        bool foundPath = false;

        do
        {
            int  cheapestOpenNodeIndex = GetCheapestNodeIndexInList(tilesToCheck);
            Node currentNode           = tilesToCheck[cheapestOpenNodeIndex];

            tilesToCheck.RemoveAt(cheapestOpenNodeIndex);
            checkedTiles.Add(currentNode);

            if (currentNode.m_tile == destination)
            {
                foundPath = true;
                break;
            }

            PopulateOpenListWithNeighbours(currentNode, destination, ref tilesToCheck, checkedTiles, canUseDiagonals);
        } while (tilesToCheck.Count > 0);

        if (foundPath)
        {
            pathQueue = RetracePathFromEnd(checkedTiles, origin, pathQueue);
        }
        else
        {
            DebugTools.LogError("Couldn't find a path from {0} to {1}", origin, destination);
        }

        return(pathQueue);
    }