Exemple #1
0
    // Called by the engine when all objects are created
    void Start()
    {
        _player = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerMain>();
        _inventory = GetComponent<ItemInventory>();

        // set item prices
        _prices.Add(101, 5);
        _prices.Add(102, 15);
        _prices.Add(201, 5);
        _prices.Add(202, 15);
        _prices.Add(301, 5);
        _prices.Add(302, 15);
        _prices.Add(401, 5);
        _prices.Add(402, 15);
        _prices.Add(501, 5);
        _prices.Add(502, 15);

        // load or create inventory
        var try_loading = _inventory.loadFromDisk("merchant");
        if (!try_loading) { // no data on disk, create it
            //This was stuff put in for testing
            //_inventory.addItem(1,10);
            _inventory.addItem(101);
            _inventory.addItem(102);
            _inventory.addItem(201);
            _inventory.addItem(202);
            _inventory.addItem(301);
            _inventory.addItem(302);
            _inventory.addItem(401);
            _inventory.addItem(402);
            _inventory.addItem(501);
            _inventory.addItem(502);
            //_player.addItem(0,100);

            //foreach (int i in _inventory.getItemList().Keys){
            //	_prices.Add(i, 1);
            //}
        }
    }