Пример #1
0
        public List <ReferencePart> GetPartsOfType(EPartType type)
        {
            switch (type)
            {
            case EPartType.Battery:
                return(_batteries);

            case EPartType.Cargo:
                return(_cargos);

            case EPartType.Cooling:
                return(_coolings);

            case EPartType.Drill:
                return(_drills);

            case EPartType.Engine:
                return(_engines);

            case EPartType.FuelTank:
                return(_fuelTanks);

            case EPartType.Hull:
                return(_hulls);

            default:
                throw new ArgumentException("Requested part type is not present in ReferencePartList");
            }
        }
Пример #2
0
    public override void OnInitial(XEntity enty)
    {
        base.OnInitial(enty);
        XEntity e = enty;

        //时装
        TempEquipSuit fashions = new TempEquipSuit();

        m_FashionList = new List <EquipPart>();
        var fashionsuit = XTableMgr.GetTable <FashionSuit>();

        for (int i = 0, max = fashionsuit.length; i < max; ++i)
        {
            FashionSuit.RowData row = fashionsuit[i];
            if (row.FashionID != null)
            {
                XEquipUtil.MakeEquip(row.SuitName, row.FashionID, m_FashionList, fashions, (int)row.SuitID);
            }
        }

        //装备
        m_EquipList = new List <EquipPart>();
        var equipsuit = XTableMgr.GetTable <EquipSuit>();

        for (int i = 0, max = equipsuit.length; i < max; ++i)
        {
            EquipSuit.RowData row = equipsuit[i];
            if (row.EquipID != null)
            {
                XEquipUtil.MakeEquip(row.SuitName, row.EquipID, m_EquipList, fashions, -1);
            }
        }

        Transform skinmesh = e.EntityObject.transform;

        skin = skinmesh.GetComponent <SkinnedMeshRenderer>();
        if (skin == null)
        {
            skin = skinmesh.gameObject.AddComponent <SkinnedMeshRenderer>();
        }
        skin.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On;
        e.skin = skin;

        for (EPartType part = EPartType.ECombinePartStart; part < EPartType.ECombinePartEnd; ++part)
        {
            parts[(int)part] = new PartLoadTask(part, this);
        }
        for (EPartType part = EPartType.ECombinePartEnd; part < EPartType.EMountEnd; ++part)
        {
            parts[(int)part] = new MountLoadTask(part, this);
        }
        RegisterEvent(XEventDefine.XEvent_Detach_Host, OnDetachHost);

        EquipPart(m_FashionList[0]);
    }
Пример #3
0
 public void UnequipPart(EPartType partType)
 {
     try
     {
         _equipment[partType] = null;
     }
     catch
     {
         Log.Instance.WriteException(new KeyNotFoundException("Key: " + partType));
     }
 }
Пример #4
0
 public Part GetEquippedPart(EPartType partType)
 {
     if (_equipment.ContainsKey(partType))
     {
         return(_equipment[partType]);
     }
     else
     {
         return(null);
     }
 }
Пример #5
0
 private void OnDetachHost(XEventArgs e)
 {
     for (EPartType part = EPartType.ECombinePartStart; part < EPartType.EMountEnd; ++part)
     {
         var p = parts[(int)part];
         if (p != null)
         {
             p.Reset();
         }
     }
 }
Пример #6
0
    public static string GetDefaultPath(EPartType part, DefaultEquip.RowData data)
    {
        string partPath = "";

        switch (part)
        {
        case EPartType.EFace:
            partPath = data.Face;
            break;

        case EPartType.EHair:
            partPath = data.Hair;
            break;

        case EPartType.EUpperBody:
            partPath = data.Body;
            break;

        case EPartType.ELowerBody:
            partPath = data.Leg;
            break;

        case EPartType.EGloves:
            partPath = data.Glove;
            break;

        case EPartType.EBoots:
            partPath = data.Boots;
            break;

        case EPartType.ESecondaryWeapon:
            partPath = data.SecondWeapon;
            break;

        case EPartType.EMainWeapon:
            partPath = data.Weapon;
            break;

        case EPartType.EWings:
            partPath = data.WingPoint;
            break;

        case EPartType.ETail:
            partPath = data.TailPoint;
            break;
        }
        return(partPath);
    }
Пример #7
0
        private void RepairPlayer()
        {
            RepairPlayerEA   rp = new RepairPlayerEA();
            int              amountOfRepairedParts = Random.Range(1, 3);
            List <EPartType> partTypes             = ((EPartType[])Enum.GetValues(typeof(EPartType))).ToList();

            for (int i = 0; i < amountOfRepairedParts; ++i)
            {
                if (partTypes.Count == 0)
                {
                    break;
                }
                EPartType partType = partTypes[Random.Range(0, partTypes.Count)];
                rp.PermaRepair.Add(partType, Random.Range(1, 3) / 100f);
                partTypes.Remove(partType);
            }
            _repairPlayer.Raise(rp);
        }
Пример #8
0
 public MountLoadTask(EPartType p, IEquip e) : base(p)
 {
     component = e;
 }
Пример #9
0
        private void SetPartToExchangerOnTheInPos(EPartType partType)
        {
            PartTypeOnInPos = partType;

            if (ExchangerOnTheInPos == EExchanger.Exchanger1)
                PartOfExchanger1 = partType;
            else
                PartOfExchanger2 = partType;
        }
Пример #10
0
 public BaseLoadTask(EPartType p)
 {
     part = p;
     fpi.Reset();
 }
Пример #11
0
 public PartLoadTask(EPartType p, IEquip equip)
     : base(p)
 {
     m_equip = equip;
 }
Пример #12
0
 public static int GetPartOffset(EPartType partType)
 {
     return(shaderSkinID[(int)partType]);
 }
Пример #13
0
    /// <summary>
    /// 处理mesh和tex的对应关系,并处理uv
    /// </summary>
    private bool Combine()
    {
        int partCount = 0;

        for (int i = (int)EPartType.ECombinePartStart; i < (int)EPartType.ECombinePartEnd; ++i)
        {
            PartLoadTask part = parts[i] as PartLoadTask;
            if (part.HasMesh())
            {
                partCount++;
            }
        }
        CombineInstance[] combineArray = GetMatCombineInstanceArray(partCount);
        if (combineArray != null)
        {
            //1.mesh collection
            int index = 0;
            for (int i = (int)EPartType.ECombinePartStart; i < (int)EPartType.ECombinePartEnd; ++i)
            {
                PartLoadTask part = parts[i] as PartLoadTask;
                if (part.HasMesh())
                {
                    CombineInstance ci = new CombineInstance();
                    if (part.mesh != null)
                    {
                        ci.mesh = part.mesh;
                    }
                    ci.subMeshIndex       = 0;
                    combineArray[index++] = ci;
                }
            }
            //2.combine
            if (skin.sharedMesh == null)
            {
                skin.sharedMesh = new Mesh();
            }
            else
            {
                skin.sharedMesh.Clear(true);
            }
            skin.gameObject.SetActive(false);
            skin.sharedMesh.CombineMeshes(combineArray, true, false);
            skin.gameObject.SetActive(true);

            //3.set material
            if (skin != null)
            {
                XEquipUtil.ReturnMaterial(skin.sharedMaterial);
            }
            skin.sharedMaterial = XEquipUtil.GetRoleMat();
            skin.GetPropertyBlock(mpb);

            //4. postload - set texture
            for (EPartType part = EPartType.ECombinePartStart; part < EPartType.EMountEnd; ++part)
            {
                parts[(int)part].PostLoad();
            }
            return(true);
        }
        return(false);
    }
Пример #14
0
 public static string GetPartOffset(EPartType partType)
 {
     return("_Tex" + (int)partType);
 }