Exemplo n.º 1
0
    public void DepartFromTile(UrbTile Tile, UrbAgent Agent)
    {
        int Xoffset = 0;
        int Yoffset = 0;

        if (X == 1 && Y == 1)
        {
            UnprintAtTile(Print[0][0], Tile, Agent);
            s_ArriveAtTile_p.End();
            return;
        }

        if (X > 2 && Y > 2)
        {
            Vector2 Voffset = GetOffset();
            Xoffset = (int)Voffset.x;
            Yoffset = (int)Voffset.y;
        }

        for (int y = 0; y < Print.Length; y++)
        {
            for (int x = 0; x < Print[y].Length; x++)
            {
                UrbTile FillingTile = Tile.GetRelativeTile(x + Xoffset, y + Yoffset);

                if (FillingTile == null)
                {
                    continue;
                }

                UrbTileprintFill Fill = Print[y][x];
                UnprintAtTile(Fill, FillingTile, Agent);
            }
        }
    }
Exemplo n.º 2
0
 protected void Initialize(string PrintMap = "")
 {
     if (string.IsNullOrEmpty(PrintMap))
     {
         Print       = new UrbTileprintFill[1][];
         Print[0]    = new UrbTileprintFill[1];
         Print[0][0] = UrbTileprintFill.Occupy;
         SynchronizeDimensions();
     }
     else
     {
         LoadPrintMapFromString(PrintMap);
     }
 }
Exemplo n.º 3
0
    protected void LoadPrintMapFromString(string PrintMap)
    {
        if (string.IsNullOrEmpty(PrintMap))
        {
            Debug.LogError("Attempting to Read Empty or Null String for Printmap");
            return;
        }
        string[] Rows = PrintMap.Split(new string[] { "\n", "\r\n" }, System.StringSplitOptions.RemoveEmptyEntries);

        char[] testCharacters = new char[MaxTileprint];

        for (int i = 0; i < MaxTileprint; i++)
        {
            testCharacters[i] = i.ToString()[0];
        }


        Print = new UrbTileprintFill[Rows.Length][];

        Y = Rows.Length;
        X = 0;

        for (int y = 0; y < Rows.Length; y++)
        {
            char[] row = Rows[y].ToCharArray();
            Print[y] = new UrbTileprintFill[row.Length];
            for (int x = 0; x < row.Length; x++)
            {
                X = (row.Length > X) ? row.Length : X;

                Print[y][x] = UrbTileprintFill.Empty;
                for (int i = 0; i < MaxTileprint; i++)
                {
                    if (row[x] == testCharacters[i])
                    {
                        Print[y][x] = (UrbTileprintFill)i;

                        if (i > 0)
                        {
                            TileCount++;
                        }
                        break;
                    }
                }
            }
        }
    }
Exemplo n.º 4
0
    public bool TilePrintCollisionCheck(UrbTile Tile)
    {
        int Xoffset = 0;
        int Yoffset = 0;

        if (X > 2 && Y > 2)
        {
            Vector2 Voffset = GetOffset();
            Xoffset = (int)Voffset.x;
            Yoffset = (int)Voffset.y;
        }

        for (int y = 0; y < Print.Length; y++)
        {
            for (int x = 0; x < Print[y].Length; x++)
            {
                UrbTile CheckedTile = Tile.GetRelativeTile(x + Xoffset, y + Yoffset);

                if (CheckedTile == null)
                {
                    return(true);
                }

                UrbTileprintFill Fill = Print[y][x];
                switch (Fill)
                {
                case UrbTileprintFill.Block:
                case UrbTileprintFill.Occupy:
                    if (CheckedTile.Blocked)
                    {
                        return(true);
                    }
                    break;

                default:
                    break;
                }
            }
        }

        return(false);
    }
Exemplo n.º 5
0
    protected void UnprintAtTile(UrbTileprintFill Fill, UrbTile Tile, UrbAgent Agent)
    {
        switch (Fill)
        {
        case UrbTileprintFill.Block:
            if (Tile.Occupants.Contains(Agent))
            {
                Tile.Occupants.Remove(Agent);
                Tile.Blocked = false;
            }
            break;

        case UrbTileprintFill.Occupy:
            if (Tile.Occupants.Contains(Agent))
            {
                Tile.Occupants.Remove(Agent);
            }
            break;

        default:
            break;
        }
    }
Exemplo n.º 6
0
    protected static void PrintAtTile(UrbTileprintFill Fill, UrbTile Tile, UrbAgent Agent)
    {
        switch (Fill)
        {
        case UrbTileprintFill.Block:
            if (!Tile.Occupants.Contains(Agent))
            {
                Tile.Occupants.Add(Agent);
                Tile.Blocked = true;
            }
            break;

        case UrbTileprintFill.Occupy:
            if (!Tile.Occupants.Contains(Agent))
            {
                Tile.Occupants.Add(Agent);
            }
            break;

        default:
            break;
        }
    }