Exemplo n.º 1
0
    private MBSetPart GetSetPartByEnum(SetPartType _type)
    {
        switch (_type)
        {
        case SetPartType.Suit:
            return(Suit);

        case SetPartType.Hat:
            return(Hat);

        case SetPartType.Glove:
            return(Glove);

        case SetPartType.Weapon:
            return(Weapon);
        }
        return(null);
    }
Exemplo n.º 2
0
    /// <summary>
    /// 替換部件
    /// </summary>
    /// <param name="_part">已經實例化的套件</param>
    /// <param name="_type">套件種類</param>
    private void SetPartsData(MBSetPart _part, SetPartType _type)
    {
        int partIndex = (int)_type;

        //回收舊部件
        if (GetSetPartByEnum(_type) != null)
        {
            MeatBallSetFactory.Instance.RecyclePart(GetSetPartByEnum(_type));
        }
        //資料
        _part.ReuseGameObject();
        //技能
        Skill newSkill = _part.Skill;

        skills[(int)_type] = newSkill;
        SkillChange(newSkill);
        //遊戲物件
        BodyPart[] parts  = Enum.GetValues(typeof(BodyPart)) as BodyPart[];
        Transform  buffer = null;

        for (int i = 0; i < parts.Length; i++)
        {
            if (_part.Sections[i] == null)
            {
                continue;
            }
            if (myBehavior.BodyParts[i] == null)
            {
                throw new Exception("沒有指定貢丸穿戴套裝物件的物件,檢查一下MeatBallBehavior的BodyParts");
            }
            buffer = _part.Sections[i].transform;
            buffer.SetParent(myBehavior.BodyParts[i].transform);
            buffer.localPosition = Vector3.zero;
            buffer.localRotation = Quaternion.Euler(Vector3.zero);
        }
    }