Exemplo n.º 1
0
        public static void Load()
        {
            items.Clear();
            DataTable dt = DB.RunReader("SELECT * FROM gunsmith");

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataRow row    = dt.Rows[i];
                int     gameid = int.Parse(row["gameid"].ToString());
                int     cost   = 0;

                string item = row["item"].ToString();
                string rare = row["rare"].ToString();

                string[] required_materials = row["required_materials"].ToString().Split(',');

                int.TryParse(row["cost"].ToString(), out cost);

                string[] required_items = row["required_items"].ToString().Split(',');
                string[] lose_items     = row["lose_items"].ToString().Split(',');

                GunSmith gunsmith = new GunSmith(gameid, cost, item, rare, required_materials, required_items, lose_items);
                if (!items.ContainsKey(gameid))
                {
                    items.Add(gameid, gunsmith);
                }
                else
                {
                    Log.WriteError("Couldn't add GunSmith ID " + gameid + " [DUPLICATE]");
                }
            }
            Log.WriteLine("Successfully loaded [" + items.Count + "] GunSmith Items");
        }
Exemplo n.º 2
0
    public void buyItem(string s)
    {
        TileUnit tu = null;

        switch (s)
        {
        case "sawmill":
            if (gs.tryBuy(BALANCE_CONSTANTS.SAWMILL_COST))
            {
                tu = new Storage(Resource.Type.WOOD);
            }
            break;

        case "foundry":
            if (gs.tryBuy(BALANCE_CONSTANTS.FOUNDRY_COST))
            {
                tu = new Storage(Resource.Type.ORE);
            }
            break;

        case "refinery":
            if (gs.tryBuy(BALANCE_CONSTANTS.REFINERY_COST))
            {
                tu = new Storage(Resource.Type.OIL);
            }
            break;

        case "guardtower":
            if (gs.tryBuy(BALANCE_CONSTANTS.TOWER_COST))
            {
                tu = new GuardTower();
            }
            break;

        case "gunsmith":
            if (gs.tryBuy(BALANCE_CONSTANTS.GUNSMITH_COST))
            {
                tu = new GunSmith();
            }
            break;
        }
        if (tu == null)
        {
            return;
        }
        tu.gr = gr;
        var v = gs.placeItemNear(tu, new IntVec2((int)gs.player.location.x, (int)gs.player.location.y));

        if (tu is GuardTower)
        {
            gr.addGuardLight(v);
        }

        if (tu != null)
        {
            activate();
        }
    }
Exemplo n.º 3
0
        public void NameTest()
        {
            AutoCompleteStringCollection value = GunSmith.Name(_databasePath, out _errOut);

            foreach (var a in value)
            {
                TestContext.WriteLine(a.ToString());
            }
            General.HasTrueValue(value.Count > 0, _errOut);
        }