コード例 #1
0
 public void ChangeItemType(BuildingItemType type)
 {
     if (type != BuildingItemType.None && type != lastUsedBuildingType)
     {
         if (type == BuildingItemType.Tower)
         {
             this.transform.localScale = towerItemSize;
         }
         else if (type == BuildingItemType.Institute)
         {
             this.transform.localScale = instituteItemSize;
         }
         else
         {
             Utils.DebugUtils.LogError(Utils.DebugUtils.Type.Building, "Can't find this buildingType :" + type);
         }
     }
     else if (type != BuildingItemType.None && type == lastUsedBuildingType)
     {
         //Not need change buildingitem size
     }
     else
     {
         Utils.DebugUtils.LogError(Utils.DebugUtils.Type.Building, "Can't find this buildingType :" + type);
     }
 }
コード例 #2
0
 public BuildingItem(BaseTile tile, int count)
 {
     Type   = BuildingItemType.TILE;
     Prefab = tile.Prefab;
     Name   = tile.Name;
     Count  = count;
 }
コード例 #3
0
 public BuildingItem(Furniture furniture, int count)
 {
     Type   = BuildingItemType.FURNITURE;
     Prefab = furniture.Prefab;
     Name   = furniture.Name;
     Count  = count;
 }
コード例 #4
0
    public void AddPending(int x, int y, string prefab, BuildingItemType type, string layer)
    {
        if (IsPendingAt(x, y))
        {
            return;
        }

        PendingBuildData data = new PendingBuildData();

        data.Prefab = prefab;
        data.Type   = type;
        data.Layer  = layer;
        data.X      = x;
        data.Y      = y;

        Pending.Add(data.GetID(), data);

        // TODO: This can still mess up when the server cannot place a tile.
        // The tile or furniture should be returned to the client in that case.

        // TODO only remove once the tile is placed.
        // Now do the real placing request...
        switch (data.Type)
        {
        case BuildingItemType.TILE:

            // Place tile.
            BaseTile tile = BaseTile.GetTile(data.Prefab);
            World.Instance.TileMap.GetLayer(layer).SetTile(tile, x, y);

            break;

        case BuildingItemType.FURNITURE:

            // Place furniture
            World.Instance.Furniture.PlaceFurniture(data.Prefab, x, y);

            break;
        }
    }