示例#1
0
    public void Close()
    {
        if (_state == CraftingMenuState.CraftingMenu_Closed)
        {
            return;
        }

        _state       = CraftingMenuState.CraftingMenu_Closing;
        _timeInState = 0.0f;
        //Play a sound effect
        _sound.Play(_sound.MenuDown, 1.0f);

        // destroy all cloned item quads placed into crafting slots
        _lastClickedQuad = null;
        _craftResult     = null;

        for (int i = 0; i <= _craftingSlots.Length - 1; i++)
        {
            if (_craftingSlots [i] != null)
            {
                Destroy(_craftingSlots [i]);
                _craftingSlots [i] = null;
            }
        }
    }
示例#2
0
    public void UpdateCraftResult()
    {
        InventoryItemFactory.ResetIngredients();

        for (int i = 0; i <= _craftingSlots.Length - 1; i++)
        {
            if (_craftingSlots [i] != null)
            {
                InventoryItemFactory.AddIngredient(_craftingSlots [i].GetComponent <ItemQuad>().invItem.Type);
            }
        }

        _craftResult = InventoryItemFactory.GetCraftResult();

        if (_craftResult != null)
        {
            // show proper icon with create button.
            _craftingButton.GetComponent <Renderer>().enabled = true;
        }
        else
        {
            _craftingButton.GetComponent <Renderer>().enabled = false;
            //_sound.Play(_sound.NotACombination,0.5f);
        }
    }
示例#3
0
    public CraftResult Craft(Craftable c, int amount)
    {
        CraftResult result = new CraftResult();

        result.atomsUsed = new List <AtomAmo>();

        var atoms = c.GetAtomsForProduction();

        for (int i = 0; i < atoms.Length; i++)  // Find Minumum
        {
            var atomAmo = atoms[i];

            AtomData data = Game.Instance.gameData.FindAtomData(atomAmo.atom.GetAtomicNumber());

            int needed = atomAmo.amo * amount;
            if (data.GetCurrAmo() < needed)
            {
                amount = data.GetCurrAmo() / atomAmo.amo;
            }
        }

        for (int i = 0; i < atoms.Length; i++)
        {
            var atomAmo = atoms[i];

            AtomData data = Game.Instance.gameData.FindAtomData(atomAmo.atom.GetAtomicNumber());

            int needed = atomAmo.amo * amount;
            data.Lose(needed);

            AtomAmo atomUsed = new AtomAmo();
            atomUsed.atom = atomAmo.atom;
            atomUsed.amo  = needed;
            result.atomsUsed.Add(atomUsed);
        }
        result.amountCreated = amount;

        int amoOfCraftables;

        if (!craftables.TryGetValue(c, out amoOfCraftables))
        {
            craftables[c] = amount;
        }
        else
        {
            craftables[c] = amoOfCraftables + amount;
        }

        if (OnCraftableProduced != null)
        {
            OnCraftableProduced(c, amount);
        }

        return(result);
    }
示例#4
0
    public static CraftResult GetCraftResult()
    {
        string sResult = "";

        foreach (string s in _ingredients.Values)
        {
            sResult += s;
        }

        // gun parts + higgs drive + isolator = gravity gun
        if (sResult == "GPHDIS")
        {
            CraftResult res = new CraftResult();
            res.IsWeapon      = true;
            res.WeaponType    = Weapon.WeaponType.Weapon_GravityGun;
            res.WeaponQty     = 5;
            res.WeaponName    = "Gravity Gun";
            res.WeaponDescr   = "Stun enemies with antigravity blasts.";
            res.WeaponTexture = "GravityGunIcon";
            return(res);

            // anything else builds a mine, except for the parts for the gravity gun.
        }
        else if ((sResult != "") && (!sResult.Contains("GP")) && (!sResult.Contains("HD")) && (!sResult.Contains("IS")))
        {
            CraftResult res = new CraftResult();
            res.IsWeapon      = true;
            res.WeaponType    = Weapon.WeaponType.Weapon_MINE;
            res.WeaponQty     = 3;
            res.WeaponName    = "M.I.N.E.";
            res.WeaponDescr   = "Massive Interconnected Network of Explosives.";
            res.WeaponTexture = "MINEIcon";
            return(res);
        }


        return(null);
    }