예제 #1
0
 public static void dequip()
 {
     Equipment.ticking      = false;
     Equipment.startedEquip = Single.MinValue;
     if (Equipment.useable != null)
     {
         Equipment.useable.dequip();
         string[] animations = ItemAnimations.getAnimations(Equipment.id);
         for (int i = 0; i < (int)animations.Length; i++)
         {
             Viewmodel.model.animation.RemoveClip(animations[i]);
         }
         UnityEngine.Object.Destroy(Equipment.useable);
     }
     if (Equipment.model != null)
     {
         UnityEngine.Object.Destroy(Equipment.model);
     }
     Equipment.equipped = Point2.NONE;
     Equipment.id       = -1;
     Equipment.busy     = false;
     Equipment.setup    = true;
     Player.clothes.changeItem(-1, string.Empty);
     if (!Network.isServer)
     {
         Player.model.networkView.RPC("equipServer", RPCMode.Server, new object[] { -1, -1, Equipment.id });
     }
 }
            public virtual void ReadChildData(BinaryReader reader)
            {
                int x = 0;

                _arrowsBitmap.ReadString(reader);
                for (x = 0; (x < _itemAnimations.Count); x = (x + 1))
                {
                    ItemAnimations.Add(new SingleAnimationReferenceBlockBlock());
                    ItemAnimations[x].Read(reader);
                }
                for (x = 0; (x < _itemAnimations.Count); x = (x + 1))
                {
                    ItemAnimations[x].ReadChildData(reader);
                }
                for (x = 0; (x < _textBlocks.Count); x = (x + 1))
                {
                    TextBlocks.Add(new TextBlockReferenceBlockBlock());
                    TextBlocks[x].Read(reader);
                }
                for (x = 0; (x < _textBlocks.Count); x = (x + 1))
                {
                    TextBlocks[x].ReadChildData(reader);
                }
                for (x = 0; (x < _bitmapBlocks.Count); x = (x + 1))
                {
                    BitmapBlocks.Add(new BitmapBlockReferenceBlockBlock());
                    BitmapBlocks[x].Read(reader);
                }
                for (x = 0; (x < _bitmapBlocks.Count); x = (x + 1))
                {
                    BitmapBlocks[x].ReadChildData(reader);
                }
                for (x = 0; (x < _hudBlocks.Count); x = (x + 1))
                {
                    HudBlocks.Add(new HudBlockReferenceBlockBlock());
                    HudBlocks[x].Read(reader);
                }
                for (x = 0; (x < _hudBlocks.Count); x = (x + 1))
                {
                    HudBlocks[x].ReadChildData(reader);
                }
                for (x = 0; (x < _playerBlocks.Count); x = (x + 1))
                {
                    PlayerBlocks.Add(new PlayerBlockReferenceBlockBlock());
                    PlayerBlocks[x].Read(reader);
                }
                for (x = 0; (x < _playerBlocks.Count); x = (x + 1))
                {
                    PlayerBlocks[x].ReadChildData(reader);
                }
            }
예제 #3
0
 public static void equip(int x, int y)
 {
     if (!Player.life.dead && !Equipment.busy && Equipment.setup && (double)(Time.realtimeSinceStartup - Equipment.lastEquip) > 0.2 && !Movement.isSwimming && !Movement.isClimbing && !Movement.isDriving)
     {
         Equipment.lastEquip = Time.realtimeSinceStartup;
         if ((Equipment.equipped.x != x || Equipment.equipped.y != y) && x >= 0 && x < Player.inventory.width && y >= 0 && y < Player.inventory.height && Player.inventory.items[x, y].id != -1 && ItemEquipable.getEquipable(Player.inventory.items[x, y].id))
         {
             Equipment.dequip();
             Equipment.equipped = new Point2(x, y);
             Equipment.id       = Player.inventory.items[x, y].id;
             Player.clothes.changeItem(Equipment.id, Player.inventory.items[x, y].state);
             Equipment.model      = (GameObject)UnityEngine.Object.Instantiate(Resources.Load(string.Concat("Prefabs/Viewmodels/", Equipment.id)));
             Equipment.model.name = Equipment.id.ToString();
             if (Equipment.id == 7004 || Equipment.id == 7014)
             {
                 Equipment.model.transform.parent = Viewmodel.model.transform.FindChild("skeleton").FindChild("leftRoot").FindChild("leftShoulder").FindChild("leftUpper").FindChild("leftLower").FindChild("leftHand");
             }
             else
             {
                 Equipment.model.transform.parent = Viewmodel.model.transform.FindChild("skeleton").FindChild("rightRoot").FindChild("rightShoulder").FindChild("rightUpper").FindChild("rightLower").FindChild("rightHand");
             }
             Equipment.model.transform.localPosition = Vector3.zero;
             Equipment.model.transform.localRotation = Quaternion.identity;
             Equipment.model.transform.localScale    = new Vector3(1f, 1f, 1f);
             Equipment.useable = (Useable)Player.model.AddComponent(Equipment.model.GetComponent <Useable>().GetType());
             UnityEngine.Object.Destroy(Equipment.model.GetComponent <Useable>());
             GameObject gameObject = (GameObject)Resources.Load(string.Concat("Models/Animations/FirstPerson/Items/", ItemAnimations.getSource(Equipment.id), "/model"));
             string[]   animations = ItemAnimations.getAnimations(Equipment.id);
             for (int i = 0; i < (int)animations.Length; i++)
             {
                 Viewmodel.model.animation.AddClip(gameObject.animation.GetClip(animations[i]), animations[i]);
             }
             Equipment.startedEquip = Time.realtimeSinceStartup;
             Equipment.setup        = false;
             Equipment.ready        = false;
             Equipment.model.transform.FindChild("model").renderer.enabled = false;
             if (!Network.isServer)
             {
                 Player.model.networkView.RPC("equipServer", RPCMode.Server, new object[] { x, y, Equipment.id });
             }
         }
         else
         {
             Equipment.dequip();
         }
     }
 }