public MainWindow() { #region Подготовка карты и панели меню InitializeComponent(); // Определяем вид разметки окна: область карты слева и меню справа Lay = LayoutsFactory.GetLayout(LayoutType.Vertical, this.Content); // Определяем параметры карты: количество клеток по горизонтали и вертикали, размер клетки, // ширина декоративной рамки вокруг карты MapInfo = new CellMapInfo(35, 20, 50, 0); // Создаем карту и размещаем его в окне программы Map = MapCreator.GetUniversalMap(this, MapInfo); Lay.Attach(Map, 0); //Map.DrawGrid(); // выводим сетку // Указываем путь к папке с картинками Map.Library.ImagesFolder = new PathInfo { Path = "..\\..\\..\\..\\i", Type = PathType.Relative }; // Создаем панель инвентаря и размещаем ее в меню hppanel = new InventoryPanel(Map.Library, 150); //hppanel2 = new InventoryPanel(Map.Library, 150); //Items1 = new InventoryPanel(Map.Library, 50); //Items2 = new InventoryPanel(Map.Library, 50); Lay.Attach(hppanel, 1); //Lay.Attach(Items1, 1); //Lay.Attach(hppanel2, 1); //Lay.Attach(Items2, 1); hppanel.SetBackground(Brushes.Wheat); // Создаем текстовую панель и размещаем ее в меню Info = new TextArea_Vertical(); Lay.Attach(Info, 1); Info.AddTextBlock("expEnemy"); Info.AddTextBlock("expMine"); // определяем функцию, которая будет вызвана при нажатии на клавишу //Map.Keyboard.SetSingleKeyEventHandler(CheckKey); #endregion player = new GameObject(); player.y = 50; player.speed = 3; player.reload = 100000; player.ammo = 40; player.hp = 10; player.InventoryPanel = hppanel; addPictures(); //player.Name = Map.SetMapBackground("map"); Name Start = new Name(); Start.player = player; Start.ShowDialog(); timer.AddAction(BCE, 10); timer.AddAction(mishen, 30000); timer.AddAction(spaunEnemy, 3000); timer.AddAction(sudba, 60000); hppanel.AddItem("hp", "hp10"); hppanel.AddItem("box", "box", player.ammo.ToString()); }
void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Player") { inventoryPanel.AddItem(id, title, description, health, food, consumable, stackMax); Destroy(gameObject); } }
// Equip Item // - Can be From Inventory to Equipment Panel public void Equip(Equipment equipment) { // Remove from Inventory if (inventory.RemoveItem(equipment)) { Equipment previousEquipment; // Add New Equipment by Swapping if (equipmentPanel.AddEquipment(equipment, out previousEquipment)) { // REturn Previous Equipment back to Inventory inventory.AddItem(previousEquipment); } else { // REturn the Equipping if not Equippable inventory.AddItem(equipment); } } }
private void OnControllerColliderHit(ControllerColliderHit hit) { InventoryItemBase item = hit.collider.GetComponent <InventoryItemBase>(); if (item != null) { inventory.AddItem(item); // Destroy(this.gameObject); } }
void OnTriggerStay2D(Collider2D other) { if (other.tag == "Player" && Input.GetButton("Collect")) { bool room = inventoryScript.RoomAvailable(); // check if there's enough room in inventory if (room) { inventoryScript.AddItem(title, description, health, food, consumable, stackMax, image); Destroy(gameObject); } } }
public void BuyItem(int productID) { GameObject item = shopItemsList[productID]; PickUp itemScript = item.GetComponent <PickUp>(); bool aBool = inventoryScript.RoomAvailable(); bool bBool = currencyScript.currentAmount >= itemScript.buyPrice; if (aBool && bBool) { inventoryScript.AddItem(itemScript.title, itemScript.description, itemScript.health, itemScript.food, itemScript.consumable, itemScript.stackMax, itemScript.image); currencyScript.SubtractCurrency(itemScript.buyPrice); } }
public MainWindow() { UGameObjectBase.game = game; Behavior.game = game; InitializeComponent(); Lay = LayoutsFactory.GetLayout(LayoutType.Vertical, this.Content); MapInfo = new CellMapInfo(50, 31, 30, 5); game.Map = MapCreator.GetUniversalMap(this, MapInfo); game.Map.Mouse.SetMouseSingleLeftClickHandler(game.setMovementGoalByClick); Lay.Attach(game.Map, 0); //game.Map.DrawGrid(); unitsPanel = new InventoryPanel(game.Map.Library, game.Map.CellSize); Lay.Attach(unitsPanel, 1); unitsPanel.SetBackground(Brushes.Wheat); game.Map.SetMapBackground(Brushes.Black); info = new TextArea_Vertical(); Lay.Attach(info, 1); info.AddTextBlock("Resources"); AddPictures(); unitsPanel.AddItem("allyLightTank", "tank1", "Light Tank"); unitsPanel.SetMouseClickHandler(CheckInventoryClick); unitsPanel.AddItem("allyMediumTank", "MediumTank", "Medium Tank"); unitsPanel.AddItem("scavenger", "scavenger", "scavenger"); game.timer.AddAction(ShowResources, 1000); game.AddBase(game.Map.XAbsolute / 2, game.Map.YAbsolute / 2, "base"); // game.CreateTank("scavenger", 500, 500); // game.AddObject("SimpleFlyer", new GOParams { X = game.Map.XAbsolute, Y = game.Map.YAbsolute }); //game.CreateTank("enemyLightTank", 1300, 500); // game.CreateTank("Baneblade",100, 200); game.CreateTank("enemyLightTank", 5, 500); }
private void AddItem(Item item) { inventoryItems.Add(item); inventoryVisual.AddItem(item); }
public MainWindow() { InitializeComponent(); Lay = LayoutsFactory.GetLayout(LayoutType.Vertical, this.Content); MapInfo = new CellMapInfo(38, 20, 50, 5); map = MapCreator.GetUniversalMap(this, MapInfo); Lay.Attach(map, 0); Inventory = new InventoryPanel(map.Library, 50, 14); Lay.Attach(Inventory, 1); Helper.map = map; map.Library.ImagesFolder = new PathInfo { Path = "..\\..\\images", Type = PathType.Relative }; map.Library.AddPicture("wall", "wall.png"); map.Library.AddPicture("fire", "Fire0.png"); map.Library.AddPicture("Gem0", "gem_green.png"); map.Library.AddPicture("Gem1", "gem_blue.png"); map.Library.AddPicture("Gem2", "gem_red.png"); map.Library.AddPicture("stones", "stones.jpg"); map.Library.AddPicture("ghost0", "GHOST.png"); map.Library.AddPicture("ghost1", "GHOST1.png"); map.Library.AddPicture("ghost2", "GHOST2.png"); map.Library.AddPicture("gate closed", "gate_closed.png"); map.Library.AddPicture("chest", "Chest.png"); for (int I = 0; I <= 3; I++) { for (int j = 0; j <= 3; j++) { map.Library.AddPicture("Portal" + I.ToString() + j.ToString(), "Portal" + I.ToString() + j.ToString() + ".png"); } } string[] exp = new string[11]; string[] Fire = new string[10]; string[] Portal0 = new string[4]; string[] Portal1 = new string[4]; string[] Portal2 = new string[4]; string[] Portal3 = new string[4]; for (int i = 0; i <= 10; i++) { exp[i] = "exp" + i.ToString(); map.Library.AddPicture(exp[i], exp[i] + ".png"); } for (int i = 0; i <= 9; i++) { Fire[i] = "Fire" + i.ToString(); map.Library.AddPicture(Fire[i], Fire[i] + ".png"); } for (int i = 0; i <= 3; i++) { Portal0[i] = "Portal0" + i.ToString(); Portal1[i] = "Portal1" + i.ToString(); Portal2[i] = "Portal2" + i.ToString(); Portal3[i] = "Portal3" + i.ToString(); } map.Library.AddPicture("fon", "Fon.jpg"); map.SetMapBackground("stones"); Inventory.AddItem("Lives", "Fire0"); Inventory.SetBackground(Brushes.Transparent); AnimationDefinition a = new AnimationDefinition(); a.AddEqualFrames(50, exp); a.LastFrame = "exp10"; map.Library.AddAnimation("Explosion", a); AnimationDefinition b = new AnimationDefinition(); b.AddEqualFrames(80, Fire); b.LastFrame = "Fire9"; map.Library.AddAnimation("Fire", b); AnimationDefinition c = new AnimationDefinition(); c.AddEqualFrames(80, Portal0); c.LastFrame = "Portal03"; map.Library.AddAnimation("Portal0", c); AnimationDefinition d = new AnimationDefinition(); d.AddEqualFrames(80, Portal1); d.LastFrame = "Portal13"; map.Library.AddAnimation("Portal1", d); AnimationDefinition f = new AnimationDefinition(); f.AddEqualFrames(80, Portal2); f.LastFrame = "Portal23"; map.Library.AddAnimation("Portal2", f); AnimationDefinition e = new AnimationDefinition(); e.AddEqualFrames(80, Portal3); e.LastFrame = "Portal33"; map.Library.AddAnimation("Portal3", e); Helper.PlayerRun = Helper.PlayerWalk * 2; //map.Library.AddContainer("wall", "wall"); //map.ContainerSetSize("wall", 50, 50); //map.ContainerSetCoordinate("wall", WallX, WallY); CreateGems(); CreatePlayer(); CreateWalls(20, 500, 50, 1020); CreateWalls(975, 20, 1860, 50); CreateWalls(1880, 530, 50, 975); CreateWalls(950, 978, 1815, 50); CreateWalls(500, 500, 250, 250); for (int i = 0; i < 3; i++) { CreateEnemy(); } CreateContainers("Chest", 101, "chest"); map.ContainerSetCoordinate("Chest", 1000, 700); CreatePortals(0, 100, 200); CreatePortals(1, 800, 900); CreatePortals(2, 1000, 500); CreatePortals(3, 1800, 300); //map.Library.AddContainer("fon", "wall", ContainerType.TiledImage); //map.ContainerSetSize("fon", 50, 500); //map.ContainerSetTileSize("fon", 50, 50); //map.ContainerSetCoordinate("fon",25, 25); Player.SetCoordinates(80, 80); timer.AddAction(CheckKey, 10); timer.AddAction(MoveEnemies, 10); timer.AddAction(PlayerPlusEnemy, 10); //Done:Доделать движение: устранить эффект перепрыгивания стены, вернув координаты в исходное состояние; добавить 2 кнопки. //Dont know how:Сделать функцию, которая принимает все параметры контейнера и создает его, чтобы в основной программе можно было создать контейнер в одну строчку. //Done:Сделать так, чтобы после сбора кристалла он появлялся в случайном месте, но не ближе 100 пикселей к игроку. //Создать класс для кристала. //* Продумать механику игры. }
public void Tester_AddItem() { Item temp = Instantiate(item); Debug.Log(inventoryPanel.AddItem(temp)); }