Exemple #1
0
    public static ShipEntity loadShip(string uniqueId)
    {
        //GameObject.Find("GameLogic").GetComponent<GameEventHandler>().printThing(uniqueId);
        ShipEntity entity = stringtoShip(
            PlayerPrefs.GetString("TSSE[ShipEntity][" + uniqueId + "]"));

        entity.uniqueId = uniqueId;
        if (entity.shipType == ShipType.None)
        {
            return(entity);
        }
        entity.items = ItemDefinitions.stringToItems(
            PlayerPrefs.GetString("TSSEList[Item][" + entity.uniqueId + "]"));
        GameObject.Find("GameLogic").GetComponent <GameEventHandler>().printThing(
            ItemDefinitions.itemsToString(entity.items));

        return(entity);
    }
Exemple #2
0
    void Start()
    {
        if (inventoryType == "Player")
        {
            currency = PlayerPrefs.GetInt("score");
        }
        else
        {
            currency = PlayerPrefs.GetInt("score-" + inventoryType);
        }
        //PlayerPrefs.DeleteAll();
        List <ItemAbstract> items = ItemDefinitions.stringToItems(
            ItemDefinitions.loadItems(uniqueId));

        /*
         * if(inventoryType == "Merchant")
         * {
         *  items = new List<ItemAbstract>();
         *  items.Add(new EngineItem(EngineItem.EngineType.Spinjet, 4));
         *
         *  items.Add(new WeaponItem(WeaponItem.WeaponType.CrownModAmmoCap, 4));
         *  items.Add(new WeaponItem(WeaponItem.WeaponType.CrownModRange, 4));
         *  items.Add(new WeaponItem(WeaponItem.WeaponType.FlameModRechargeRate, 4));
         *  items.Add(new WeaponItem(WeaponItem.WeaponType.MissileModAmmoCap, 4));
         *  items.Add(new WeaponItem(WeaponItem.WeaponType.MissileModAmmoCap, 5));
         * }
         * else if(inventoryType == "Player")
         * {
         *  items = new List<ItemAbstract>();
         *  items.Add(new WeaponItem(WeaponItem.WeaponType.CrownModAmmoCap, 1));
         *  items.Add(new WeaponItem(WeaponItem.WeaponType.CrownModAmmoCap, 2));
         *  items.Add(new WeaponItem(WeaponItem.WeaponType.CrownModAmmoCap, 4));
         *  items.Add(new WeaponItem(WeaponItem.WeaponType.CrownModRange, 2));
         *  items.Add(new WeaponItem(WeaponItem.WeaponType.CrownModRechargeRate, 3));
         *  items.Add(new WeaponItem(WeaponItem.WeaponType.FlameModAmmoCap, 2));
         *  items.Add(new WeaponItem(WeaponItem.WeaponType.FlameModAmmoCap, 2));
         *  items.Add(new WeaponItem(WeaponItem.WeaponType.FlameModRechargeRate, 3));
         *  items.Add(new WeaponItem(WeaponItem.WeaponType.FlameModRechargeRate, 1));
         * }
         * /*
         * List<ItemAbstract> items = new List<ItemAbstract>();
         * // hardcoding temporary item list
         * items.Add(new WeaponItem(WeaponItem.WeaponType.CrownModAmmoCap, 1));
         * items.Add(new WeaponItem(WeaponItem.WeaponType.CrownModAmmoCap, 2));
         * items.Add(new WeaponItem(WeaponItem.WeaponType.CrownModRange, 2));
         * items.Add(new WeaponItem(WeaponItem.WeaponType.CrownModRechargeRate, 3));
         * items.Add(new WeaponItem(WeaponItem.WeaponType.FlameModAmmoCap, 2));
         * items.Add(new WeaponItem(WeaponItem.WeaponType.FlameModAmmoCap, 2));
         * items.Add(new WeaponItem(WeaponItem.WeaponType.FlameModRechargeRate, 3));
         * items.Add(new WeaponItem(WeaponItem.WeaponType.FlameModRechargeRate, 1));
         */
        clearInventory();
        foreach (ItemAbstract item in items)
        {
            if (item.getType() != "Error")
            {
                print("adding " + item);
                //addItem(item);
                inventory[ItemDefinitions.itemToString(item)]++;
                if (item.getTier() > 3)
                {
                    if (blueprintDisplay != null)
                    {
                        blueprintDisplay.GetComponent <ItemListHandler>().
                        addItem(item);
                    }
                }
            }
        }
        saveInventory();
        //ItemDefinitions.saveItems("Player", ItemDefinitions.itemsToString(items));
        if (shipDisplay != null)
        {
            for (int i = 0; i < 6; i++)
            {
                string id = "PlayerShip" + i.ToString();
                shipDisplay.GetComponent <ShipListHandler>().addShip(ShipDefinitions.loadShip(id));
            }
        }
        reloadItems();
        updateCurrency();
    }
Exemple #3
0
    public void loadInventory()
    {
        clearInventory();
        List <ItemAbstract> items = ItemDefinitions.stringToItems(
            ItemDefinitions.loadItems(uniqueId));

        foreach (ItemAbstract item in items)
        {
            addItem(item);
            inventory[ItemDefinitions.itemToString(item)]++;
        }

        /*
         * string invSlotLabel = uniqueId + "InventorySlotLabel[Weapon]";
         * for (int i = 0; i < WeaponItem.numWeaponTypes; i++)
         * {
         *  string currLabel = invSlotLabel + i.ToString();
         *  numOfEachWeapItem[i] = 0;
         *  if (UnityEngine.PlayerPrefs.HasKey(currLabel))
         *  {
         *      numOfEachWeapItem[i] = UnityEngine.PlayerPrefs.GetInt(currLabel);
         *  }
         *  else
         *  {
         *      continue;
         *  }
         * }
         *
         * for (int i = 0; i < WeaponItem.numWeaponTypes; i++)
         * {
         *  for (int j = 0; j < numOfEachWeapItem[i]; j++)
         *  {
         *      print("adding weapon item: " + i + " and num = " + numOfEachWeapItem[i]);
         *      inventoryDisplay.GetComponent<ItemListHandler>().addItem(ItemDefinitions.intToItem(i));
         *  }
         * }
         *
         * invSlotLabel = uniqueId + "InventorySlotLabel[Engine]";
         * for (int i = 0; i < EngineItem.numEngineTypes; i++)
         * {
         *  string currLabel = invSlotLabel + i.ToString();
         *  numOfEachEngItem[i] = 0;
         *  if (UnityEngine.PlayerPrefs.HasKey(currLabel))
         *  {
         *      numOfEachEngItem[i] = UnityEngine.PlayerPrefs.GetInt(currLabel);
         *  }
         *  else
         *  {
         *      continue;
         *  }
         * }
         *
         * for (int i = 0; i < EngineItem.numEngineTypes; i++)
         * {
         *  if (i == 0)
         *      print("adding engine item: " + i + " and num = " + numOfEachEngItem[i]);
         *  for (int j = 0; j < numOfEachEngItem[i]; j++)
         *  {
         *      inventoryDisplay.GetComponent<ItemListHandler>().addItem(ItemDefinitions.intToItem(i));
         *  }
         * }
         */
    }