Exemple #1
0
    /// <summary>
    /// 取得套件
    /// </summary>
    /// <param name="_partType"></param>
    /// <returns></returns>
    public MBSetPart GetPartByEnum(MeatBall.SetPartType _partType)
    {
        MBSetPart part = null;

        switch (_partType)
        {
        case MeatBall.SetPartType.Glove:
            part = this.Glove;
            break;

        case MeatBall.SetPartType.Suit:
            part = this.Suit;
            break;

        case MeatBall.SetPartType.Hat:
            part = this.Hat;
            break;

        case MeatBall.SetPartType.Weapon:
            part = this.Weapon;
            break;

        default:
            break;
        }
        part.Initial(Name);
        return(part);
    }
Exemple #2
0
    /// <summary>
    /// 取得套裝散件
    /// </summary>
    /// <param name="_setName"></param>
    /// <param name="_type"></param>
    /// <returns></returns>
    protected MBSetPart GetPartGameObject(SetType _setName, MeatBall.SetPartType _type)
    {
        //如果原資料就沒有該部位了就回傳null
        if (dataPool[_setName].GetPartByEnum(_type) == null)
        {
            return(null);
        }
        Debug.Log("Search Suit");
        MBSetPart part = null;

        //尋找該Dictionary
        for (int i = 0; i < objectPool[_setName].Count; i++)
        {
            //找出該套裝
            part = objectPool[_setName][i].GetPartByEnum(_type);
            //如果此物件的該部位正在被使用就繼續找別的
            if (part.IsThisUsing)
            {
                part = null;
                continue;
            }
            //沒在使用就指定該物件
            break;
        }
        //整場物件都沒有空的部位就造新的套裝再取其物件
        if (part == null)
        {
            MeatBallSet newSet = GameObject.Instantiate(GetSet(_setName)) as MeatBallSet;
            objectPool[_setName].Add(newSet);
            newSet.InstantiateParts();
            part = newSet.GetPartByEnum(_type);
        }
        Debug.Log(part.name);
        //事前準備
        part.ReuseGameObject();
        //回傳該物件
        return(part);
    }