Example #1
0
        private void LoadAssets(TerrainItem item)
        {
            foreach (int textureId in item._mTextureIds)
            {
                TerrainTextureConfigItem textureCfg = SingletonManager.Get <TerrainTextureConfigManager>().GetTextureById(textureId);
                if (null == textureCfg)
                {
                    continue;
                }
                TerrainTextureTypeConfigItem typeCfg =
                    SingletonManager.Get <TerrainTextureTypeConfigManager>().GetTextureTypeById(textureCfg.Type);
                if (null == typeCfg)
                {
                    continue;
                }

                //Sound
                LoadSoundAsset(typeCfg.SoundInfo.Normal);
                LoadSoundAsset(typeCfg.SoundInfo.Brake);
                foreach (int id in typeCfg.SoundInfo.WalkIds)
                {
                    LoadSoundAsset(id);
                }
                //Effects
                LoadEffectAsset(typeCfg.EffectInfo.Normal);
                LoadEffectAsset(typeCfg.EffectInfo.Brake);
                LoadEffectAsset(typeCfg.EffectInfo.BrokenBrake);
                //Material
                LoadMaterialAsset(typeCfg.MaterialInfo.Track);
                LoadMaterialAsset(typeCfg.MaterialInfo.Slippery);
            }
        }
Example #2
0
        public int GetTerrainPositionMatType(Vector3 worldPos)
        {
            int textureId = GetId(worldPos);
            TerrainTextureTypeConfigItem texture = GetTextureType(textureId);

            if (texture != null)
            {
                return(texture.Type);
            }
            return(0);
        }
Example #3
0
        public int GetSoundId(Vector3 worldPos, ETerrainSoundType soundType)
        {
            int textureId = GetId(worldPos);
            TerrainTextureTypeConfigItem texture = GetTextureType(textureId);

            if (null != texture)
            {
                switch (soundType)
                {
                case ETerrainSoundType.Normal:
                    return(texture.SoundInfo.Normal);

                case ETerrainSoundType.Brake:
                    return(texture.SoundInfo.Brake);

                case ETerrainSoundType.Walk:
                    int[] ids = texture.SoundInfo.WalkIds;
                    if (null != ids && ids.Length > 0)
                    {
                        return(ids[_randGen.Next(ids.Length)]);
                    }
                    break;

                case ETerrainSoundType.Squat:
                    var squatIds = texture.SoundInfo.SquatIds;
                    if (null != squatIds && squatIds.Length > 0)
                    {
                        return(squatIds[_randGen.Next(squatIds.Length)]);
                    }
                    break;

                case ETerrainSoundType.Crawl:
                    var crawIds = texture.SoundInfo.CrawlIds;
                    if (null != crawIds && crawIds.Length > 0)
                    {
                        return(crawIds[_randGen.Next(crawIds.Length)]);
                    }
                    break;

                case ETerrainSoundType.Land:
                    return(texture.SoundInfo.Land);
                }
            }
            return(_defaultSoundId);
        }
Example #4
0
        //MaterialId
        public int GetMaterialId(Vector3 worldPos, ETerrainMaterialType materialType)
        {
            int textureId = GetId(worldPos);
            TerrainTextureTypeConfigItem texture = GetTextureType(textureId);

            if (null != texture)
            {
                switch (materialType)
                {
                case ETerrainMaterialType.Track:
                    return(texture.MaterialInfo.Track);

                case ETerrainMaterialType.Slippery:
                    return(texture.MaterialInfo.Slippery);
                }
            }
            return(_defaultMaterialId);
        }
Example #5
0
        //EffectId
        public int GetEffectId(Vector3 worldPos, ETerrainEffectType effectType)
        {
            int textureId = GetId(worldPos);
            TerrainTextureTypeConfigItem texture = GetTextureType(textureId);

            if (null != texture)
            {
                switch (effectType)
                {
                case ETerrainEffectType.Normal:
                    return(texture.EffectInfo.Normal);

                case ETerrainEffectType.Brake:
                    return(texture.EffectInfo.Brake);

                case ETerrainEffectType.BrokenBrake:
                    return(texture.EffectInfo.BrokenBrake);
                }
            }
            return(_defaultEffectId);
        }
Example #6
0
        //ć–æ‘©æ“ŠćŠ›
        public float GetDragFriction(Vector3 worldPos)
        {
            /*
             * int posX = Math.Max((int)(worldPos.x - _terrainInitPos.x), 0);
             * int posZ = Math.Max((int)(worldPos.z - _terrainInitPos.z), 0);
             * int subId = CalcPos2SubId(posX, posZ);
             * TerrainItem item = GetSubTerrain(subId);
             * if (item != null)
             * {
             *  posX %= _splitWidth;
             *  posZ %= _splitHeight;
             *  return item.GetDragFriction(posX, posZ, _defaultFrictionDrag);
             * }*/
            int textureId = GetId(worldPos);
            TerrainTextureTypeConfigItem item = GetTextureType(textureId);

            if (null != item)
            {
                return(item.Drag);
            }
            return(_defaultFrictionDrag);
        }