Exemple #1
0
    public void Combo()
    {
        GameObject  comboPlanet   = homePlanets[currentViewingPlanet].gameObject;
        HomePlanet  comboHomeInfo = comboPlanet.GetComponent <HomePlanet>();
        PlanetCombo combo;

        if (comboList.Combo(comboHomeInfo.items[0], comboHomeInfo.items[1], comboHomeInfo.items[2]) != null)
        {
            combo = comboList.Combo(comboHomeInfo.items[0], comboHomeInfo.items[1], comboHomeInfo.items[2]);
            comboPlanet.gameObject.name = combo.planet.name;
            comboPlanet.GetComponent <SpriteRenderer>().sprite                = combo.planet.GetComponent <SpriteRenderer>().sprite;
            comboPlanet.GetComponent <HomePlanet>().productionItems           = combo.productionItems;
            comboPlanet.GetComponent <HomePlanet>().homePlanetInfo.comboIndex = combo.index;


            resourceInventory.checkForItemAndRemove(getCurrentViewingPlanet().GetComponent <HomePlanet>().items[0].resource.GetComponent <rsrce>().nameOfResource, 1);
            resourceInventory.checkForItemAndRemove(getCurrentViewingPlanet().GetComponent <HomePlanet>().items[1].resource.GetComponent <rsrce>().nameOfResource, 1);
            resourceInventory.checkForItemAndRemove(getCurrentViewingPlanet().GetComponent <HomePlanet>().items[2].resource.GetComponent <rsrce>().nameOfResource, 1);

            getCurrentViewingPlanet().GetComponent <HomePlanet>().removeItem(0);
            getCurrentViewingPlanet().GetComponent <HomePlanet>().removeItem(1);
            getCurrentViewingPlanet().GetComponent <HomePlanet>().removeItem(2);
            getCurrentViewingPlanet().GetComponent <HomePlanet>().UpdateUI();
        }
    }
Exemple #2
0
    public void clearInventory()
    {
        // loop through, check for item, add quantity if found
        for (int itemSlot = 0; itemSlot < numberOfItemSlots; itemSlot++)
        {
            if (items[itemSlot] != null)
            {
                if (items[itemSlot].resource != null)
                {
                    resourceInventory.checkForItemAndRemove(items[itemSlot].resource.GetComponent <rsrce>().nameOfResource, items[itemSlot].quantity);
                    int count = 0;
                    while (count != items[itemSlot].quantity)
                    {
                        GameObject resource = Instantiate(items[itemSlot].resource);
                        resource.tag = "resource";
                        resource.transform.position = new Vector2(gameObject.transform.position.x, gameObject.transform.position.y);
                        Vector2 velocityDirection = new Vector2(Random.Range(-2, 2), Random.Range(-2, 2));

                        while ((velocityDirection.x < .5f && velocityDirection.x > -.5f) && (velocityDirection.y < .5f && velocityDirection.y > -.5f))
                        {
                            velocityDirection = new Vector2(Random.Range(-2, 2), Random.Range(-2, 2));
                        }

                        resource.GetComponent <Rigidbody2D>().velocity        = velocityDirection;
                        resource.GetComponent <Rigidbody2D>().angularVelocity = 720;
                        count++;
                    }
                    removeItem(itemSlot, items[itemSlot].quantity);
                }
            }
        }
    }