Ejemplo n.º 1
0
 // using item
 public IGoods.IGoods useItem(String itemName)
 {
     IGoods.IGoods target = findItem(itemName);
     if (target == null)
     {
         Console.WriteLine(itemName + " does not exist in inventory!");
     }
     else
     {
         if (target.Destroyable && target.Useable)
         {
             currentWeight -= target.Weight;
             currentVolumn -= target.Volumn;
             if (target.Count > 1)
             {
                 findItem(itemName).Count -= 1;
                 Console.WriteLine("One of the " + target.ItemName + " item is used!");
             }
             else
             {
                 Console.WriteLine("You used " + target.ItemName + " !");
                 inventory.Remove(findItem(itemName));
             }
         }
         else
         {
             Console.WriteLine("You can't use this item!");
         }
     }
     return(target);
 }
Ejemplo n.º 2
0
        public String eqiupWeapon(String itemName)
        {
            String temp = "";

            IGoods.IGoods targetItem = playerInventory.equipItem(itemName);
            if (targetItem != null)
            {
                try
                {
                    if (weapon == null)
                    {
                        weapon = (IGoods.NewEquipments)targetItem;
                    }
                    else
                    {
                        playerInventory.addItem(weapon);
                        weapon = (IGoods.NewEquipments)targetItem;
                    }
                }
                catch (InvalidCastException e)
                {
                    temp = "You can not equip this item!";
                }
            }
            return(temp);
        }
Ejemplo n.º 3
0
 // destroying item
 public void destoryItem(String itemName)
 {
     IGoods.IGoods target = findItem(itemName);
     if (target == null)
     {
         //place holder for now
         Console.WriteLine("There is no such item in this room!");
     }
     else
     {
         if (target.Destroyable)
         {
             if (target.Count > 1)
             {
                 findItem(itemName).Count -= 1;
                 Console.WriteLine("One of the following item is destroyed!");
             }
             else
             {
                 Console.WriteLine("One of the item is destoryed!");
                 itemInRoom.Remove(findItem(itemName));
             }
         }
         else
         {
             Console.WriteLine("You can't destroy this item!");
         }
     }
 }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            //本服务开放端口
            int silePort = 11112;
            //主简仓网关端口
            int gatewayPort = 30000;
            //主简仓开放端口
            int mainSiloPort = 11111;
            var host         = StartHost(silePort, gatewayPort, mainSiloPort);


            var client = StartClient(gatewayPort);


            //由于向网关添加一个服务处理需要多一些时间
            //所以可能会抛出获取不到的异常
            //详情请看5、常见问题


            while (true)
            {
                string ReadLine = Console.ReadLine();
                if (ReadLine == "Exit")
                {
                    host.Result.StopAsync().Wait();
                    client.Result.Close();
                    break;
                }
                else if (ReadLine == "Goods")
                {
                    try
                    {
                        IGoods.IGoods goods = client.Result.GetGrain <IGoods.IGoods>(0);
                        Console.WriteLine(goods.GetGoodsDescribe().Result);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("服务暂时还没有启动完成 请稍后再试" + e.Message);
                    }
                }
                else if (ReadLine == "ShoppingRecord")
                {
                    try
                    {
                        IShoppingRecord.IShoppingRecord shoppingRecord = client.Result.GetGrain <IShoppingRecord.IShoppingRecord>(0);
                        Console.WriteLine(shoppingRecord.GetShoppingRecordDescribe().Result);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("服务暂时还没有启动完成 请稍后再试" + e.Message);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        //using an item
        public String usingItem(String itemName)
        {
            String temp = "";

            IGoods.IGoods targetItem = playerInventory.useItem(itemName);
            if (targetItem != null)
            {
                IGoods.NewNonEquipments useItem = (IGoods.NewNonEquipments)targetItem;
                player.heal(useItem.HPRecovery);
            }
            return(temp);
        }
Ejemplo n.º 6
0
 // helper method
 public IGoods.IGoods findItem(String targetItem)
 {
     IGoods.IGoods search = null;
     for (int index = 0; index < itemInRoom.Count; index++)
     {
         if (itemInRoom[index].ItemName == targetItem)
         {
             search = itemInRoom[index];
         }
     }
     return(search);
 }
Ejemplo n.º 7
0
 // adding item
 public void addItem(IGoods.IGoods newItem)
 {
     if (currentWeight + newItem.Weight <= maxWeight && currentVolumn + newItem.Volumn <= maxVolumn)
     {
         inventory.Add(newItem);
         currentWeight += newItem.Weight;
         currentVolumn += newItem.Volumn;
     }
     else if (currentWeight + newItem.Weight > maxWeight)
     {
         Console.WriteLine("Your bag got too heavy so you decided to not put the item into your bag.");
     }
     else if (currentVolumn + newItem.Volumn > maxVolumn)
     {
         Console.WriteLine("There is no space in your bag so you decided to not put the item into your bag.");
     }
 }
Ejemplo n.º 8
0
 // Discarding item in inventory
 public void discardItem(String itemName)
 {
     IGoods.IGoods target = findItem(itemName);
     if (target == null)
     {
         Console.WriteLine(itemName + " does not exist in inventory!");
     }
     else
     {
         currentWeight -= target.Weight;
         currentVolumn -= target.Volumn;
         if (target.Count > 1)
         {
             findItem(itemName).Count -= 1;
         }
         else
         {
             inventory.Remove(target);
         }
     }
 }
Ejemplo n.º 9
0
 //picking up
 public IGoods.IGoods getItem(String itemName)
 {
     IGoods.IGoods target = findItem(itemName);
     if (target == null)
     {
         Console.WriteLine("Item does not exist in this room!");
     }
     else
     {
         if (target.Count > 1)
         {
             findItem(itemName).Count -= 1;
             Console.WriteLine("One of the " + target.ItemName + " item is placed in inventory!");
         }
         else
         {
             Console.WriteLine("You placed " + target.ItemName + " into your inventory!");
             itemInRoom.Remove(findItem(itemName));
         }
     }
     return(target);
 }
Ejemplo n.º 10
0
 public GoodController()
 {
     this.goods = this.GetServer <IGoods.IGoods>();
 }
Ejemplo n.º 11
0
        /*
         * //view skill list
         * public String knownAbility()
         * {
         *  String list = "";
         *  if (abilityList.Count != 0)
         *  {
         *      for(int index = 0; index < abilityList.Count; index++)
         *      {
         *          if (Level >= abilityList[index].LevelRequirement)
         *          {
         *              list += abilityList[index].AbilityName + "\n";
         *          }
         *      }
         *  }
         *  else
         *  {
         *      list = "There is no known abilities!";
         *  }
         *  return list;
         * }
         *
         * //helper function
         * private PlayerAbility findAbility(String target)
         * {
         *  PlayerAbility find = null;
         *  for (int index = 0; index < abilityList.Count; index++)
         *  {
         *      if (abilityList[index].AbilityName == target)
         *      {
         *          find = abilityList[index];
         *      }
         *  }
         *  return find;
         * }
         *
         * //checking if ability is available
         * public bool existingAbility(String abilityName)
         * {
         *  bool checking = false;
         *  if(findAbility(abilityName) != null)
         *  {
         *      checking = true;
         *  }
         *  else
         *  {
         *      checking = false;
         *  }
         *  return checking;
         * }
         *
         * // checking if ability is usable
         * private int usableAbility(String abilityName)
         * {
         *  int effect = 0;
         *  PlayerAbility targetAbility = findAbility(abilityName);
         *  if (targetAbility != null)
         *  {
         *      if (Level >= targetAbility.LevelRequirement)
         *      {
         *          if(CurrentMP - targetAbility.MPCost >= 0)
         *          {
         *              if(targetAbility.Type == AbilityType.HEAL)
         *              {
         *                  effect = targetAbility.AbilityMod;
         *              }
         *              else if(targetAbility.Type == AbilityType.DAMAGE)
         *              {
         *                  if(InCombat)
         *                  {
         *                      effect = targetAbility.AbilityMod;
         *                  }
         *                  else
         *                  {
         *                      Console.WriteLine("You cant not use this ability at this time.");
         *                      effect = 0;
         *                  }
         *              }
         *          }
         *          else
         *          {
         *              Console.WriteLine("You do not have the mana to use this ability!");
         *              effect = 0;
         *          }
         *      }
         *      else
         *      {
         *          effect = 0;
         *          Console.WriteLine("You are not high enough level to use this ability");
         *      }
         *  }
         *  else
         *  {
         *      effect = 0;
         *      Console.WriteLine("The following abillity does not exist!");
         *  }
         *  return effect;
         * }*/

        public void addToInventory(IGoods.IGoods newItem)
        {
            playerInventory.addItem(newItem);
        }
Ejemplo n.º 12
0
        //This for tradeing items

        /*
         * public string TradeRoom()
         * {
         *  string itemsNames = "Item: ";
         *  Dictionary<string, Items>.KeyCollection keys = items.Keys;
         *  foreach (object items in keys)
         *  {
         *      itemsNames += ", " + itemsNames;
         *  }
         *
         *  return itemsNames;
         * }*/

        // adding item to room
        public void addItem(IGoods.IGoods item)
        {
            itemInRoom.Add(item);
        }
Ejemplo n.º 13
0
        static void Main(string[] args)
        {
            //本服务开放端口
            int silePort = 11113;
            //主简仓网关端口
            int gatewayPort = 30000;
            //主简仓开放端口
            int mainSiloPort = 11111;

            ///定时器对象
            IGrainReminder grainReminder = null;
            //由于向网关添加一个服务处理需要多一些时间
            //所以在程序运行后马上获取服务可能会抛出获取不到的异常
            //详情请看5、常见问题
            var host   = StartHost(silePort, gatewayPort, mainSiloPort);
            var client = StartClient(gatewayPort);

            while (true)
            {
                string ReadLine = Console.ReadLine();
                if (ReadLine == "Exit")
                {
                    host.Result.StopAsync().Wait();
                    client.Result.Close();
                    break;
                }
                else if (ReadLine == "Goods")
                {
                    try
                    {
                        IGoods.IGoods goods = client.Result.GetGrain <IGoods.IGoods>(0);
                        Console.WriteLine(goods.GetGoodsDescribe().Result);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("服务暂时还没有启动完成 请稍后再试" + e.Message);
                    }
                }
                else if (ReadLine == "GoodsList")
                {
                    try
                    {
                        IGoods.IGoods             goods     = client.Result.GetGrain <IGoods.IGoods>(0);
                        List <Entity.GoodsEntity> arrayList = goods.GetGoodsList().Result;
                        Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(arrayList));
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("服务暂时还没有启动完成 请稍后再试" + e.Message);
                    }
                }
                else if (ReadLine == "GoodsStartTimer")
                {
                    try
                    {
                        IGoods.IGoods goods = client.Result.GetGrain <IGoods.IGoods>(0);
                        //grainReminder = goods.StartTimerTest().Result;
                        //goods.StartTimerTestString("Test");
                        goods.StartTimer();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("服务暂时还没有启动完成 请稍后再试" + e.Message);
                    }
                }
                else if (ReadLine == "GoodsStopTimer")
                {
                    try
                    {
                        IGoods.IGoods goods = client.Result.GetGrain <IGoods.IGoods>(0);
                        //goods.StopTimerTest(grainReminder).Wait();
                        goods.StopTimerTest("Test");
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("服务暂时还没有启动完成 请稍后再试" + e.Message);
                    }
                }
                else if (ReadLine == "ShoppingRecord")
                {
                    try
                    {
                        IShoppingRecord.IShoppingRecord shoppingRecord = client.Result.GetGrain <IShoppingRecord.IShoppingRecord>(0);
                        Console.WriteLine(shoppingRecord.GetShoppingRecordDescribe().Result);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("服务暂时还没有启动完成 请稍后再试" + e.Message);
                    }
                }
            }
        }
Ejemplo n.º 14
0
 public OrderController()
 {
     this.shoppingRecord = this.GetServer <IShoppingRecord.IShoppingRecord>();
     this.goods          = this.GetServer <IGoods.IGoods>();
 }