Exemple #1
0
    public string GetHashString()
    {
        string hashedString = GeneralStaticClass.Md5Sum(actorName + actorSalary.ToString() + actorLevel.ToString() + actorSprite.ToString());

        return(hashedString);
    }
Exemple #2
0
    IEnumerator FindPath(Vector3 _start, Vector3 _end, Element _element)
    {
        Vector3[] waypoints   = new Vector3[0];
        bool      pathSuccess = false;

        Node startNode  = grid.NodeFromWorldPoint(_start);
        Node targetNode = grid.NodeFromWorldPoint(_end);

        if (startNode.Walkable && targetNode.Walkable)
        {
            Heap <Node>    openSet   = new Heap <Node> (grid.getGridSize);
            HashSet <Node> closedSet = new HashSet <Node> ();

            openSet.Add(startNode);

            while (openSet.Count > 0)
            {
                Node currentNode = openSet.RemoveFirst();
                closedSet.Add(currentNode);

                if (currentNode == targetNode)
                {
                    print("// ziel gefunden :)");
                    pathSuccess = true;

                    break;
                }

                foreach (Node neighbour in grid.GetNeighbours(currentNode))
                {
                    if (!neighbour.Walkable || closedSet.Contains(neighbour))
                    {
                        continue;
                    }

                    int elementPenalty = 200;
                    if (currentNode.ElementForTransport == _element)
                    {
                        elementPenalty = 0;
                    }
                    int newMovementCostToNeighbour = currentNode.gCost + GetDistance(currentNode, neighbour) + neighbour.movementPenalty + elementPenalty;
                    if (newMovementCostToNeighbour < neighbour.gCost || !openSet.Contains(neighbour))
                    {
                        neighbour.gCost = newMovementCostToNeighbour;
                        neighbour.hCost = GeneralStaticClass.GetDistance(neighbour, targetNode);

                        neighbour.parent = currentNode;

                        if (!openSet.Contains(neighbour))
                        {
                            openSet.Add(neighbour);
                        }
                        else
                        {
                            openSet.UpdateItem(neighbour);
                        }
                    }
                }
            }
        }
        yield return(null);

        if (pathSuccess)
        {
            waypoints = RetracePath(startNode, targetNode);
        }
        else
        {
            print("didnt find path");
        }
        pathRequestManager.FinishedProcessingPath(waypoints, pathSuccess);
    }