Beispiel #1
0
    void startAtMovableTile()
    {
        //GameObject[] mvTiles = GameObject.FindGameObjectsWithTag("Movable");
        int startIndex = 7;
        int endIndex   = RandomRangeExcept(40, 80, 40);

        TileUnit tileStartUnit = greenTiles[startIndex] as TileUnit;
        TileUnit tileEndUnit   = tileNodes[17, 28];             //greenTiles[endIndex] as TileUnit;

        GameObject tileStart = tileStartUnit.getGameObject();
        GameObject tileEnd   = tileEndUnit.getGameObject();

        //Place Player
        GameObject pInstance = GameObject.Find("Player");
        Vector3    v;

        v.x = tileStart.transform.position.x;
        v.y = tileStart.transform.position.y;
        v.z = tileStart.transform.position.z - 50;
        pInstance.transform.position = v;

        //Place CaptureFlag
        GameObject fInstance = GameObject.Find("CaptureFlag");
        Vector3    v2;

        v2.x = tileEnd.transform.position.x;
        v2.y = tileEnd.transform.position.y;
        v2.z = tileEnd.transform.position.z - 50;
        fInstance.transform.position = v2;

        genPath(tileStartUnit, tileEndUnit);
    }
Beispiel #2
0
    float getHeuristic(TileUnit baseTile, TileUnit tile)
    {
        float      valX, valY;
        GameObject objBase = baseTile.getGameObject();
        GameObject obj     = tile.getGameObject();

        valX = Mathf.Abs(objBase.transform.position.x - obj.transform.position.x);
        valY = Mathf.Abs(objBase.transform.position.y - obj.transform.position.y);

        return(valX + valY);
    }
Beispiel #3
0
    float getHeuristic(TileUnit baseTile, TileUnit tile)
    {
        float valX, valY;
        GameObject objBase = baseTile.getGameObject();
        GameObject obj = tile.getGameObject();

        valX = Mathf.Abs(objBase.transform.position.x - obj.transform.position.x);
        valY = Mathf.Abs(objBase.transform.position.y - obj.transform.position.y);

        return valX + valY;
    }