Exemplo n.º 1
0
    public static void Bag(ItemSprite sprite)
    {
        ItemBag item     = sprite.Reference.GetComponent <ItemBag>();
        int     bagSpace = item.BagStorageLimit;

        UI.root.InventorySlotGrid.GetComponent <InventoryGridManager>().ChangeActiveInventorySlots(bagSpace);
    }
Exemplo n.º 2
0
    void PlaceSprites()
    {
        print("placed Sprites");
        int n = 0;

        for (int y = 0; y < shape.rows.Length; y++)
        {
            for (int x = 0; x < shape.rows[y].row.Length; x++)
            {
                if (shape.rows[y].row[x])
                {
                    //print (x + " - " + y);
                    Vector3 displacement = new Vector3(x - center.x, y - center.y, 0);

                    mySprites [n] = (GameObject)Instantiate(ItemSpritePrefab, transform.position + displacement, transform.rotation);
                    mySprites [n].transform.parent = transform;
                    ItemSprite mySprite = mySprites [n].GetComponent <ItemSprite> ();
                    mySprite.x = (int)displacement.x;
                    mySprite.y = (int)displacement.y;
                    n++;
                }
            }
        }
        transform.rotation = Quaternion.Euler(0, 0, 180);
    }
Exemplo n.º 3
0
    /*  private void Debug() {
     *    print("Slot Index " + i);
     *    print("Slot Active " + Slot.Active);
     *    print("Slot Child Count " + Slot.transform.childCount);
     *    print("Item Pickable " + itemPickable.Stackable);
     *    print("Limit of Stack " + limitOfStack);
     *    print("IgnoreCommonItems " + ignoreCommonItems);
     *    print("Quantity " + quantity);
     * }*/

    private void Single_AddToSlot(ItemPickable itemPickable, InventorySlotManager Slot)
    {
        GameObject item       = new GameObject();
        ItemSprite itemSprite = item.AddComponent <ItemSprite>();
        RawImage   image      = item.AddComponent <RawImage>();

        itemSprite.Reference = itemPickable.gameObject;
        itemSprite.Quantity  = 1;
        image.texture        = itemPickable.ItemIcon;
        image.SetNativeSize();
        image.rectTransform.sizeDelta = new Vector2(80, 80);
        if (itemPickable.transform.gameObject.GetComponent <ItemBlock>() != null)
        {
            item.name = itemPickable.transform.gameObject.GetComponent <ItemBlock>().BlockName;
        }
        else
        {
            item.name = itemPickable.gameObject.name;
        }
        item.transform.SetParent(Slot.transform, false);
        try
        {
            itemPickable.gameObject.GetComponent <Collider>().enabled     = false;
            itemPickable.gameObject.GetComponent <MeshRenderer>().enabled = false;
        }
        catch (Exception)
        {
            itemPickable.gameObject.SetActive(false);
        }
        Refresh();
    }
Exemplo n.º 4
0
    public void SetInactiveType(InactiveType _type, ItemSprite item = null, InactiveTrigger trigger = null)
    {
        current_stay_item    = item;
        curretn_stay_trigger = trigger;
        this.inactive_type   = _type;
        switch (_type)
        {
        case InactiveType.攻击:
            main_inactive_image.GetComponent <RectTransform>().sizeDelta        = new Vector2(110, 110);
            main_inactive_image.GetComponent <RectTransform>().anchoredPosition = new Vector2(-6.6f, -13.8f);
            main_inactive_image.GetComponent <EquipmentSprite>().UpdateIamgeSprite();
            break;

        case InactiveType.拾取:
            main_inactive_image.GetComponent <RectTransform>().sizeDelta        = new Vector2(50, 50);
            main_inactive_image.GetComponent <RectTransform>().anchoredPosition = Vector2.zero;
            main_inactive_image.sprite = inactive_sprite_dic[_type];
            break;

        case InactiveType.交互:
            main_inactive_image.GetComponent <RectTransform>().sizeDelta        = new Vector2(40, 40);
            main_inactive_image.GetComponent <RectTransform>().anchoredPosition = Vector2.zero;
            main_inactive_image.sprite = inactive_sprite_dic[_type];
            break;

        default:
            break;
        }
    }
Exemplo n.º 5
0
 private void ActivateSlots(int capacity, ItemPickable[] item, StorageViewable storage)
 {
     Clear();
     for (int i = 0; i < capacity; i++)
     {
         InventorySlotManager Slot = transform.GetChild(i).gameObject.GetComponent <InventorySlotManager>();
         Slot.Active = true;
         Slot.GetComponent <RawImage>().color = Active_Color;
         if (item[i] != null)
         {
             GameObject itemObject = new GameObject();
             ItemSprite itemSprite = itemObject.AddComponent <ItemSprite>();
             RawImage   image      = itemObject.AddComponent <RawImage>();
             itemSprite.Reference = item[i].gameObject;
             itemSprite.Quantity  = item[i].Quantity;
             image.texture        = item[i].ItemIcon;
             image.SetNativeSize();
             itemObject.name = item[i].name;
             itemObject.transform.SetParent(Slot.transform, false);
             try {
                 item[i].gameObject.GetComponent <Collider>().enabled     = false;
                 item[i].gameObject.GetComponent <MeshRenderer>().enabled = false;
             }
             catch (Exception e) {
                 item[i].gameObject.SetActive(false);
             }
         }
     }
     CheckDropForInActive();
 }
Exemplo n.º 6
0
 protected Weapon(string nameIn, int damage, float atkspd, Color levelIn, ItemSprite imageIn, Vector2 ItemSize, params Type[] EquippableBy) : base(nameIn, levelIn, imageIn)
 {
     Damage          = damage;
     AttackSpeed     = atkspd;
     EquippableClass = EquippableBy;
     Size            = ItemSize;
 }
Exemplo n.º 7
0
        private void ChangeItem(ushort item, ushort count)
        {
            var pb = PB_Item;

            pb.BackColor       = ItemColor.GetItemColor(item);
            pb.BackgroundImage = ItemSprite.GetItemSprite(item, count);
        }
Exemplo n.º 8
0
    public void OnDrop(PointerEventData data)
    {
        GameObject droppedObject = data.pointerDrag;
        ItemSprite droppedSprite = droppedObject.GetComponent <ItemSprite>();

        if (transform.childCount > 0 && Active &&
            droppedSprite.Reference.GetComponent <ItemPickable>().Stackable)  // checks if multiple/stackable

        {
            ItemSprite currentSprite    = transform.GetChild(0).gameObject.GetComponent <ItemSprite>();
            bool       stackableCurrent = currentSprite.Reference.GetComponent <ItemPickable>().Stackable;

            if (stackableCurrent)
            {
                int availableToTransfer = currentSprite.Reference.GetComponent <ItemPickable>().MaxStack - currentSprite.Quantity;
                if (droppedSprite.Reference.name == currentSprite.Reference.name)
                {
                    bool limitOfStack = currentSprite.QuantityChange(droppedSprite.Quantity, droppedSprite.Reference.GetComponent <ItemPickable>());
                    if (limitOfStack)
                    {
                        droppedSprite.enableAllBlockRaycast();
                        currentSprite.gameObject.GetComponent <CanvasGroup>().blocksRaycasts = true;
                        currentSprite.QuantityChangeImplicit(droppedSprite.Quantity);
                        currentSprite.UpdateQuickSlotInfo();
                        droppedSprite.ClearQuickSlotInfo();
                        droppedSprite.willDestroy();
                        Destroy(droppedSprite.Reference.gameObject);
                        Destroy(droppedObject, 0.25f);
                    }
                    else
                    {
                        if (droppedSprite.Quantity > 0 && availableToTransfer > 0)
                        {
                            currentSprite.UpdateQuickSlotInfo();
                            droppedSprite.UpdateQuickSlotInfo();
                            droppedSprite.QuantityChangeImplicit(-availableToTransfer);
                            currentSprite.QuantityChangeImplicit(availableToTransfer);
                        }
                    }
                }
            }
            else
            {
                if (transform.childCount == 0 && Active)
                {
                    droppedObject.transform.SetParent(transform);
                    droppedObject.GetComponent <CanvasGroup>().blocksRaycasts = true;
                }
            }
        }
        else
        {
            if (transform.childCount == 0 && Active)
            {
                droppedObject.transform.SetParent(transform);
                droppedObject.GetComponent <CanvasGroup>().blocksRaycasts = true;
            }
        }
    }
Exemplo n.º 9
0
        protected override void CreateChildren()
        {
            _sprite = new ItemSprite();
            Add(_sprite);

            _label = PixelScene.CreateText(8);
            Add(_label);
        }
Exemplo n.º 10
0
    public static void Medical(ItemSprite sprite)
    {
        ItemMedical item       = sprite.Reference.GetComponent <ItemMedical>();
        int         healthGain = item.HealthGain;

        UI.root.playerStats.healHealth(healthGain);
        sprite.QuantityChangeImplicit(-1);
    }
Exemplo n.º 11
0
    public void CheckWield()
    {
        // Hold something infront

        ItemSprite sprite = transform.GetChild(selectedSlot).gameObject.GetComponent <QuickSlotManager>().Reference;

        if (sprite == null || sprite.Reference == null) /*Debug.LogError("Sprite or SpriteReference is null");*/ return {
            ;
        }
Exemplo n.º 12
0
 public void DropItemSprite(ItemSprite iSprite)
 {
     if (iSprite.leftClick)
     {
         UI.root.playerInventory.DropItem(iSprite.Reference.GetComponent <ItemPickable>());
         iSprite.enableAllBlockRaycast();
         Destroy(iSprite.gameObject, 0.01f);
     }
 }
Exemplo n.º 13
0
 public FireBall(GraphicsDevice graphicsDevice, Texture2D tex, Peach p)
 {
     fireBall            = tex;
     Sprite              = new ItemSprite(graphicsDevice, fireBall, 1, 3, Constants.ZERO, 3);
     Sprite.Acceleration = new Vector2(Constants.ZERO, 1300);
     Consumed            = false;
     Checkable           = true;
     Shooter             = p;
 }
Exemplo n.º 14
0
 public static void MeleeWeapon(ItemSprite sprite)
 {
     if (sprite.QSReference != null)
     {
     }
     else
     {
         sprite.TransferToQuickSlot();
     }
 }
Exemplo n.º 15
0
 public ItemCharacter(Texture2D texture, Point rowsAndColumns, Vector2 location)
 {
     Item             = new ItemSprite(texture, location, rowsAndColumns);
     Parameters       = Item.Parameters;
     InitialParameter = new MoveParameters(false);
     Scene.CopyDataOfParameter(Parameters, InitialParameter);
     IsBump   = false;
     BumpHigh = 0;
     BumpLow  = Sprint5Main.Game.GraphicsDevice.Viewport.Height;
 }
Exemplo n.º 16
0
        private void cbItem_SelectedIndexChanged(object sender, EventArgs e)
        {
            var selectedItemId = (ushort)(int)cbItem.SelectedValue;
            var itemCount      = (ushort)0;

            pbItem.BackColor = ItemColor.GetItemColor(selectedItemId);
            pbItem.Image     = ItemSprite.GetItemSprite(selectedItemId, itemCount);
            SelectedItemInfo = itemConvertor.FromItemId(selectedItemId);
            OnItemChanged();
        }
Exemplo n.º 17
0
 public static void Telescopes(ItemSprite sprite)
 {
     if (sprite.QSReference != null)
     {
     }
     else
     {
         sprite.TransferToQuickSlot();
     }
 }
        private void LoadWorld()
        {
            RpgLibrary.WorldClasses.LevelData levelData =
                Game.Content.Load <RpgLibrary.WorldClasses.LevelData>(@"Game\Levels\Starting Level");

            RpgLibrary.WorldClasses.MapData mapData =
                Game.Content.Load <RpgLibrary.WorldClasses.MapData>(@"Game\Levels\Maps\" + levelData.MapName);

            TileMap map = TileMap.FromMapData(mapData, Game.Content);

            Level level = new Level(map);

            ChestData chestData = Game.Content.Load <ChestData>(@"Game\Chests\Plain Chest");

            Chest chest = new Chest(chestData);

            BaseSprite chestSprite = new BaseSprite(
                containers,
                new Rectangle(0, 0, 32, 32),
                new Point(10, 10));

            ItemSprite itemSprite = new ItemSprite(
                chest,
                chestSprite);

            level.Chests.Add(itemSprite);

            World world = new World(GameRef, GameRef.ScreenRectangle);

            world.Levels.Add(level);
            world.CurrentLevel = 0;

            AnimatedSprite s = new AnimatedSprite(
                GameRef.Content.Load <Texture2D>(@"SpriteSheets\Eliza"),
                AnimationManager.Instance.Animations);

            s.Position = new Vector2(0 * Engine.TileWidth, 5 * Engine.TileHeight);

            EntityData ed = new EntityData("Eliza", 10, 10, 10, 10, 10, 10, "20|CON|12", "16|WIL|16",
                                           "0|0|0");

            Entity e = new Entity("Eliza", ed, EntityGender.Female, EntityType.NPC);

            NonPlayerCharacter npc = new NonPlayerCharacter(e, s);

            npc.SetConversation("eliza1");
            world.Levels[world.CurrentLevel].Characters.Add(npc);

            GamePlayScreen.World = world;

            CreateConversation();

            ((NonPlayerCharacter)world.Levels[world.CurrentLevel].Characters[0]).SetConversation("eliza1");
        }
Exemplo n.º 19
0
        private ISprite MakeCoinSprite(ContentManager content, GraphicsDevice graphics)
        {
            ISprite   sprite;
            Texture2D coin = content.Load <Texture2D>("ItemSpriteSheet");

            sprite = new ItemSprite(graphics, coin, 5, 10, 2, 10);
            sprite.CurrentLocation = new Vector2(Top2ndLeft.X + 112, 1);
            sprite.ScaleSprite(1.5f);

            return(sprite);
        }
Exemplo n.º 20
0
        public override void Update()
        {
            ItemSprite.Update();
            Hitbox = ItemSprite.GetHitboxFromSprite(Location);

            itemTimer--;
            if (itemTimer == 0)
            {
                PlayerLevel.Instance.DespawnList.Add(this);
                ScoreKeeper.Instance.IncrementCoins();
            }
        }
Exemplo n.º 21
0
        private void SetItemSprite(Item item, PictureBox pb)
        {
            var dw   = Sprites.Width;
            var dh   = Sprites.Height;
            var font = L_ItemName.Font;

            pb.BackColor       = ItemColor.GetItemColor(item);
            pb.BackgroundImage = ItemSprite.GetItemSprite(item);
            var backing = new Bitmap(dw, dh);

            pb.Image = ItemSprite.GetItemMarkup(item, font, dw, dh, backing);
        }
Exemplo n.º 22
0
    public void Clear()
    {
        RawImage img = QuickSlotSprite.GetComponent <RawImage>();
        Color    c   = new Color(255f, 255f, 255f, 0f);

        img.color             = c;
        img.texture           = null;
        itemName.text         = "";
        itemQty.text          = "";
        Reference.QSReference = null;
        Reference             = null;
    }
Exemplo n.º 23
0
        public virtual void InventoryRender(Vector2 position)
        {
            if (!myGraphicsInitialized)
            {
                InitializeGraphics();
            }

            if (ItemSprite.Position != position)
            {
                ItemSprite.Position = position;
            }
            ItemSprite.Render();
        }
Exemplo n.º 24
0
 public void DropItems()
 {
     if (transform.childCount > 0)
     {
         ItemSprite sprite = transform.GetChild(0).gameObject.GetComponent <ItemSprite>();
         UI.root.playerInventory.DropItem(sprite.Reference.GetComponent <ItemPickable>());
         if (sprite.QSReference != null)
         {
             sprite.QSReference.GetComponent <QuickSlotManager>().Clear();
         }
         Destroy(transform.GetChild(0).gameObject);
     }
 }
Exemplo n.º 25
0
        protected ItemModel(ItemEnemySpriteFactory itemEnemySpriteFactory)
        {
            ItemEnemySpriteFactory = itemEnemySpriteFactory;
            Sprite    = new ItemSprite(this);
            IsVisible = true;
            ConsumedPositionFactor = 1;
            Support        = false;
            CanGravity     = false;
            verticalV      = 1;
            horizontalV    = 0;
            MoveAwayFactor = new Vector2(horizontalV, verticalV);

            Time = new Stopwatch();
        }
Exemplo n.º 26
0
Arquivo: Main.cs Projeto: val7x/NHSE
        private void Main_KeyDown(object sender, KeyEventArgs e)
        {
            if (ModifierKeys != Keys.Control)
            {
#if DEBUG
                if (ModifierKeys == (Keys.Control | Keys.Alt) && e.KeyCode == Keys.D)
                {
                    DevUtil.UpdateAll();
                }
#endif
                return;
            }

            switch (e.KeyCode)
            {
            case Keys.O:
            {
                Menu_Open(sender, e);
                break;
            }

            case Keys.I:
            {
                ItemSprite.Initialize(GameInfo.GetStrings("en").itemlist);
                var items = new Item[40];
                for (int i = 0; i < items.Length; i++)
                {
                    items[i] = new Item(Item.NONE);
                }
                using var editor = new PlayerItemEditor(items, 10, 4, true);
                editor.ShowDialog();
                break;
            }

            case Keys.H:
            {
                using var editor = new SysBotRAMEdit(InjectionType.Generic);
                editor.ShowDialog();
                break;
            }

            case Keys.P:
            {
                using var editor = new SettingsEditor();
                editor.ShowDialog();
                break;
            }
            }
        }
Exemplo n.º 27
0
        protected override void CreateChildren()
        {
            base.CreateChildren();

            Icon = new ItemSprite();
            Add(Icon);

            TopLeft = new BitmapText(PixelScene.font1x);
            Add(TopLeft);

            TopRight = new BitmapText(PixelScene.font1x);
            Add(TopRight);

            BottomRight = new BitmapText(PixelScene.font1x);
            Add(BottomRight);
        }
Exemplo n.º 28
0
            protected override void CreateChildren()
            {
                base.CreateChildren();

                _shield = new ItemSprite(ItemSpriteSheet.TOMB, null);
                Add(_shield);

                _position = new BitmapText(font1x);
                Add(_position);

                _desc = CreateMultiline(9);
                Add(_desc);

                _classIcon = new Image();
                Add(_classIcon);
            }
Exemplo n.º 29
0
 public void CheckReferences()
 {
     for (int i = 0; i < UI.root.InventorySlotGrid.transform.childCount; i++)
     {
         GameObject Slot = UI.root.InventorySlotGrid.transform.GetChild(i).gameObject;
         if (Slot.transform.childCount != 0)
         {
             ItemSprite sprite = Slot.transform.GetChild(0).GetComponent <ItemSprite>();
             if (sprite != null)
             {
                 if (sprite.Reference == null)
                 {
                     Destroy(sprite.gameObject);
                 }
             }
         }
     }
 }
Exemplo n.º 30
0
 public BeginningState(GameMain game)
 {
     Game      = game;
     TextFont  = Game.Content.Load <SpriteFont>("Fonts/File");
     TopCenter = new Vector2(100, 200);
     Peach     = new Peach(Game.Content, Game.GraphicsDevice);
     Peach.Sprite.Acceleration = new Vector2(Constants.ZERO, Constants.ZERO);
     University       = Game.Content.Load <Texture2D>("University");
     UniversitySprite = new ItemSprite(Game.GraphicsDevice, University, 1, 1, Constants.ZERO, 1);
     UniversitySprite.CurrentLocation = new Vector2(500, 500);
     Logo       = Game.Content.Load <Texture2D>("IntroLogo");
     LogoSprite = new ItemSprite(Game.GraphicsDevice, Logo, 1, 18, Constants.ZERO, 18);
     LogoSprite.CurrentLocation = new Vector2(600, 400);
     LogoSprite.ScaleSprite(4f);
     LogoSprite.LoopFrame = true;
     Peach.Location       = new Vector2(Constants.ZERO, 930);
     TimeRemaining        = Constants.TIMER_BEGINNING;
     passedSeconds        = Constants.ZERO;
 }