예제 #1
0
 public void Init(Inventory.Slot slot)
 {
     this.slot = slot;
     GetComponent<Image> ().sprite = Resources.Load<Sprite> ("Texture/Item/"+slot.item.info.id);
     Transform count = transform.FindChild ("Count");
     count.GetComponent<Text> ().text = slot.count.ToString ();
 }
예제 #2
0
    public void Init(Inventory.Slot buttonSlot)
    {
        itemImage = GetComponentInChildren<RawImage> ();
        countText = GetComponentInChildren<Text> ();
        slot = buttonSlot;

        element = GetComponent<HoverContextElement> ();
    }
예제 #3
0
 void Start()
 {
     if (prefab) {
         singleSlot = Inventory.Slot.CreateSlot ();
         singleSlot.item = prefab.GetItem ();
         singleSlot.count = count;
         UpdateGraphics ();
     }
 }
예제 #4
0
파일: SlotUI.cs 프로젝트: Orkad/Zombie2D
 public void Init(Inventory.Slot slot)
 {
     if (slot.Empty)
     {
         text.text = "";
         return;
     }
     image.sprite = slot.item.icon;
     text.text    = slot.count.ToString();
 }
예제 #5
0
 // Use this for initialization
 void Awake()
 {
     camera = Camera.main;
     cur = this;
     defaultFixedDeltaTime = Time.fixedDeltaTime;
     itemInHand = Inventory.Slot.CreateSlot ();
     SetAdvancedCommand (0);
 }
예제 #6
0
    public void UpdateAmmunition()
    {
        if (!character)
            return;

        characterAmmoSlot = character.FindSlotByType (CharacterEquipment.Slot.Ammo).item;

        if (characterAmmoSlot.item) {
            body.currentAmmoPrefab = characterAmmoSlot.item.prefab;
            currentProjectile = body.currentAmmoPrefab.gameObject.GetComponent<Projectile> ();
        }else {
            body.currentAmmoPrefab = null;
            currentProjectile = null;
        }
    }
예제 #7
0
 public CP28CreativeInventoryAction(MinecraftClient client, Stream stream) : base(client, stream)
 {
     Slot        = Data.ReadShort();
     ClickedItem = Data.ReadSlot();
 }
예제 #8
0
        public void HandleWorldAction(MinecraftPacket packet)
        {
            switch (packet)
            {
            case CP1BPlayerDigging digging:
                bool IsLegal(double x1, double y1, double z1, double x2, double y2, double z2)
                {
                    return(Math.Sqrt(Math.Pow(x2 - x1, 2) + Math.Pow(y2 - y1, 2) + Math.Pow(z2 - z1, 2)) <= 6.0);
                }

                BlockBase block = Parent.GetBlock(digging.Location.X, digging.Location.Y, digging.Location.Z);
                SP07AcknowledgePlayerDigging acknowledgePlayerDigging;

                if (block == null)
                {
                    acknowledgePlayerDigging = new SP07AcknowledgePlayerDigging(Client, digging.Location, 0,
                                                                                (SP07AcknowledgePlayerDigging.ActionType)digging.Status, false);
                    Client.Send(acknowledgePlayerDigging);
                    break;
                }

                if (!IsLegal(X, Y + 1.5, Z, digging.Location.X, digging.Location.Y, digging.Location.Z))
                {
                    acknowledgePlayerDigging = new SP07AcknowledgePlayerDigging(Client, digging.Location, block.State,
                                                                                (SP07AcknowledgePlayerDigging.ActionType)digging.Status, false);
                    Client.Send(acknowledgePlayerDigging);
                    break;
                }

                acknowledgePlayerDigging = new SP07AcknowledgePlayerDigging(Client, digging.Location, block.State,
                                                                            (SP07AcknowledgePlayerDigging.ActionType)digging.Status, true);
                Client.Send(acknowledgePlayerDigging);

                // TODO block break animation

                CP1BPlayerDigging.ActionType requiredAction;

                if (Gamemode == Gamemode.Creative)
                {
                    requiredAction = CP1BPlayerDigging.ActionType.StartedDigging;
                }
                else
                {
                    requiredAction = CP1BPlayerDigging.ActionType.FinishedDigging;
                }

                if (digging.Status == requiredAction)
                {
                    BlockBase air = new BlockAir();

                    Parent.SetBlock(air, digging.Location.X, digging.Location.Y, digging.Location.Z);

                    SP0BBlockChange blockChange = new(null, digging.Location, air.State);
                    Client.Server.MulticastAsync(blockChange, Client, Parent.GetClientsWithChunkLoaded(
                                                     (int)Math.Floor((double)digging.Location.X / Chunk.X_SIZE),
                                                     (int)Math.Floor((double)digging.Location.Z / Chunk.Z_SIZE)).ToArray());
                }
                break;

            case CP2EPlayerBlockPlacement playerBlockPlacement:
                Position.Int pos = new(playerBlockPlacement.Location);

                switch (playerBlockPlacement.Face)
                {
                case Face.Top:
                    pos.Y++;
                    break;

                case Face.Bottom:
                    pos.Y--;
                    break;

                case Face.North:
                    pos.Z--;
                    break;

                case Face.East:
                    pos.X++;
                    break;

                case Face.South:
                    pos.Z++;
                    break;

                case Face.West:
                    pos.X--;
                    break;
                }

                // TODO check for collisions here

                if (Parent.GetBlock(pos.X, pos.Y, pos.Z) == null)
                {
                    Inventory.Slot held = Inventory.Slots[Inventory.HeldSlot];

                    if (!held.IsEmpty() && held.Item is BlockItem item)
                    {
                        block = BlockRepository.Create(item.BlockProtocolId);

                        if (block == null || block.State == 0)
                        {
                            break;
                        }

                        if (pos.Y < 0 || pos.Y >= Chunk.Y_SIZE)
                        {
                            return;
                        }

                        Parent.SetBlock(block, pos.X, pos.Y, pos.Z);

                        SP0BBlockChange _blockChange = new(null, pos, block.State);
                        Client.Server.MulticastAsync(_blockChange, Client, Parent.GetClientsWithChunkLoaded(
                                                         (int)Math.Floor((double)pos.X / Chunk.X_SIZE),
                                                         (int)Math.Floor((double)pos.Z / Chunk.Z_SIZE)).ToArray());
                    }
                }
                break;

            case CP1CEntityAction:
                break;
            }
        }
예제 #9
0
        public IEnumerator Drop(float waitTime)
        {
            yield return new WaitForSeconds (waitTime);

            Rigidbody body = transform.GetComponentInParent<Rigidbody> ();
            GameObject pItem = PhysicalItem.Create (item.item, item.count, transform.position, transform.rotation).gameObject;
            Rigidbody drop = pItem.GetComponent<Rigidbody> ();

            drop.velocity = body.velocity;
            drop.angularVelocity = body.angularVelocity;

            item = null;
            Update ();
        }