Beispiel #1
0
        public void Send(ref MinecraftClient client, GameStream stream)
        {
            int data = 0;

            switch (_entity.Identifier.Name)
            {
            case "item_frame":
                ItemFrame iFrame = (ItemFrame)_entity;
                data = iFrame.Rotation;
                break;

            case "falling_block":
                /*FallingBlock fBlock = (FallingBlock) _entity;
                 * data = fBlock.World.GetAtPosition(fBlock.SpawnPosition).State*/
                break;

            case "fishing_hook":
                FishingHook fHook = (FishingHook)_entity;
                data = fHook.HookedId;
                break;
            }

            Protocol.Send(ref client, stream, Packet,
                          _entity.Id, _entity.UniqueId.ToString(),
                          _entity.Type,
                          _entity.Position.X, _entity.Position.Y, _entity.Position.Z,
                          _entity.Position.Pitch, _entity.Position.Yaw,
                          data,
                          (short)_entity.Velocity.X,
                          (short)_entity.Velocity.Y,
                          (short)_entity.Velocity.Z);
        }
Beispiel #2
0
    // Use this for initialization
    void Start()
    {
        playerMain = mainPlayer.GetComponent <PlayerMain> ();

        healthUI       = transform.Find("BottomLeft/HealthBar/EnergyMask/Energy").gameObject.GetComponent <RectTransform> ();
        healthHolderUI = transform.Find("BottomLeft/HealthBar/HolderMask/Holder").gameObject.GetComponent <RectTransform> ();

        energyUI       = transform.Find("BottomLeft/EnergyBar/EnergyMask/Energy").gameObject.GetComponent <RectTransform> ();
        energyHolderUI = transform.Find("BottomLeft/EnergyBar/HolderMask/Holder").gameObject.GetComponent <RectTransform> ();

        levelPercent    = transform.Find("BottomLeft/Level/Green").gameObject.GetComponent <Image> ();
        levelTextSetter = transform.Find("BottomLeft/Level").gameObject.GetComponent <LevelTextSetter> ();

        wingOutline = transform.Find("Top/Wings/Outline").gameObject.GetComponent <Image> ();
        wingFillL   = transform.Find("Top/Wings/FillL").gameObject.GetComponent <Image> ();
        wingFillR   = transform.Find("Top/Wings/FillR").gameObject.GetComponent <Image> ();

        invGroup = transform.Find("TopRight").gameObject.GetComponent <CanvasGroup> ();

        weaponFrame   = new ItemFrame();
        armorFrame    = new ItemFrame();
        artifactFrame = new ItemFrame();
        pickupFrame   = new ItemFrame();

        weaponFrame.SetupIcons("FrameWeapon", transform);
        armorFrame.SetupIcons("FrameArmor", transform);
        artifactFrame.SetupIcons("FrameArtifact", transform);
        pickupFrame.SetupIcons("FramePickup", transform);

        invSelector = transform.Find("TopRight/Selector").gameObject.GetComponent <RectTransform> ();
    }
        public static Block GetBlock(this BlockEntity input)
        {
            Block Block = new Air();

            switch (input.Id)
            {
            case "Sign":
                Block = new StandingSign();
                break;

            case "Chest":
                Block = new Chest();
                break;

            case "EnchantTable":
                Block = new EnchantingTable();
                break;

            case "Furnace":
                Block = new Furnace();
                break;

            case "Skull":
                Block = new Skull();
                break;

            case "ItemFrame":
                Block = new ItemFrame();
                break;
            }
            return(Block);
        }
Beispiel #4
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (ItemId != 0L)
            {
                hash ^= ItemId.GetHashCode();
            }
            if (ItemSubCategory != 0)
            {
                hash ^= ItemSubCategory.GetHashCode();
            }
            if (ItemImageName.Length != 0)
            {
                hash ^= ItemImageName.GetHashCode();
            }
            if (ItemFrame != 0)
            {
                hash ^= ItemFrame.GetHashCode();
            }
            if (ItemType != 0)
            {
                hash ^= ItemType.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Beispiel #5
0
        public void GetItem()
        {
            var item      = new Item(3, 2, 1);
            var itemFrame = new ItemFrame(Vector.Zero, item);

            Assert.That(itemFrame.Item, Is.EqualTo(item));
        }
Beispiel #6
0
        public void WithPosition(int x, int y)
        {
            ITileEntity itemFrame = new ItemFrame(Vector.Zero, new Item());

            itemFrame = itemFrame.WithPosition(new Vector(x, y));

            Assert.That(itemFrame.Position, Is.EqualTo(new Vector(x, y)));
        }
Beispiel #7
0
 void drawItem(Item it)
 {
     tmp = GameObject.Instantiate(itemFrame);
     tmp.transform.SetParent(gameObject.transform);
     tmp_rt                   = tmp.GetComponent <RectTransform>();
     tmp_rt.localScale        = item_frame_rt.localScale;
     tmp_rt.anchoredPosition  = item_frame_rt.anchoredPosition;
     tmp_rt.anchoredPosition += new Vector2(0, (item_frame_rt.rect.height + 1.5f) * -rectSize);
     tmpIF = tmp.GetComponent <ItemFrame>();
     itemFrames.Add(tmpIF);
     //Debug.Log(playerInventory.inventory[i].name);
     //Debug.Log(playerInventory.inventory[i].value);
     tmpIF.name  = it.name;
     tmpIF.value = it.value;
     tmpIF.item  = it;
     tmpIF.setValues();
     //tmp.SetActive(true);
     //gameObject.SetActive(true);
     listItemFrame.Add(tmpIF);
     //Debug.Log("updateuje menu");
     rectSize++;
 }
Beispiel #8
0
        /// <summary>
        /// 获取物品信息
        /// </summary>
        public void GetItemInfo()
        {
            ItemPicture.Visibility = Visibility.Collapsed;
            string regex = ("\"" + SelectedItem.ID + "\":{\"id\":\"[\\d]*?\",\"img\":\"[\\s\\S]*?\",\"dname\":\"([\\s\\S]*?)\",\"qual\":[\\s\\S]*?,\"cost\":([\\s\\S]*?),\"desc\":\"([\\s\\S]*?)\",\"notes\":\"([\\s\\S]*?)\",\"attrib\":\"([\\s\\S]*?)\",\"mc\":([\\s\\S]*?),\"cd\":([\\s\\S]*?),\"lore\":\"([\\s\\S]*?)\",\"components\":[\\s\\S]*?,\"created\":[\\s\\S]*?}");
            Match  match = Regex.Match(json, regex);

            string regexComponents = ("\"" + SelectedItem.ID + "\":{\"id\":[\\s\\S]*?,\"components\":([\\s\\S]*?),\"created\":[\\s\\S]*?}");
            Match  matchComponents = Regex.Match(jsonComponents, regexComponents);

            SelectedItem.Name  = UnicodeToString(match.Groups[1].Value);
            SelectedItem.Price = UnicodeToString(match.Groups[2].Value).Replace("\"", "");
            SelectedItem.Info  = UnicodeToString(match.Groups[3].Value.Replace(" \\/", "").Replace("<br>", "\r\n").Replace("<br />", "").Replace("<\\/h1>", "").Replace("<h1>", "").Replace("<span class=\\\"attribVal\\\">", "").Replace("<\\/span>", "").Replace("<span class=\\\"attribValText\\\">", "")
                                                 .Replace("\\/", "/").Replace("\t", "\r\n").Replace("\\\\", "\\").Replace("\\r", "").Replace("\\n", "").Replace("<span class=\\\"GameplayValues GameplayVariable\\\">", "").Replace("<font color='#e03e2e'>", "\r\n").Replace("</font>", ""));
            SelectedItem.Tips       = UnicodeToString(match.Groups[4].Value.Replace(" \\/", "").Replace("\\\\", "\\").Replace("<br>", "\r\n").Replace("\\r", "").Replace("\\n", ""));
            SelectedItem.Attributes = UnicodeToString(match.Groups[5].Value.Replace("\\/", "/").Replace("<span class=\\\"attribVal\\\">", "").Replace("</span>", "").Replace("<\\/span>", "").Replace("<span class=\\\"attribValText\\\">", "")
                                                      .Replace("\\\\", "\\").Replace("<br>", "\r\n").Replace("< br>", "\r\n").Replace("\\r", "").Replace("\\n", "").Replace("<br />", "\r\n").Replace("<p class=\\\"pop_skill_p\\\">", "").Replace("<span class=\\\"color_yellow\\\">", "").Replace("</p>", "").Replace("+", "\r\n+"));
            SelectedItem.Mana       = UnicodeToString(match.Groups[6].Value.Replace("false", "0").Replace("\"\"", "0").Replace("\"", ""));
            SelectedItem.CoolDown   = UnicodeToString(match.Groups[7].Value.Replace("false", "0").Replace("\"\"", "0").Replace("\"", ""));
            SelectedItem.Background = UnicodeToString(match.Groups[8].Value).Replace("\\n", "\n");
            SelectedItem.Components = matchComponents.Groups[1].Value.Replace("[", "").Replace("]", "").Replace("\"", "").Replace("\\", "").Split(',');
            ItemFrame.Navigate(typeof(ItemInfoPage));
        }
        public void WriteRead()
        {
            var tiles = new Tile?[10, 10];

            Main.tileFrameImportant[1] = true;
            var tile = new Tile {
                IsActive = true, BlockColor = 1, WallColor = 1, BlockId = 1, WallId = 1, Liquid = 255
            };

            for (var x = 0; x < 10; ++x)
            {
                for (var y = 0; y < 10; ++y)
                {
                    tiles[x, y] = tile;
                }
            }
            var clipboard = new Clipboard(tiles);
            var items     = new Item[40];

            items[0] = new Item(1, 2, 3);
            var chest         = new Chest(new Vector(0, 1), "Test", new Item[40]);
            var itemFrame     = new ItemFrame(new Vector(3, 4), new Item(1, 2, 3));
            var logicSensor   = new LogicSensor(new Vector(2, 5), LogicSensorType.Day, true, 5);
            var sign          = new Sign(new Vector(1, 0), "Test2");
            var trainingDummy = new TrainingDummy(new Vector(4, 5), 21);

            clipboard.AddTileEntity(chest);
            clipboard.AddTileEntity(itemFrame);
            clipboard.AddTileEntity(logicSensor);
            clipboard.AddTileEntity(sign);
            clipboard.AddTileEntity(trainingDummy);
            var schematicFormat = new DefaultSchematicFormat();

            Clipboard clipboard2;

            using (var stream = new MemoryStream())
            {
                schematicFormat.Write(clipboard, stream);
                stream.Position = 0;
                clipboard2      = schematicFormat.Read(stream);

                Assert.That(clipboard2, Is.Not.Null);
            }

            for (var x = 0; x < 10; ++x)
            {
                for (var y = 0; y < 10; ++y)
                {
                    Assert.That(clipboard2.GetTile(new Vector(x, y)), Is.EqualTo(tile));
                }
            }
            foreach (var entity in clipboard2.GetTileEntities())
            {
                if (entity is Chest chest2)
                {
                    Assert.That(chest2.Position, Is.EqualTo(chest.Position));
                    Assert.That(chest2.Name, Is.EqualTo(chest.Name));
                    Assert.That(chest2.Items, Is.EquivalentTo(chest2.Items));
                }
                else if (entity is ItemFrame itemFrame2)
                {
                    Assert.That(itemFrame2.Position, Is.EqualTo(itemFrame.Position));
                    Assert.That(itemFrame2.Item, Is.EqualTo(itemFrame.Item));
                }
                else if (entity is LogicSensor logicSensor2)
                {
                    Assert.That(logicSensor2.Position, Is.EqualTo(logicSensor.Position));
                    Assert.That(logicSensor2.Type, Is.EqualTo(logicSensor.Type));
                    Assert.That(logicSensor2.IsEnabled, Is.EqualTo(logicSensor.IsEnabled));
                    Assert.That(logicSensor2.Data, Is.EqualTo(logicSensor.Data));
                }
                else if (entity is Sign sign2)
                {
                    Assert.That(sign2.Position, Is.EqualTo(sign.Position));
                    Assert.That(sign2.Text, Is.EqualTo(sign.Text));
                }
                else if (entity is TrainingDummy trainingDummy2)
                {
                    Assert.That(trainingDummy2.Position, Is.EqualTo(trainingDummy.Position));
                    Assert.That(trainingDummy2.NpcIndex, Is.EqualTo(trainingDummy.NpcIndex));
                }
            }
        }
Beispiel #10
0
 public void CopyIcons(ItemFrame from)
 {
     primaryImage.sprite   = from.primaryImage.sprite;
     secondaryImage.sprite = from.secondaryImage.sprite;
 }
Beispiel #11
0
        public void GetPosition(int x, int y)
        {
            var itemFrame = new ItemFrame(new Vector(x, y), new Item());

            Assert.That(itemFrame.Position, Is.EqualTo(new Vector(x, y)));
        }