void CollectItem(collectable itemToCollect)
    {
        switch (itemToCollect.ItemType)
        {
        case itemType.Potion:
            GainHealth(3);
            break;

        case itemType.Special:
            SpecialAttack();
            break;

        case itemType.Attack:
            GainWeaponLevel();
            break;

        case itemType.Page:
            GainPages(1);
            break;

        case itemType.Coin:
            GainCoins(1);
            break;

        default:
            break;
        }
    }
Exemple #2
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.tag == "collectable")
        {
            collectable col = collision.gameObject.GetComponent <collectable>();

            if (col.MaxEnergy != 0)
            {
                changeMaxEnergy(col.MaxEnergy);
            }
            if (col.Energy != 0)
            {
                changeEnergy(col.Energy);
            }
            if (col.MaxAttractorMass != 0)
            {
                changeMaxAttractorMass(col.MaxAttractorMass);
            }

            col.destroy();
        }
        else if (collision.gameObject.tag == "death")
        {
            Application.LoadLevel(Application.loadedLevel);
        }
        //if (checkGrounded())
        //   jumping = false;
    }
Exemple #3
0
    //Test function
    public void add(collectable building)
    {
        Inventory.buildings.Add(building);
        Inventory_UI ui = Instantiate(UIElement, content).GetComponent <Inventory_UI>();

        ui.SetUp(Inventory.buildings.Count, building);
    }
Exemple #4
0
    /*void OnCollisionEnter2D(Collision2D colll)
     * {
     *      Debug.Log("death1111");
     *      if(colll.gameObject.tag=="Birds")
     *      {
     *              Debug.Log("death");
     *              text.SetActive (true);
     *              player.SetActive (false);
     *              button.SetActive (true);
     *      }
     * }*/

    void Start()
    {
        mycol = GetComponent <Collider2D>();

        PotScript     = GameObject.FindGameObjectWithTag("pot").GetComponent <pot>();
        LolipopScript = GameObject.FindGameObjectWithTag("lolipop").GetComponent <collectable>();
        highscore     = PlayerPrefs.GetInt("highscore");
    }
    // Start is called before the first frame update
    public void SetUp(int count, collectable collect)
    {
        building = collect;
        transform.GetChild(0).GetComponent <UnityEngine.UI.Image>().sprite = building.sprite;
        transform.GetChild(1).GetComponent <Text>().text = building.objectName;
        player = GameObject.FindGameObjectWithTag("Player").GetComponent <TurretPlacement>();

        //GetComponent<RectTransform>().localPosition = new Vector3(0, -200 * count + 500, 0);
    }
Exemple #6
0
 // Start is called before the first frame update
 void Awake()
 {
     availableCollectables = new List <collectable>();
     Object[] availableObjects = Resources.LoadAll("ourCollectables");
     Debug.Log(availableObjects.Length);
     foreach (var x in availableObjects)
     {
         collectable i = x as collectable;
         availableCollectables.Add(i);
     }
     print(availableCollectables.Count);
 }
Exemple #7
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        collectable item = collision.GetComponent <collectable>();

        if (item != null)
        {
            item.player           = this.gameObject;
            item.transform.parent = null;
            info.inventory.Add(item);
            item.gameObject.SetActive(false);
        }
    }
Exemple #8
0
    public void placeBuilding(collectable building)
    {
        if (Inventory.buildings.Contains(building))
        {
            Vector3 spawnPos = cam.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y));
            if (!prohibitedArea.OverlapPoint(spawnPos))
            {
                Instantiate(building.building, new Vector3(spawnPos.x, spawnPos.y, 0), Quaternion.identity);

                Inventory.buildings.Remove(building);

                building = null;
            }
        }
        else
        {
            Debug.Log("ERROR: This shouldn't be happening! Something's wrong! panic! AAAAA!");
        }
    }