Esempio n. 1
0
        /// <summary>
        /// アイテムが選択された時の処理
        /// </summary>
        /// <param name="item">選択されたアイテム</param>
        /// <param name="node">選択されたノード</param>
        public void itemChose(IItem item, TradeItemNode node)
        {
            int itemValue = TradeHelper.getSellValue(item, player, (Merchant)trader);

            inventory.removeItem(item);
            player.addMetal(itemValue);
            updateItem();
        }
Esempio n. 2
0
 /// <summary>
 /// 表示させるアイテムを更新します
 /// </summary>
 public void updateItem()
 {
     detachContents();
     foreach (IItem item in inventory.getItems())
     {
         GameObject    nodeObject = Instantiate(tradeItemNodePrefab);
         TradeItemNode node       = nodeObject.GetComponent <TradeItemNode>();
         node.setGoods(item, TradeHelper.getSellValue(item, player, (Merchant)trader), this);
         nodeObject.transform.SetParent(content.transform);
     }
 }
Esempio n. 3
0
        /// <summary>
        /// 購入するアイテムが決定した時の処理
        /// </summary>
        /// <param name="item">購入するアイテム</param>
        public void itemChose(IItem item, TradeItemNode node)
        {
            int itemValue = TradeHelper.getBuyValue(item, player, (Merchant)trader);

            if (itemValue > player.getMetal())
            {
                window.tradeFailed();
                return;
            }
            player.addItem(item);
            player.minusMetal(itemValue);
            trader.traded(itemValue, item);

            sellWindow.updateItem();
        }
Esempio n. 4
0
        /// <summary>
        /// 初期設定を行います
        /// </summary>
        /// <param name="player">取引に参加するPC</param>
        /// <param name="trader">取引に参加するフレンドリキャラクター</param>
        public void setState(Player player, IFriendly trader)
        {
            this.player    = player;
            this.trader    = trader;
            this.inventory = player.getInventory();

            headerText.text = player.getName();

            tradeItemNodePrefab = (GameObject)Resources.Load("Prefabs/TradeItemNode");

            foreach (IItem item in inventory.getItems())
            {
                GameObject    nodeObject = Instantiate(tradeItemNodePrefab);
                TradeItemNode node       = nodeObject.GetComponent <TradeItemNode>();
                node.setGoods(item, TradeHelper.getSellValue(item, player, (Merchant)trader), this);
                nodeObject.transform.SetParent(content.transform);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 初期設定を行います
        /// </summary>
        /// <param name="goods">商品のリスト</param>
        /// <param name="player">取引に参加するプレイヤー</param>
        /// <param name="trader">取引に参加するIFriendlyキャラクター</param>
        /// <param name="window">親となるメッセージウィンドウ</param>
        public void setState(List <IItem> goods, Player player, IFriendly trader, MassageWindow window)
        {
            tradeItemNodePrefab = (GameObject)Resources.Load("Prefabs/TradeItemNode");
            this.goods          = goods;
            foreach (IItem item in goods)
            {
                TradeItemNode node = Instantiate(tradeItemNodePrefab).GetComponent <TradeItemNode>();
                node.setGoods(item, TradeHelper.getBuyValue(item, player, (Merchant)trader), this);
                node.transform.SetParent(content.transform);
            }
            this.player = player;
            this.trader = (Merchant)trader;
            this.window = window;

            headerText.text = trader.getName();

            sellWindow = transform.root.GetComponent <TradeView>().getSellWindow();
            sellWindow.setState(player, trader);
            sellWindow.transform.SetParent(transform.root);
        }