Exemplo n.º 1
0
 public void NewGame()
 {
     disposed        = false;
     PlayerInventory = new Inventory();
     HatchInv        = new HatchInventory();
     PlayerInventory.AddItem(new IngotItem(KnownMetal.Iron, 1));
     HatchInv.AddItem(new CastItem(CastItem.GreatsowordCast));
     HatchInv.AddItem(new CastItem(CastItem.BroadswordCast));
     HatchInv.AddItem(new CastItem(CastItem.IngotCast));
     HatchInv.AddItem(new IngotItem(KnownMetal.Gold, 0.8f));
     HatchInv.AddItem(new IngotItem(KnownMetal.Iron, 0.7f));
     HatchInv.AddItem(new IngotItem(KnownMetal.Gold, 0.9f));
     HatchInv.AddItem(new IngotItem(KnownMetal.Copper, 1f));
     HatchInv.AddItem(new IngotItem(KnownMetal.Copper, 0.8f));
     HatchInv.AddItem(new IngotItem(KnownMetal.Copper, 1f));
     HatchInv.AddItem(new IngotItem(KnownMetal.Copper, 0.65f));
     HatchInv.AddItem(new IngotItem(KnownMetal.Bronze, 0.8f));
     HatchInv.AddItem(new IngotItem(KnownMetal.HiTinBronze, 0.9f));
     HatchInv.AddItem(new IngotItem(KnownMetal.LowTinBronze, 0.7f));
     HatchInv.AddItem(new IngotItem(KnownMetal.Tin, 0.8f));
     HatchInv.AddItem(new IngotItem(KnownMetal.Tin, 0.9f));
     FoundryIngots     = new SolidList <IngotItem> (FoundryMeshInfo.IngotAmount);
     FoundryAlloy      = new Alloy();
     AirQuality        = 25;
     CoalPercent       = 80;
     FoundryTemprature = 25;
     CastMetal         = -1;
 }
Exemplo n.º 2
0
        public void LoadGame(Stream reader)
        {
            disposed = false;
            Console.WriteLine("Loading game!");
            PlayerInventory = new Inventory();
            PlayerInventory.LoadFromFile(reader);                                                                       //PlayerInventory
            HatchInv = new HatchInventory();
            HatchInv.LoadFromFile(reader);                                                                              //HatchInv
            if (reader.ReadByte() != 0)                                                                                 //Check if CurrentCast is not null
            {
                CurrentCast = (CastItem)StreamIO.LoadItem(reader);                                                      //CurrentCast
            }
            CastMetal = reader.ReadByte();                                                                              //CastMetal
            var buffer = new byte[sizeof(float) * 4];

            reader.Read(buffer, 0, sizeof(float) * 4);                                                                          //CastMetaPurity, CastFilling, CastingTemperature, OldFoundryAmount
            CastMetalPurity   = BitConverter.ToSingle(buffer, 0);
            CastFilling       = BitConverter.ToSingle(buffer, sizeof(float));
            CastingTemprature = BitConverter.ToSingle(buffer, 2 * sizeof(float));
            OldFoundryAmount  = BitConverter.ToSingle(buffer, 3 * sizeof(float));
            FoundryIngots     = new SolidList <IngotItem> (FoundryMeshInfo.IngotAmount);
            for (int i = 0; i < FoundryIngots.Capacity; i++)
            {
                if (reader.ReadByte() != 0)                                                             //Check if the item is not null
                {
                    FoundryIngots [i] = (IngotItem)StreamIO.LoadItem(reader);                           //Read IngotItems
                }
            }
            FoundryAlloy = StreamIO.LoadAlloy(reader);                                                                  //FoundryAlloy
            reader.Read(buffer, 0, sizeof(float) * 3);                                                                  //Read3
            AirQuality        = BitConverter.ToSingle(buffer, 0);                                                       //AirQuality
            CoalPercent       = BitConverter.ToSingle(buffer, sizeof(float));                                           //CoalPercent
            FoundryTemprature = BitConverter.ToSingle(buffer, sizeof(float) * 2);                                       //FoundryTemperature
            Console.Out.WriteLine(reader.Position);
        }
Exemplo n.º 3
0
        public void RenderView(Matrix4 VP, Scene s)
        {
            Inventory playerInv = game.GameStats.PlayerInventory;

            playerInv.Render(game);

            if (!transition.IsDone())
            {
                return;
            }

            HatchInventory hatchInv = game.GameStats.HatchInv;
            float          x        = inventoryXPos;
            float          y        = inventoryYPos;

            OrthoRenderEngine.DrawTexturedBox(TextureCollection.Button, x, y, iconSize * iconsPerRow, iconSize * iconsPerRow, 0, 0, iconsPerRow, iconsPerRow);

            float itemX = 0;
            float itemY = 0;

            for (int i = 0; i < hatchInv.GetItemAmount(); i++)
            {
                Item item = hatchInv.GetItem(i);
                if (itemY + item.GetSize() > iconsPerRow)
                {
                    itemY = 0;
                    itemX++;
                    if (itemX >= iconsPerRow)
                    {
                    }                    //TODO add multiple pages or something
                }
                item.RenderItem(x + itemX * iconSize, y + itemY * iconSize, iconSize, iconSize * item.GetSize());

                itemY += item.GetSize();
            }

            if (hoveredItem >= 0 & hoveredItem < hatchInv.GetItemAmount())
            {
                Item item = hatchInv.GetItem(hoveredItem);

                game.TooltipHelper.ClaimIfPossible(this);

                if (game.TooltipHelper.GetOwner() == this)
                {
                    game.TooltipHelper.RenderItemTooltip(item, Input.OrthoMouseX - 30, Input.OrthoMouseY);
                }
            }
            else if (game.TooltipHelper.GetOwner() == this)
            {
                game.TooltipHelper.UnClaim();
            }
        }
Exemplo n.º 4
0
        public void UpdateView(Scene s)
        {
            if (Input.CloseKeyPressed)
            {
                game.SetView(prevView);
                return;
            }

            transition.UpdateTransition(Time.Delta() * 2);

            if (hatchRotation > -1.5f)
            {
                hatchSpeed -= Time.Delta() * 8;
            }
            else
            {
                hatchSpeed -= 4 * hatchSpeed * Time.Delta();
            }
            hatchRotation += hatchSpeed * Time.Delta();

            game.GameStats.PlayerInventory.HandleInput();
            if (game.GameStats.PlayerInventory.HasSelectedItem())
            {
                game.GameStats.HatchInv.AddItem(game.GameStats.PlayerInventory.GetSelectedItem());
                game.GameStats.PlayerInventory.RemoveItem(game.GameStats.PlayerInventory.GetSelectedItemIndex());
            }

            Inventory      playerInv = game.GameStats.PlayerInventory;
            HatchInventory hatchInv  = game.GameStats.HatchInv;
            float          x         = inventoryXPos;
            float          y         = inventoryYPos;

            if (Input.OrthoMouseX > x & Input.OrthoMouseY > y & Input.OrthoMouseX < x + iconSize * iconsPerRow & Input.OrthoMouseY < y + iconSize * iconsPerRow)
            {
                int xIndex = (int)(Input.OrthoMouseX - x) / (int)iconSize;
                int yIndex = (int)(Input.OrthoMouseY - y) / (int)iconSize;

                int  iconIndex = yIndex + xIndex * iconsPerRow;
                uint box       = 0;
                uint yPos      = 0;
                uint xPos      = 0;
                for (hoveredItem = 0; hoveredItem < hatchInv.GetItemAmount(); hoveredItem++)
                {
                    box  += hatchInv.GetItem(hoveredItem).GetSize();
                    yPos += hatchInv.GetItem(hoveredItem).GetSize();

                    if (yPos > iconsPerRow)
                    {
                        yPos = 0;
                        xPos++;
                        box = xPos * iconsPerRow + hatchInv.GetItem(hoveredItem).GetSize();
                    }
                    if (iconIndex < box - hatchInv.GetItem(hoveredItem).GetSize())
                    {
                        hoveredItem = -1;
                        break;
                    }
                    if (box > iconIndex)
                    {
                        break;
                    }
                }

                if (hoveredItem < hatchInv.GetItemAmount() & Input.MousePressed)
                {
                    Item item = hatchInv.GetItem(hoveredItem);
                    if (playerInv.CanFitItem(item))
                    {
                        playerInv.AddItem(item);
                        hatchInv.RemoveItem(hoveredItem);
                    }
                    else
                    {
                        playerInv.InventoryTooFull(item);
                    }
                }
            }
            else
            {
                hoveredItem = -1;
            }
        }