public void DrawItemInfo(int screenposX, int screenposY, Packet_Item item)
 {
     int sizex = dataItems.ItemSizeX(item);
     int sizey = dataItems.ItemSizeY(item);
     IntRef tw = new IntRef();
     IntRef th = new IntRef();
     float one = 1;
     game.platform.TextSize(dataItems.ItemInfo(item), 11 + one / 2, tw, th);
     tw.value += 6;
     th.value += 4;
     int w = game.platform.FloatToInt(tw.value + CellDrawSize * sizex);
     int h = game.platform.FloatToInt(th.value < CellDrawSize * sizey ? CellDrawSize * sizey + 4 : th.value);
     if (screenposX < w + 20) { screenposX = w + 20; }
     if (screenposY < h + 20) { screenposY = h + 20; }
     if (screenposX > game.Width() - (w + 20)) { screenposX = game.Width() - (w + 20); }
     if (screenposY > game.Height() - (h + 20)) { screenposY = game.Height() - (h + 20); }
     game.Draw2dTexture(game.WhiteTexture(), screenposX - w, screenposY - h, w, h, null, 0, Game.ColorFromArgb(255, 0, 0, 0), false);
     game.Draw2dTexture(game.WhiteTexture(), screenposX - w + 2, screenposY - h + 2, w - 4, h - 4, null, 0, Game.ColorFromArgb(255, 105, 105, 105), false);
     FontCi font = new FontCi();
     font.family = "Arial";
     font.size = 10;
     game.Draw2dText(dataItems.ItemInfo(item), font, screenposX - tw.value + 4, screenposY - h + 2, null, false);
     Packet_Item item2 = new Packet_Item();
     item2.BlockId = item.BlockId;
     DrawItem(screenposX - w + 2, screenposY - h + 2, item2, 0, 0);
 }
Example #2
0
    void DrawItem(int screenposX, int screenposY, Packet_Item item, int drawsizeX, int drawsizeY)
    {
        if (item == null)
        {
            return;
        }
        int sizex = dataItems.ItemSizeX(item);
        int sizey = dataItems.ItemSizeY(item);

        if (drawsizeX == 0 || drawsizeX == -1)
        {
            drawsizeX = CellDrawSize * sizex;
            drawsizeY = CellDrawSize * sizey;
        }
        if (item.ItemClass == Packet_ItemClassEnum.Block)
        {
            if (item.BlockId == 0)
            {
                return;
            }
            game.Draw2dTexture(game.terrainTexture, screenposX, screenposY,
                               drawsizeX, drawsizeY, IntRef.Create(dataItems.TextureIdForInventory()[item.BlockId]), game.texturesPacked(), Game.ColorFromArgb(255, 255, 255, 255), false);
            if (item.BlockCount > 1)
            {
                FontCi font = new FontCi();
                font.size = 8;
                game.Draw2dText(game.platform.IntToString(item.BlockCount), font, screenposX, screenposY, null, false);
            }
        }
        else
        {
            game.Draw2dBitmapFile(dataItems.ItemGraphics(item), screenposX, screenposY,
                                  drawsizeX, drawsizeY);
        }
    }
Example #3
0
    internal void DrawAmmo(Game game)
    {
        Packet_Item item = game.d_Inventory.RightHand[game.ActiveMaterial];

        if (item != null && item.ItemClass == Packet_ItemClassEnum.Block)
        {
            if (game.blocktypes[item.BlockId].IsPistol)
            {
                int    loaded = game.LoadedAmmo[item.BlockId];
                int    total  = game.TotalAmmo[item.BlockId];
                string s      = game.platform.StringFormat2("{0}/{1}", game.platform.IntToString(loaded), game.platform.IntToString(total - loaded));
                FontCi font   = new FontCi();
                font.family = "Arial";
                font.size   = 18;
                game.Draw2dText(s, font, game.Width() - game.TextSizeWidth(s, 18) - 50,
                                game.Height() - game.TextSizeHeight(s, 18) - 50, loaded == 0 ? IntRef.Create(Game.ColorFromArgb(255, 255, 0, 0)) : IntRef.Create(Game.ColorFromArgb(255, 255, 255, 255)), false);
                if (loaded == 0)
                {
                    font.size = 14;
                    string pressR = "Press R to reload";
                    game.Draw2dText(pressR, font, game.Width() - game.TextSizeWidth(pressR, 14) - 50,
                                    game.Height() - game.TextSizeHeight(s, 14) - 80, IntRef.Create(Game.ColorFromArgb(255, 255, 0, 0)), false);
                }
            }
        }
    }
Example #4
0
    public bool CanWear(int selectedWear, Packet_Item item)
    {
        if (item == null)
        {
            return(true);
        }
        if (item == null)
        {
            return(true);
        }
        switch (selectedWear)
        {
        //case WearPlace.LeftHand: return false;
        case WearPlace_.RightHand: return(item.ItemClass == Packet_ItemClassEnum.Block);

        case WearPlace_.MainArmor: return(false);

        case WearPlace_.Boots: return(false);

        case WearPlace_.Helmet: return(false);

        case WearPlace_.Gauntlet: return(false);

        default: return(false);
        }
    }
Example #5
0
    public bool IsCompass()
    {
        Packet_Item item = game.d_Inventory.RightHand[game.ActiveMaterial];

        return(item != null &&
               item.ItemClass == Packet_ItemClassEnum.Block &&
               item.BlockId == game.d_Data.BlockIdCompass());
    }
Example #6
0
    public bool IsTorch()
    {
        Packet_Item item = game.d_Inventory.RightHand[game.ActiveMaterial];

        return(item != null &&
               item.ItemClass == Packet_ItemClassEnum.Block &&
               game.blocktypes[item.BlockId].DrawType == Packet_DrawTypeEnum.Torch);
    }
Example #7
0
 public int ItemSizeY(Packet_Item item)
 {
     if (item.ItemClass == Packet_ItemClassEnum.Block)
     {
         return(1);
     }
     game.platform.ThrowException("ItemClass");
     return(1);
 }
Example #8
0
 public string ItemInfo(Packet_Item item)
 {
     if (item.ItemClass == Packet_ItemClassEnum.Block)
     {
         return(game.language.Get(StringTools.StringAppend(game.platform, "Block_", game.blocktypes[item.BlockId].Name)));
     }
     game.platform.ThrowException("ItemClass");
     return("ItemClass");
 }
Example #9
0
 public int ItemSizeY(Packet_Item item)
 {
     if (item.ItemClass == Packet_ItemClassEnum.Block)
     {
         return 1;
     }
     game.platform.ThrowException("ItemClass");
     return 1;
 }
Example #10
0
 public string ItemInfo(Packet_Item item)
 {
     if (item.ItemClass == Packet_ItemClassEnum.Block)
     {
         return game.language.Get(StringTools.StringAppend(game.platform, "Block_", game.blocktypes[item.BlockId].Name));
     }
     game.platform.ThrowException("ItemClass");
     return "ItemClass";
 }
Example #11
0
 public bool CanWear(int selectedWear, Packet_Item item)
 {
     if (item == null) { return true; }
     if (item == null) { return true; }
     switch (selectedWear)
     {
         //case WearPlace.LeftHand: return false;
         case WearPlace_.RightHand: return item.ItemClass == Packet_ItemClassEnum.Block;
         case WearPlace_.MainArmor: return false;
         case WearPlace_.Boots: return false;
         case WearPlace_.Helmet: return false;
         case WearPlace_.Gauntlet: return false;
         default: return false;
     }
 }
    public override void OnNewFrameFixed(Game game, NewFrameEventArgs args)
    {
        Packet_Item activeitem  = game.d_Inventory.RightHand[game.ActiveMaterial];
        int         activeblock = 0;

        if (activeitem != null)
        {
            activeblock = activeitem.BlockId;
        }
        if (activeblock != PreviousActiveMaterialBlock)
        {
            game.SendPacketClient(ClientPackets.ActiveMaterialSlot(game.ActiveMaterial));
        }
        PreviousActiveMaterialBlock = activeblock;
    }
Example #13
0
    public static string HandImage2d(Game game)
    {
        Packet_Item item = game.d_Inventory.RightHand[game.ActiveMaterial];
        string      img  = null;

        if (item != null)
        {
            img = game.blocktypes[item.BlockId].Handimage;
            if (game.IronSights)
            {
                img = game.blocktypes[item.BlockId].IronSightsImage;
            }
        }
        return(img);
    }
Example #14
0
    internal float BuildDelay(Game game)
    {
        float       default_ = (1f * 95 / 100) * (1 / game.basemovespeed);
        Packet_Item item     = game.d_Inventory.RightHand[game.ActiveMaterial];

        if (item == null || item.ItemClass != Packet_ItemClassEnum.Block)
        {
            return(default_);
        }
        float delay = game.DeserializeFloat(game.blocktypes[item.BlockId].DelayFloat);

        if (delay == 0)
        {
            return(default_);
        }
        return(delay);
    }
Example #15
0
    public void DrawMaterialSelector()
    {
        game.Draw2dBitmapFile("materials.png", MaterialSelectorBackgroundStartX(), MaterialSelectorBackgroundStartY(), game.platform.FloatToInt(1024 * game.Scale()), game.platform.FloatToInt(128 * game.Scale()));
        int materialSelectorStartX_ = MaterialSelectorStartX();
        int materialSelectorStartY_ = MaterialSelectorStartY();

        for (int i = 0; i < 10; i++)
        {
            Packet_Item item = game.d_Inventory.RightHand[i];
            if (item != null)
            {
                DrawItem(materialSelectorStartX_ + i * ActiveMaterialCellSize(), materialSelectorStartY_,
                         item, ActiveMaterialCellSize(), ActiveMaterialCellSize());
            }
        }
        game.Draw2dBitmapFile("activematerial.png",
                              MaterialSelectorStartX() + ActiveMaterialCellSize() * game.ActiveMaterial,
                              MaterialSelectorStartY(), ActiveMaterialCellSize() * 64 / 48, ActiveMaterialCellSize() * 64 / 48);
    }
Example #16
0
    public void DrawItemInfo(int screenposX, int screenposY, Packet_Item item)
    {
        int    sizex = dataItems.ItemSizeX(item);
        int    sizey = dataItems.ItemSizeY(item);
        IntRef tw    = new IntRef();
        IntRef th    = new IntRef();
        float  one   = 1;

        game.platform.TextSize(dataItems.ItemInfo(item), 11 + one / 2, tw, th);
        tw.value += 6;
        th.value += 4;
        int w = game.platform.FloatToInt(tw.value + CellDrawSize * sizex);
        int h = game.platform.FloatToInt(th.value < CellDrawSize * sizey ? CellDrawSize * sizey + 4 : th.value);

        if (screenposX < w + 20)
        {
            screenposX = w + 20;
        }
        if (screenposY < h + 20)
        {
            screenposY = h + 20;
        }
        if (screenposX > game.Width() - (w + 20))
        {
            screenposX = game.Width() - (w + 20);
        }
        if (screenposY > game.Height() - (h + 20))
        {
            screenposY = game.Height() - (h + 20);
        }
        game.Draw2dTexture(game.WhiteTexture(), screenposX - w, screenposY - h, w, h, null, 0, Game.ColorFromArgb(255, 0, 0, 0), false);
        game.Draw2dTexture(game.WhiteTexture(), screenposX - w + 2, screenposY - h + 2, w - 4, h - 4, null, 0, Game.ColorFromArgb(255, 105, 105, 105), false);
        FontCi font = new FontCi();

        font.family = "Arial";
        font.size   = 10;
        game.Draw2dText(dataItems.ItemInfo(item), font, screenposX - tw.value + 4, screenposY - h + 2, null, false);
        Packet_Item item2 = new Packet_Item();

        item2.BlockId = item.BlockId;
        DrawItem(screenposX - w + 2, screenposY - h + 2, item2, 0, 0);
    }
Example #17
0
 internal PointRef ItemAtCell(PointRef p)
 {
     for (int i = 0; i < d_Inventory.ItemsCount; i++)
     {
         Packet_PositionItem k    = d_Inventory.Items[i];
         Packet_Item         item = k.Value_;
         for (int x = 0; x < d_Items.ItemSizeX(item); x++)
         {
             for (int y = 0; y < d_Items.ItemSizeY(item); y++)
             {
                 int px = k.X + x;
                 int py = k.Y + y;
                 if (p.X == px && p.Y == py)
                 {
                     return(PointRef.Create(k.X, k.Y));
                 }
             }
         }
     }
     return(null);
 }
Example #18
0
 public Packet_Item Stack(Packet_Item itemA, Packet_Item itemB)
 {
     if (itemA.ItemClass == Packet_ItemClassEnum.Block
         && itemB.ItemClass == Packet_ItemClassEnum.Block)
     {
         //int railcountA = MyLinq.Count(DirectionUtils.ToRailDirections(d_Data.Rail[itemA.BlockId]));
         //int railcountB = MyLinq.Count(DirectionUtils.ToRailDirections(d_Data.Rail[itemB.BlockId]));
         //if ((itemA.BlockId != itemB.BlockId) && (!(railcountA > 0 && railcountB > 0)))
         //{
         //    return null;
         //}
         //todo stack size limit
         Packet_Item ret = new Packet_Item();
         ret.ItemClass = itemA.ItemClass;
         ret.BlockId = itemA.BlockId;
         ret.BlockCount = itemA.BlockCount + itemB.BlockCount;
         return ret;
     }
     else
     {
         return null;
     }
 }
Example #19
0
    public int GetWeaponTextureId(int side)
    {
        Packet_Item item = game.d_Inventory.RightHand[game.ActiveMaterial];

        if (item == null || IsCompass() || (item != null && item.BlockId == 0))
        {
            //empty hand
            if (side == TileSide.Top)
            {
                return(game.TextureId[game.d_Data.BlockIdEmptyHand()][TileSide.Top]);
            }
            return(game.TextureId[game.d_Data.BlockIdEmptyHand()][TileSide.Front]);
        }
        if (item.ItemClass == Packet_ItemClassEnum.Block)
        {
            return(game.TextureId[item.BlockId][side]);
        }
        else
        {
            //TODO: add rendering for other item classes as needed
            return(0);
        }
    }
Example #20
0
 public Packet_Item Stack(Packet_Item itemA, Packet_Item itemB)
 {
     if (itemA.ItemClass == Packet_ItemClassEnum.Block &&
         itemB.ItemClass == Packet_ItemClassEnum.Block)
     {
         //int railcountA = MyLinq.Count(DirectionUtils.ToRailDirections(d_Data.Rail[itemA.BlockId]));
         //int railcountB = MyLinq.Count(DirectionUtils.ToRailDirections(d_Data.Rail[itemB.BlockId]));
         //if ((itemA.BlockId != itemB.BlockId) && (!(railcountA > 0 && railcountB > 0)))
         //{
         //    return null;
         //}
         //TODO: stack size limit
         Packet_Item ret = new Packet_Item();
         ret.ItemClass  = itemA.ItemClass;
         ret.BlockId    = itemA.BlockId;
         ret.BlockCount = itemA.BlockCount + itemB.BlockCount;
         return(ret);
     }
     else
     {
         return(null);
     }
 }
Example #21
0
    public override void OnKeyDown(Game game, KeyEventArgs args)
    {
        if (!(game.guistate == GuiState.Normal && game.GuiTyping == TypingState.None))
        {
            //Do nothing when in dialog or chat
            return;
        }
        int eKey = args.GetKeyCode();

        if (eKey == game.GetKey(GlKeys.R))
        {
            Packet_Item item = game.d_Inventory.RightHand[game.ActiveMaterial];
            if (item != null && item.ItemClass == Packet_ItemClassEnum.Block &&
                game.blocktypes[item.BlockId].IsPistol &&
                game.reloadstartMilliseconds == 0)
            {
                int sound = game.rnd.Next() % game.blocktypes[item.BlockId].Sounds.ReloadCount;
                game.AudioPlay(StringTools.StringAppend(game.platform, game.blocktypes[item.BlockId].Sounds.Reload[sound], ".ogg"));
                game.reloadstartMilliseconds = game.platform.TimeMillisecondsFromStart();
                game.reloadblock             = item.BlockId;
                game.SendPacketClient(ClientPackets.Reload());
            }
        }
    }
Example #22
0
 public string ItemGraphics(Packet_Item item)
 {
     return null;
 }
Example #23
0
    public override void OnNewFrameDraw2d(Game game_, float deltaTime)
    {
        game = game_;
        if (dataItems == null)
        {
            dataItems      = new GameDataItemsClient();
            dataItems.game = game_;
            controller     = ClientInventoryController.Create(game_);
            inventoryUtil  = game.d_InventoryUtil;
        }
        if (game.guistate == GuiState.MapLoading)
        {
            return;
        }
        DrawMaterialSelector();
        if (game.guistate != GuiState.Inventory)
        {
            return;
        }
        if (ScrollingUpTimeMilliseconds != 0 && (game.platform.TimeMillisecondsFromStart() - ScrollingUpTimeMilliseconds) > 250)
        {
            ScrollingUpTimeMilliseconds = game.platform.TimeMillisecondsFromStart();
            ScrollUp();
        }
        if (ScrollingDownTimeMilliseconds != 0 && (game.platform.TimeMillisecondsFromStart() - ScrollingDownTimeMilliseconds) > 250)
        {
            ScrollingDownTimeMilliseconds = game.platform.TimeMillisecondsFromStart();
            ScrollDown();
        }

        PointRef scaledMouse = PointRef.Create(game.mouseCurrentX, game.mouseCurrentY);

        game.Draw2dBitmapFile("inventory.png", InventoryStartX(), InventoryStartY(), 1024, 1024);

        //the3d.Draw2dTexture(terrain, 50, 50, 50, 50, 0);
        //the3d.Draw2dBitmapFile("inventory_weapon_shovel.png", 100, 100, 60 * 2, 60 * 4);
        //the3d.Draw2dBitmapFile("inventory_gauntlet_gloves.png", 200, 200, 60 * 2, 60 * 2);
        //main inventory
        for (int i = 0; i < game.d_Inventory.ItemsCount; i++)
        {
            Packet_PositionItem k = game.d_Inventory.Items[i];
            if (k == null)
            {
                continue;
            }
            int screeny = k.Y - ScrollLine;
            if (screeny >= 0 && screeny < CellCountInPageY)
            {
                DrawItem(CellsStartX() + k.X * CellDrawSize, CellsStartY() + screeny * CellDrawSize, k.Value_, 0, 0);
            }
        }

        //draw area selection
        if (game.d_Inventory.DragDropItem != null)
        {
            PointRef selectedInPage = SelectedCell(scaledMouse);
            if (selectedInPage != null)
            {
                int x     = (selectedInPage.X) * CellDrawSize + CellsStartX();
                int y     = (selectedInPage.Y) * CellDrawSize + CellsStartY();
                int sizex = dataItems.ItemSizeX(game.d_Inventory.DragDropItem);
                int sizey = dataItems.ItemSizeY(game.d_Inventory.DragDropItem);
                if (selectedInPage.X + sizex <= CellCountInPageX &&
                    selectedInPage.Y + sizey <= CellCountInPageY)
                {
                    int        c;
                    IntRef     itemsAtAreaCount = new IntRef();
                    PointRef[] itemsAtArea      = inventoryUtil.ItemsAtArea(selectedInPage.X, selectedInPage.Y + ScrollLine, sizex, sizey, itemsAtAreaCount);
                    if (itemsAtArea == null || itemsAtAreaCount.value > 1)
                    {
                        c = Game.ColorFromArgb(100, 255, 0, 0); // red
                    }
                    else //0 or 1
                    {
                        c = Game.ColorFromArgb(100, 0, 255, 0); // green
                    }
                    game.Draw2dTexture(game.WhiteTexture(), x, y,
                                       CellDrawSize * sizex, CellDrawSize * sizey,
                                       null, 0, c, false);
                }
            }
            IntRef selectedWear = SelectedWearPlace(scaledMouse);
            if (selectedWear != null)
            {
                PointRef p    = PointRef.Create(wearPlaceStart[selectedWear.value].X + InventoryStartX(), wearPlaceStart[selectedWear.value].Y + InventoryStartY());
                PointRef size = wearPlaceCells[selectedWear.value];

                int         c;
                Packet_Item itemsAtArea = inventoryUtil.ItemAtWearPlace(selectedWear.value, game.ActiveMaterial);
                if (!dataItems.CanWear(selectedWear.value, game.d_Inventory.DragDropItem))
                {
                    c = Game.ColorFromArgb(100, 255, 0, 0); // red
                }
                else //0 or 1
                {
                    c = Game.ColorFromArgb(100, 0, 255, 0); // green
                }
                game.Draw2dTexture(game.WhiteTexture(), p.X, p.Y,
                                   CellDrawSize * size.X, CellDrawSize * size.Y,
                                   null, 0, c, false);
            }
        }

        //material selector
        DrawMaterialSelector();

        //wear
        //DrawItem(Offset(wearPlaceStart[(int)WearPlace.LeftHand], InventoryStart), inventory.LeftHand[ActiveMaterial.ActiveMaterial], null);
        DrawItem(wearPlaceStart[WearPlace_.RightHand].X + InventoryStartX(), wearPlaceStart[WearPlace_.RightHand].Y + InventoryStartY(), game.d_Inventory.RightHand[game.ActiveMaterial], 0, 0);
        DrawItem(wearPlaceStart[WearPlace_.MainArmor].X + InventoryStartX(), wearPlaceStart[WearPlace_.MainArmor].Y + InventoryStartY(), game.d_Inventory.MainArmor, 0, 0);
        DrawItem(wearPlaceStart[WearPlace_.Boots].X + InventoryStartX(), wearPlaceStart[WearPlace_.Boots].Y + InventoryStartY(), game.d_Inventory.Boots, 0, 0);
        DrawItem(wearPlaceStart[WearPlace_.Helmet].X + InventoryStartX(), wearPlaceStart[WearPlace_.Helmet].Y + InventoryStartY(), game.d_Inventory.Helmet, 0, 0);
        DrawItem(wearPlaceStart[WearPlace_.Gauntlet].X + InventoryStartX(), wearPlaceStart[WearPlace_.Gauntlet].Y + InventoryStartY(), game.d_Inventory.Gauntlet, 0, 0);

        //info
        if (SelectedCell(scaledMouse) != null)
        {
            PointRef selected = SelectedCell(scaledMouse);
            selected.Y += ScrollLine;
            PointRef itemAtCell = inventoryUtil.ItemAtCell(selected);
            if (itemAtCell != null)
            {
                Packet_Item item = GetItem(game.d_Inventory, itemAtCell.X, itemAtCell.Y);
                if (item != null)
                {
                    int x = (selected.X) * CellDrawSize + CellsStartX();
                    int y = (selected.Y) * CellDrawSize + CellsStartY();
                    DrawItemInfo(scaledMouse.X, scaledMouse.Y, item);
                }
            }
        }
        if (SelectedWearPlace(scaledMouse) != null)
        {
            int         selected        = SelectedWearPlace(scaledMouse).value;
            Packet_Item itemAtWearPlace = inventoryUtil.ItemAtWearPlace(selected, game.ActiveMaterial);
            if (itemAtWearPlace != null)
            {
                DrawItemInfo(scaledMouse.X, scaledMouse.Y, itemAtWearPlace);
            }
        }
        if (SelectedMaterialSelectorSlot(scaledMouse) != null)
        {
            int         selected = SelectedMaterialSelectorSlot(scaledMouse).value;
            Packet_Item item     = game.d_Inventory.RightHand[selected];
            if (item != null)
            {
                DrawItemInfo(scaledMouse.X, scaledMouse.Y, item);
            }
        }

        if (game.d_Inventory.DragDropItem != null)
        {
            DrawItem(scaledMouse.X, scaledMouse.Y, game.d_Inventory.DragDropItem, 0, 0);
        }
    }
 void DrawItem(int screenposX, int screenposY, Packet_Item item, int drawsizeX, int drawsizeY)
 {
     if (item == null)
     {
         return;
     }
     int sizex = dataItems.ItemSizeX(item);
     int sizey = dataItems.ItemSizeY(item);
     if (drawsizeX == 0 || drawsizeX == -1)
     {
         drawsizeX = CellDrawSize * sizex;
         drawsizeY = CellDrawSize * sizey;
     }
     if (item.ItemClass == Packet_ItemClassEnum.Block)
     {
         if (item.BlockId == 0)
         {
             return;
         }
         game.Draw2dTexture(game.terrainTexture, screenposX, screenposY,
             drawsizeX, drawsizeY, IntRef.Create(dataItems.TextureIdForInventory()[item.BlockId]), game.texturesPacked(), Game.ColorFromArgb(255, 255, 255, 255), false);
         if (item.BlockCount > 1)
         {
             FontCi font = new FontCi();
             font.size = 8;
             font.family = "Arial";
             game.Draw2dText(game.platform.IntToString(item.BlockCount), font, screenposX, screenposY, null, false);
         }
     }
     else
     {
         game.Draw2dBitmapFile(dataItems.ItemGraphics(item), screenposX, screenposY,
             drawsizeX, drawsizeY);
     }
 }
Example #25
0
    internal void NextBullet(Game game, int bulletsshot)
    {
        float one    = 1;
        bool  left   = game.mouseLeft;
        bool  middle = game.mouseMiddle;
        bool  right  = game.mouseRight;

        bool IsNextShot = bulletsshot != 0;

        if (!game.leftpressedpicking)
        {
            if (game.mouseleftclick)
            {
                game.leftpressedpicking = true;
            }
            else
            {
                left = false;
            }
        }
        else
        {
            if (game.mouseleftdeclick)
            {
                game.leftpressedpicking = false;
                left = false;
            }
        }
        if (!left)
        {
            game.currentAttackedBlock = null;
        }

        Packet_Item item          = game.d_Inventory.RightHand[game.ActiveMaterial];
        bool        ispistol      = (item != null && game.blocktypes[item.BlockId].IsPistol);
        bool        ispistolshoot = ispistol && left;
        bool        isgrenade     = ispistol && game.blocktypes[item.BlockId].PistolType == Packet_PistolTypeEnum.Grenade;

        if (ispistol && isgrenade)
        {
            ispistolshoot = game.mouseleftdeclick;
        }
        //grenade cooking - TODO: fix instant explosion when closing ESC menu
        if (game.mouseleftclick)
        {
            game.grenadecookingstartMilliseconds = game.platform.TimeMillisecondsFromStart();
            if (ispistol && isgrenade)
            {
                if (game.blocktypes[item.BlockId].Sounds.ShootCount > 0)
                {
                    game.AudioPlay(game.platform.StringFormat("{0}.ogg", game.blocktypes[item.BlockId].Sounds.Shoot[0]));
                }
            }
        }
        float wait = ((one * (game.platform.TimeMillisecondsFromStart() - game.grenadecookingstartMilliseconds)) / 1000);

        if (isgrenade && left)
        {
            if (wait >= game.grenadetime && isgrenade && game.grenadecookingstartMilliseconds != 0)
            {
                ispistolshoot         = true;
                game.mouseleftdeclick = true;
            }
            else
            {
                return;
            }
        }
        else
        {
            game.grenadecookingstartMilliseconds = 0;
        }

        if (ispistol && game.mouserightclick && (game.platform.TimeMillisecondsFromStart() - game.lastironsightschangeMilliseconds) >= 500)
        {
            game.IronSights = !game.IronSights;
            game.lastironsightschangeMilliseconds = game.platform.TimeMillisecondsFromStart();
        }

        IntRef pick2count = new IntRef();
        Line3D pick       = new Line3D();

        GetPickingLine(game, pick, ispistolshoot);
        BlockPosSide[] pick2 = game.Pick(game.s, pick, pick2count);

        if (left)
        {
            game.handSetAttackDestroy = true;
        }
        else if (right)
        {
            game.handSetAttackBuild = true;
        }

        if (game.overheadcamera && pick2count.value > 0 && left)
        {
            //if not picked any object, and mouse button is pressed, then walk to destination.
            if (game.Follow == null)
            {
                //Only walk to destination when not following someone
                game.playerdestination = Vector3Ref.Create(pick2[0].blockPos[0], pick2[0].blockPos[1] + 1, pick2[0].blockPos[2]);
            }
        }
        bool pickdistanceok = (pick2count.value > 0); //&& (!ispistol);

        if (pickdistanceok)
        {
            if (game.Dist(pick2[0].blockPos[0] + one / 2, pick2[0].blockPos[1] + one / 2, pick2[0].blockPos[2] + one / 2,
                          pick.Start[0], pick.Start[1], pick.Start[2]) > CurrentPickDistance(game))
            {
                pickdistanceok = false;
            }
        }
        bool playertileempty = game.IsTileEmptyForPhysics(
            game.platform.FloatToInt(game.player.position.x),
            game.platform.FloatToInt(game.player.position.z),
            game.platform.FloatToInt(game.player.position.y + (one / 2)));
        bool playertileemptyclose = game.IsTileEmptyForPhysicsClose(
            game.platform.FloatToInt(game.player.position.x),
            game.platform.FloatToInt(game.player.position.z),
            game.platform.FloatToInt(game.player.position.y + (one / 2)));
        BlockPosSide pick0 = new BlockPosSide();

        if (pick2count.value > 0 &&
            ((pickdistanceok && (playertileempty || (playertileemptyclose))) ||
             game.overheadcamera)
            )
        {
            game.SelectedBlockPositionX = game.platform.FloatToInt(pick2[0].Current()[0]);
            game.SelectedBlockPositionY = game.platform.FloatToInt(pick2[0].Current()[1]);
            game.SelectedBlockPositionZ = game.platform.FloatToInt(pick2[0].Current()[2]);
            pick0 = pick2[0];
        }
        else
        {
            game.SelectedBlockPositionX = -1;
            game.SelectedBlockPositionY = -1;
            game.SelectedBlockPositionZ = -1;
            pick0.blockPos    = new float[3];
            pick0.blockPos[0] = -1;
            pick0.blockPos[1] = -1;
            pick0.blockPos[2] = -1;
        }
        PickEntity(game, pick, pick2, pick2count);
        if (game.cameratype == CameraType.Fpp || game.cameratype == CameraType.Tpp)
        {
            int ntileX = game.platform.FloatToInt(pick0.Current()[0]);
            int ntileY = game.platform.FloatToInt(pick0.Current()[1]);
            int ntileZ = game.platform.FloatToInt(pick0.Current()[2]);
            if (game.IsUsableBlock(game.map.GetBlock(ntileX, ntileZ, ntileY)))
            {
                game.currentAttackedBlock = Vector3IntRef.Create(ntileX, ntileZ, ntileY);
            }
        }
        if (game.GetFreeMouse())
        {
            if (pick2count.value > 0)
            {
                OnPick_(pick0);
            }
            return;
        }

        if ((one * (game.platform.TimeMillisecondsFromStart() - lastbuildMilliseconds) / 1000) >= BuildDelay(game) ||
            IsNextShot)
        {
            if (left && game.d_Inventory.RightHand[game.ActiveMaterial] == null)
            {
                game.SendPacketClient(ClientPackets.MonsterHit(game.platform.FloatToInt(2 + game.rnd.NextFloat() * 4)));
            }
            if (left && !fastclicking)
            {
                //todo animation
                fastclicking = false;
            }
            if ((left || right || middle) && (!isgrenade))
            {
                lastbuildMilliseconds = game.platform.TimeMillisecondsFromStart();
            }
            if (isgrenade && game.mouseleftdeclick)
            {
                lastbuildMilliseconds = game.platform.TimeMillisecondsFromStart();
            }
            if (game.reloadstartMilliseconds != 0)
            {
                PickingEnd(left, right, middle, ispistol);
                return;
            }
            if (ispistolshoot)
            {
                if ((!(game.LoadedAmmo[item.BlockId] > 0)) ||
                    (!(game.TotalAmmo[item.BlockId] > 0)))
                {
                    game.AudioPlay("Dry Fire Gun-SoundBible.com-2053652037.ogg");
                    PickingEnd(left, right, middle, ispistol);
                    return;
                }
            }
            if (ispistolshoot)
            {
                float toX = pick.End[0];
                float toY = pick.End[1];
                float toZ = pick.End[2];
                if (pick2count.value > 0)
                {
                    toX = pick2[0].blockPos[0];
                    toY = pick2[0].blockPos[1];
                    toZ = pick2[0].blockPos[2];
                }

                Packet_ClientShot shot = new Packet_ClientShot();
                shot.FromX     = game.SerializeFloat(pick.Start[0]);
                shot.FromY     = game.SerializeFloat(pick.Start[1]);
                shot.FromZ     = game.SerializeFloat(pick.Start[2]);
                shot.ToX       = game.SerializeFloat(toX);
                shot.ToY       = game.SerializeFloat(toY);
                shot.ToZ       = game.SerializeFloat(toZ);
                shot.HitPlayer = -1;

                for (int i = 0; i < game.entitiesCount; i++)
                {
                    if (game.entities[i] == null)
                    {
                        continue;
                    }
                    if (game.entities[i].drawModel == null)
                    {
                        continue;
                    }
                    Entity p_ = game.entities[i];
                    if (p_.networkPosition == null)
                    {
                        continue;
                    }
                    if (!p_.networkPosition.PositionLoaded)
                    {
                        continue;
                    }
                    float feetposX = p_.position.x;
                    float feetposY = p_.position.y;
                    float feetposZ = p_.position.z;
                    //var p = PlayerPositionSpawn;
                    Box3D bodybox  = new Box3D();
                    float headsize = (p_.drawModel.ModelHeight - p_.drawModel.eyeHeight) * 2; //0.4f;
                    float h        = p_.drawModel.ModelHeight - headsize;
                    float r        = one * 35 / 100;

                    bodybox.AddPoint(feetposX - r, feetposY + 0, feetposZ - r);
                    bodybox.AddPoint(feetposX - r, feetposY + 0, feetposZ + r);
                    bodybox.AddPoint(feetposX + r, feetposY + 0, feetposZ - r);
                    bodybox.AddPoint(feetposX + r, feetposY + 0, feetposZ + r);

                    bodybox.AddPoint(feetposX - r, feetposY + h, feetposZ - r);
                    bodybox.AddPoint(feetposX - r, feetposY + h, feetposZ + r);
                    bodybox.AddPoint(feetposX + r, feetposY + h, feetposZ - r);
                    bodybox.AddPoint(feetposX + r, feetposY + h, feetposZ + r);

                    Box3D headbox = new Box3D();

                    headbox.AddPoint(feetposX - r, feetposY + h, feetposZ - r);
                    headbox.AddPoint(feetposX - r, feetposY + h, feetposZ + r);
                    headbox.AddPoint(feetposX + r, feetposY + h, feetposZ - r);
                    headbox.AddPoint(feetposX + r, feetposY + h, feetposZ + r);

                    headbox.AddPoint(feetposX - r, feetposY + h + headsize, feetposZ - r);
                    headbox.AddPoint(feetposX - r, feetposY + h + headsize, feetposZ + r);
                    headbox.AddPoint(feetposX + r, feetposY + h + headsize, feetposZ - r);
                    headbox.AddPoint(feetposX + r, feetposY + h + headsize, feetposZ + r);

                    float[] p;
                    float   localeyeposX = game.EyesPosX();
                    float   localeyeposY = game.EyesPosY();
                    float   localeyeposZ = game.EyesPosZ();
                    p = Intersection.CheckLineBoxExact(pick, headbox);
                    if (p != null)
                    {
                        //do not allow to shoot through terrain
                        if (pick2count.value == 0 || (game.Dist(pick2[0].blockPos[0], pick2[0].blockPos[1], pick2[0].blockPos[2], localeyeposX, localeyeposY, localeyeposZ)
                                                      > game.Dist(p[0], p[1], p[2], localeyeposX, localeyeposY, localeyeposZ)))
                        {
                            if (!isgrenade)
                            {
                                Entity entity = new Entity();
                                Sprite sprite = new Sprite();
                                sprite.positionX = p[0];
                                sprite.positionY = p[1];
                                sprite.positionZ = p[2];
                                sprite.image     = "blood.png";
                                entity.sprite    = sprite;
                                entity.expires   = Expires.Create(one * 2 / 10);
                                game.EntityAddLocal(entity);
                            }
                            shot.HitPlayer = i;
                            shot.IsHitHead = 1;
                        }
                    }
                    else
                    {
                        p = Intersection.CheckLineBoxExact(pick, bodybox);
                        if (p != null)
                        {
                            //do not allow to shoot through terrain
                            if (pick2count.value == 0 || (game.Dist(pick2[0].blockPos[0], pick2[0].blockPos[1], pick2[0].blockPos[2], localeyeposX, localeyeposY, localeyeposZ)
                                                          > game.Dist(p[0], p[1], p[2], localeyeposX, localeyeposY, localeyeposZ)))
                            {
                                if (!isgrenade)
                                {
                                    Entity entity = new Entity();
                                    Sprite sprite = new Sprite();
                                    sprite.positionX = p[0];
                                    sprite.positionY = p[1];
                                    sprite.positionZ = p[2];
                                    sprite.image     = "blood.png";
                                    entity.sprite    = sprite;
                                    entity.expires   = Expires.Create(one * 2 / 10);
                                    game.EntityAddLocal(entity);
                                }
                                shot.HitPlayer = i;
                                shot.IsHitHead = 0;
                            }
                        }
                    }
                }
                shot.WeaponBlock = item.BlockId;
                game.LoadedAmmo[item.BlockId] = game.LoadedAmmo[item.BlockId] - 1;
                game.TotalAmmo[item.BlockId]  = game.TotalAmmo[item.BlockId] - 1;
                float projectilespeed = game.DeserializeFloat(game.blocktypes[item.BlockId].ProjectileSpeedFloat);
                if (projectilespeed == 0)
                {
                    {
                        Entity entity = game.CreateBulletEntity(
                            pick.Start[0], pick.Start[1], pick.Start[2],
                            toX, toY, toZ, 150);
                        game.EntityAddLocal(entity);
                    }
                }
                else
                {
                    float vX      = toX - pick.Start[0];
                    float vY      = toY - pick.Start[1];
                    float vZ      = toZ - pick.Start[2];
                    float vLength = game.Length(vX, vY, vZ);
                    vX /= vLength;
                    vY /= vLength;
                    vZ /= vLength;
                    vX *= projectilespeed;
                    vY *= projectilespeed;
                    vZ *= projectilespeed;
                    shot.ExplodesAfter = game.SerializeFloat(game.grenadetime - wait);

                    {
                        Entity grenadeEntity = new Entity();

                        Sprite sprite = new Sprite();
                        sprite.image          = "ChemicalGreen.png";
                        sprite.size           = 14;
                        sprite.animationcount = 0;
                        sprite.positionX      = pick.Start[0];
                        sprite.positionY      = pick.Start[1];
                        sprite.positionZ      = pick.Start[2];
                        grenadeEntity.sprite  = sprite;

                        Grenade_ projectile = new Grenade_();
                        projectile.velocityX    = vX;
                        projectile.velocityY    = vY;
                        projectile.velocityZ    = vZ;
                        projectile.block        = item.BlockId;
                        projectile.sourcePlayer = game.LocalPlayerId;

                        grenadeEntity.expires = Expires.Create(game.grenadetime - wait);

                        grenadeEntity.grenade = projectile;
                        game.EntityAddLocal(grenadeEntity);
                    }
                }
                Packet_Client packet = new Packet_Client();
                packet.Id   = Packet_ClientIdEnum.Shot;
                packet.Shot = shot;
                game.SendPacketClient(packet);

                if (game.blocktypes[item.BlockId].Sounds.ShootEndCount > 0)
                {
                    game.pistolcycle = game.rnd.Next() % game.blocktypes[item.BlockId].Sounds.ShootEndCount;
                    game.AudioPlay(game.platform.StringFormat("{0}.ogg", game.blocktypes[item.BlockId].Sounds.ShootEnd[game.pistolcycle]));
                }

                bulletsshot++;
                if (bulletsshot < game.DeserializeFloat(game.blocktypes[item.BlockId].BulletsPerShotFloat))
                {
                    NextBullet(game, bulletsshot);
                }

                //recoil
                game.player.position.rotx -= game.rnd.NextFloat() * game.CurrentRecoil();
                game.player.position.roty += game.rnd.NextFloat() * game.CurrentRecoil() * 2 - game.CurrentRecoil();

                PickingEnd(left, right, middle, ispistol);
                return;
            }
            if (ispistol && right)
            {
                PickingEnd(left, right, middle, ispistol);
                return;
            }
            if (pick2count.value > 0)
            {
                if (middle)
                {
                    int newtileX = game.platform.FloatToInt(pick0.Current()[0]);
                    int newtileY = game.platform.FloatToInt(pick0.Current()[1]);
                    int newtileZ = game.platform.FloatToInt(pick0.Current()[2]);
                    if (game.map.IsValidPos(newtileX, newtileZ, newtileY))
                    {
                        int  clonesource  = game.map.GetBlock(newtileX, newtileZ, newtileY);
                        int  clonesource2 = game.d_Data.WhenPlayerPlacesGetsConvertedTo()[clonesource];
                        bool gotoDone     = false;
                        //find this block in another right hand.
                        for (int i = 0; i < 10; i++)
                        {
                            if (game.d_Inventory.RightHand[i] != null &&
                                game.d_Inventory.RightHand[i].ItemClass == Packet_ItemClassEnum.Block &&
                                game.d_Inventory.RightHand[i].BlockId == clonesource2)
                            {
                                game.ActiveMaterial = i;
                                gotoDone            = true;
                            }
                        }
                        if (!gotoDone)
                        {
                            IntRef freehand = game.d_InventoryUtil.FreeHand(game.ActiveMaterial);
                            //find this block in inventory.
                            for (int i = 0; i < game.d_Inventory.ItemsCount; i++)
                            {
                                Packet_PositionItem k = game.d_Inventory.Items[i];
                                if (k == null)
                                {
                                    continue;
                                }
                                if (k.Value_.ItemClass == Packet_ItemClassEnum.Block &&
                                    k.Value_.BlockId == clonesource2)
                                {
                                    //free hand
                                    if (freehand != null)
                                    {
                                        game.WearItem(
                                            game.InventoryPositionMainArea(k.X, k.Y),
                                            game.InventoryPositionMaterialSelector(freehand.value));
                                        break;
                                    }
                                    //try to replace current slot
                                    if (game.d_Inventory.RightHand[game.ActiveMaterial] != null &&
                                        game.d_Inventory.RightHand[game.ActiveMaterial].ItemClass == Packet_ItemClassEnum.Block)
                                    {
                                        game.MoveToInventory(
                                            game.InventoryPositionMaterialSelector(game.ActiveMaterial));
                                        game.WearItem(
                                            game.InventoryPositionMainArea(k.X, k.Y),
                                            game.InventoryPositionMaterialSelector(game.ActiveMaterial));
                                    }
                                }
                            }
                        }
                        string[] sound = game.d_Data.CloneSound()[clonesource];
                        if (sound != null)            // && sound.Length > 0)
                        {
                            game.AudioPlay(sound[0]); //todo sound cycle
                        }
                    }
                }
                if (left || right)
                {
                    BlockPosSide tile = pick0;
                    int          newtileX;
                    int          newtileY;
                    int          newtileZ;
                    if (right)
                    {
                        newtileX = game.platform.FloatToInt(tile.Translated()[0]);
                        newtileY = game.platform.FloatToInt(tile.Translated()[1]);
                        newtileZ = game.platform.FloatToInt(tile.Translated()[2]);
                    }
                    else
                    {
                        newtileX = game.platform.FloatToInt(tile.Current()[0]);
                        newtileY = game.platform.FloatToInt(tile.Current()[1]);
                        newtileZ = game.platform.FloatToInt(tile.Current()[2]);
                    }
                    if (game.map.IsValidPos(newtileX, newtileZ, newtileY))
                    {
                        //Console.WriteLine(". newtile:" + newtile + " type: " + d_Map.GetBlock(newtileX, newtileZ, newtileY));
                        if (!(pick0.blockPos[0] == -1 &&
                              pick0.blockPos[1] == -1 &&
                              pick0.blockPos[2] == -1))
                        {
                            int blocktype;
                            if (left)
                            {
                                blocktype = game.map.GetBlock(newtileX, newtileZ, newtileY);
                            }
                            else
                            {
                                blocktype = ((game.BlockInHand() == null) ? 1 : game.BlockInHand().value);
                            }
                            if (left && blocktype == game.d_Data.BlockIdAdminium())
                            {
                                PickingEnd(left, right, middle, ispistol);
                                return;
                            }
                            string[] sound = left ? game.d_Data.BreakSound()[blocktype] : game.d_Data.BuildSound()[blocktype];
                            if (sound != null)            // && sound.Length > 0)
                            {
                                game.AudioPlay(sound[0]); //todo sound cycle
                            }
                        }
                        //normal attack
                        if (!right)
                        {
                            //attack
                            int posx = newtileX;
                            int posy = newtileZ;
                            int posz = newtileY;
                            game.currentAttackedBlock = Vector3IntRef.Create(posx, posy, posz);
                            if (!game.blockHealth.ContainsKey(posx, posy, posz))
                            {
                                game.blockHealth.Set(posx, posy, posz, game.GetCurrentBlockHealth(posx, posy, posz));
                            }
                            game.blockHealth.Set(posx, posy, posz, game.blockHealth.Get(posx, posy, posz) - game.WeaponAttackStrength());
                            float health = game.GetCurrentBlockHealth(posx, posy, posz);
                            if (health <= 0)
                            {
                                if (game.currentAttackedBlock != null)
                                {
                                    game.blockHealth.Remove(posx, posy, posz);
                                }
                                game.currentAttackedBlock = null;
                                OnPick(game, game.platform.FloatToInt(newtileX), game.platform.FloatToInt(newtileZ), game.platform.FloatToInt(newtileY),
                                       game.platform.FloatToInt(tile.Current()[0]), game.platform.FloatToInt(tile.Current()[2]), game.platform.FloatToInt(tile.Current()[1]),
                                       tile.collisionPos,
                                       right);
                            }
                            PickingEnd(left, right, middle, ispistol);
                            return;
                        }
                        if (!right)
                        {
                            game.particleEffectBlockBreak.StartParticleEffect(newtileX, newtileY, newtileZ);//must be before deletion - gets ground type.
                        }
                        if (!game.map.IsValidPos(newtileX, newtileZ, newtileY))
                        {
                            game.platform.ThrowException("Error in picking - NextBullet()");
                        }
                        OnPick(game, game.platform.FloatToInt(newtileX), game.platform.FloatToInt(newtileZ), game.platform.FloatToInt(newtileY),
                               game.platform.FloatToInt(tile.Current()[0]), game.platform.FloatToInt(tile.Current()[2]), game.platform.FloatToInt(tile.Current()[1]),
                               tile.collisionPos,
                               right);
                        //network.SendSetBlock(new Vector3((int)newtile.X, (int)newtile.Z, (int)newtile.Y),
                        //    right ? BlockSetMode.Create : BlockSetMode.Destroy, (byte)MaterialSlots[activematerial]);
                    }
                }
            }
        }
        PickingEnd(left, right, middle, ispistol);
    }
Example #26
0
    public void DrawWeapon(float dt)
    {
        int light;

        if (IsTorch())
        {
            light = 255;
        }
        else
        {
            light = game.platform.FloatToInt(Light() * 256);
            if (light > 255)
            {
                light = 255;
            }
            if (light < 0)
            {
                light = 0;
            }
        }
        game.platform.BindTexture2d(terrainTexture());

        Packet_Item item = game.d_Inventory.RightHand[game.ActiveMaterial];
        int         curmaterial;

        if (item == null)
        {
            curmaterial = 0;
        }
        else
        {
            curmaterial = item.BlockId == 151 ? 128 : item.BlockId;
        }
        float curlight = Light();

        if (curmaterial != oldMaterial || curlight != oldLight || modelData == null || game.handRedraw)
        {
            game.handRedraw   = false;
            modelData         = new ModelData();
            modelData.indices = new int[128];
            modelData.xyz     = new float[128];
            modelData.uv      = new float[128];
            modelData.rgba    = new byte[128];
            int x = 0;
            int y = 0;
            int z = 0;
            if (IsEmptyHand() || IsCompass())
            {
                d_BlockRendererTorch.TopTexture  = GetWeaponTextureId(TileSide.Top);
                d_BlockRendererTorch.SideTexture = GetWeaponTextureId(TileSide.Front);
                d_BlockRendererTorch.AddTorch(game.d_Data, game, modelData, x, y, z, TorchType.Normal);
            }
            else if (IsTorch())
            {
                d_BlockRendererTorch.TopTexture  = GetWeaponTextureId(TileSide.Top);
                d_BlockRendererTorch.SideTexture = GetWeaponTextureId(TileSide.Front);
                d_BlockRendererTorch.AddTorch(game.d_Data, game, modelData, x, y, z, TorchType.Normal);
            }
            else
            {
                DrawCube(modelData, x, y, z, Game.ColorFromArgb(255, light, light, light));
            }
        }
        oldMaterial = curmaterial;
        oldLight    = curlight;

        game.platform.GlClearDepthBuffer();
        game.GLMatrixModeModelView();
        game.GLPushMatrix();
        game.GLLoadIdentity();

        game.GLTranslate((one * 3 / 10) + zzzposz - attackt * 5, -(one * 15 / 10) + zzzposx - buildt * 10, -(one * 15 / 10) + zzzposy);
        game.GLRotate(30 + (zzzx) - attackt * 300, 1, 0, 0);
        game.GLRotate(60 + zzzy, 0, 1, 0);
        game.GLScale(one * 8 / 10, one * 8 / 10, one * 8 / 10);

        bool move = !(oldplayerposX == game.player.position.x &&
                      oldplayerposY == game.player.position.y &&
                      oldplayerposZ == game.player.position.z);

        oldplayerposX = game.player.position.x;
        oldplayerposY = game.player.position.y;
        oldplayerposZ = game.player.position.z;
        if (move)
        {
            t_           += dt;
            slowdownTimer = slowdownTimerSpecial;
        }
        else
        {
            if (slowdownTimer == slowdownTimerSpecial)
            {
                slowdownTimer = (animperiod / 2 - (t_ % (animperiod / 2)));
            }
            slowdownTimer -= dt;
            if (slowdownTimer < 0)
            {
                t_ = 0;
            }
            else
            {
                t_ += dt;
            }
        }
        zzzposx = rot(t_);
        zzzposz = rot2(t_);
        if (attack != -1)
        {
            attack += dt * 7;
            if (attack > Game.GetPi() / 2)
            {
                attack = -1;
                if (build)
                {
                    buildt = 0;
                }
                else
                {
                    attackt = 0;
                }
            }
            else
            {
                if (build)
                {
                    buildt  = rot(attack / 5);
                    attackt = 0;
                }
                else
                {
                    attackt = rot(attack / 5);
                    buildt  = 0;
                }
            }
        }

        game.platform.GlEnableTexture2d();
        game.platform.BindTexture2d(terrainTexture());
        game.DrawModelData(modelData);

        game.GLPopMatrix();
    }
Example #27
0
    public bool IsEmptyHand()
    {
        Packet_Item item = game.d_Inventory.RightHand[game.ActiveMaterial];

        return(item == null || item.BlockId == 0);
    }
Example #28
0
 public string ItemGraphics(Packet_Item item)
 {
     return(null);
 }