Пример #1
0
    public Locator MatchingLoc(TileStats tilestat, MapHelper.LocatorDirection dir)
    {
        List <Locator> match = new List <Locator>();

        foreach (Locator loc in tilestat.locators)
        {
            switch (dir)
            {
            case MapHelper.LocatorDirection.North:

                if (loc.dir == MapHelper.LocatorDirection.South)
                {
                    match.Add(loc);
                    break;
                }
                break;

            case MapHelper.LocatorDirection.East:

                if (loc.dir == MapHelper.LocatorDirection.West)
                {
                    match.Add(loc);
                    break;
                }
                break;

            case MapHelper.LocatorDirection.South:

                if (loc.dir == MapHelper.LocatorDirection.North)
                {
                    match.Add(loc);
                    break;
                }
                break;

            case MapHelper.LocatorDirection.West:

                if (loc.dir == MapHelper.LocatorDirection.East)
                {
                    match.Add(loc);
                    break;
                }
                break;
            }
        }

        Locator[] matchArray = match.ToArray();
        return(matchArray[UnityEngine.Random.Range(0, matchArray.Length)]);
    }
Пример #2
0
    public bool isLocatorOverlap(int xPos, int yPos, MapHelper.LocatorDirection dir)
    {
        //print("check locator: " + xPos + " " + yPos);
        //print("locator overlapping at: ");
        switch (dir)
        {
        case MapHelper.LocatorDirection.West:
            for (int i = -2; i < 5; i++)
            {
                for (int j = 1; j < 10; j++)
                {
                    if (currentMap.HasTile(new Vector3Int(xPos + i, yPos + j, 0)))
                    {
                        //print("x: " + i + ", y: " + j);
                        //print(new Vector3Int(xPos + i, yPos + j, 0));
                        return(true);
                    }
                }
            }
            break;

        case MapHelper.LocatorDirection.South:
            for (int i = -1; i > -10; i--)
            {
                for (int j = -2; j < 5; j++)
                {
                    if (currentMap.HasTile(new Vector3Int(xPos + i, yPos + j, 0)))
                    {
                        //print("x: " + i + ", y: " + j);
                        //print(new Vector3Int(xPos + i, yPos + j, 0));
                        return(true);
                    }
                }
            }
            break;

        case MapHelper.LocatorDirection.East:
            for (int i = -2; i < 5; i++)
            {
                for (int j = -1; j > -10; j--)
                {
                    if (currentMap.HasTile(new Vector3Int(xPos + i, yPos + j, 0)))
                    {
                        //print("x: " + i + ", y: " + j);
                        //print(new Vector3Int(xPos + i, yPos + j, 0));
                        return(true);
                    }
                }
            }
            break;

        case MapHelper.LocatorDirection.North:
            for (int i = 1; i < 10; i++)
            {
                for (int j = -2; j < 5; j++)
                {
                    if (currentMap.HasTile(new Vector3Int(xPos + i, yPos + j, 0)))
                    {
                        //print("x: " + i + ", y: " + j);
                        //print(new Vector3Int(xPos + i, yPos + j, 0));
                        return(true);
                    }
                }
            }
            break;
        }

        return(false);
    }