示例#1
0
 private void NormalState()
 {
     Usable.Type     type = Player.UsableSelected;
     Usable.Category cat  = Usable.category[(int)type];
     if (cat == Usable.Category.Block)
     {
         World.UIBlockTilemap.Clear();
         int  amount   = Player.inventoryUsables.GetItemCount(type);
         bool canPlace = PlaceBlock.CanPlace((int)mousePos.x, (int)mousePos.y, out canPlace);
         if (amount > 0 && canPlace && MouseInRange(9, false))
         {
             World.UIBlockTilemap.SetCell((int)mousePos.x, -(int)mousePos.y + Chunk.height, 1);
         }
         else
         {
             World.UIBlockTilemap.SetCell((int)mousePos.x, -(int)mousePos.y + Chunk.height, 0);
         }
     }
 }
示例#2
0
 private void ClickNormalState()
 {
     Usable.Type     type = Player.UsableSelected;
     Usable.Category cat  = Usable.category[(int)type];
     if (MouseInRange(9, false))
     {
         if (cat == Usable.Category.Block)
         {
             int amount = Player.inventoryUsables.GetItemCount(type);
             if (amount > 0)
             {
                 bool succeed = PlaceBlock.Place((int)mousePos.x, (int)mousePos.y, Usable.blocks[type]);
                 if (succeed)
                 {
                     Player.inventoryUsables.Remove(type, 1);
                     if (ToolBar.GetInstance() != null)
                     {
                         ToolBar.SendRefresh();
                     }
                 }
             }
         }
     }
 }