コード例 #1
0
ファイル: ItemData.cs プロジェクト: souxiaosou/OmniEngine.Net
 public static Item createItem(ItemData datablock)
 {
     ObjectCreator tch = new ObjectCreator("Item");
     tch["dataBlock"] = datablock;
     tch["static"] = true;
     tch["rotate"] = true;
     return tch.Create();
 }
コード例 #2
0
 public virtual bool Throw(ItemData data, int amount = 1)
 {
     bool functionresult = false;
     if (getInventory(data) > 0)
         {
         Item objectid = data.onThrow(this, amount);
             {
             if (objectid != 0)
                 {
                 throwObject(objectid);
                 Audio.AudioServerPlay3D("ThrowSnd", this.getTransform());
                 functionresult = true;
                 }
             }
         }
     return functionresult;
 }
コード例 #3
0
        public virtual bool Use(ItemData data)
        {
            GameConnection client = getControllingClient();
            if (client.isObject())
                {
                double defaultfov = client.getControlCameraDefaultFov();
                double fov = client.getControlCameraFov();
                if (defaultfov != fov)
                    return false;
                }
            if (getInventory(data) > 0)

                return data.onUse(_ID);

            return false;
        }
コード例 #4
0
        public virtual int setInventory(ItemData data, int value = 0)
        {
            int max = 0;

            max = maxInventory(data);
            if (value > max)
                value = max;

            int amount = this["inv[" + data.getName() + "]"].AsInt();

            if (amount != value)
                {
                this["inv[" + data.getName() + "]"] = value.AsString();
                //console.warn("Setting " + data.getName() + " to " + value);

                data.onInventory(this, value);
                }
            return value;
        }
コード例 #5
0
        public virtual int decInventory(ItemData data, int amount = 0)
        {
            int total = this["inv[" + data.getName() + "]"].AsInt();

            if (total > 0)
                {
                if (total < amount)
                    amount = total;

                setInventory(data, (total - amount));
                return amount;
                }
            return 0;
        }
コード例 #6
0
        public virtual int incInventory(ItemData datablock, int amount)
        {
            int maxamount = maxInventory(datablock);

            int total = this["inv[" + datablock.getName() + "]"].AsInt();

            if (total < maxamount)
                {
                if (total + amount > maxamount)
                    amount = (maxamount - total);
                setInventory(datablock, (total + amount));
                return amount;
                }
            return 0;
        }
コード例 #7
0
 public static void serverCmdUse(GameConnection client, ItemData data)
 {
     if (((Player) client.getControlObject()).isObject())
         ((Player) client.getControlObject()).Use(data);
 }
コード例 #8
0
ファイル: Player.cs プロジェクト: souxiaosou/OmniEngine.Net
 public override bool Use(ItemData data)
 {
     if (isPilot())
         return false;
     //Instead of going through the parent stuff, we can now just call the parent function via base.
     return base.Use(data);
 }