Beispiel #1
0
    void OnGUI()
    {
        GUILayout.BeginVertical();
        string[] types = { "tree", "car", "stone" };
        //for(int i = 0;i<3;++i)
        // {
        //    if (GUILayout.Button(types[i]))
        //        chooseType = (e_ItemType)i;
        // }

        if (GUILayout.Button("tree"))
        {
            chooseType = e_ItemType.Tree;
        }
        if (GUILayout.Button("box"))
        {
            chooseType = e_ItemType.Box;
        }
        if (GUILayout.Button("stone"))
        {
            chooseType = e_ItemType.Stone;
        }
        GUILayout.EndVertical();
        GUILayout.Label("save data to asset");
        if (GUILayout.Button("save data"))
        {
            Save();
        }
    }
Beispiel #2
0
    /// <summary>
    /// Returns a item from the object pool if one is available.
    /// If not, create a new item
    /// </summary>
    /// <param name="type">item type to find</param>
    /// <returns></returns>
    public GameObject FindItemOfType(e_ItemType type)
    {
        GameObject go;

        for (int i = 0; i < objectPool_item.Count; i++)
        {
            if (objectPool_item[i].itemType == type)
            {
                objectPool_item[i].TurnOn();
                go = objectPool_item[i].gameObject;
                objectPool_item.RemoveAt(i);
                return(go);
            }
        }

        if (ItemParent == null)
        {
            Init();
        }

        switch (type)
        {
        case e_ItemType.Boost_Attack:
            go = Instantiate(Helper.ItemPath_Boost_attack, ItemParent.transform) as GameObject;
            go.GetComponent <Item>().TurnOn();
            return(go);

        case e_ItemType.Boost_Speed:
            go = Instantiate(Helper.ItemPath_Boost_speed, ItemParent.transform) as GameObject;
            go.GetComponent <Item>().TurnOn();
            return(go);

        case e_ItemType.Boost_Defense:
            go = Instantiate(Helper.ItemPath_Boost_defense, ItemParent.transform) as GameObject;
            go.GetComponent <Item>().TurnOn();
            return(go);

        case e_ItemType.Pickup:
            go = Instantiate(Helper.ItemPath_pickUp, ItemParent.transform) as GameObject;
            go.GetComponent <Item>().TurnOn();
            return(go);

        default:
            Debug.LogError("FindEnemyOfType - Returned null");
            return(null);
        }
    }
Beispiel #3
0
    /// <summary>
    ///
    /// this is used to apply a boost to the player depending on the
    /// enum type passed
    ///
    /// </summary>
    public void ApplyBoost(e_ItemType type)
    {
        switch (type)
        {
        case e_ItemType.Boost_Speed:
            attackBoostTimer = 0;
            break;

        case e_ItemType.Boost_Attack:
            attackBoostTimer = 0;
            break;

        case e_ItemType.Boost_Defense:
            sheildBoost = true;
            break;

        case e_ItemType.Pickup:
            Debug.LogError("USE ApplyLoot(int amount) FUNCTION, USING WRONG ONE");
            break;

        default:
            break;
        }
    }