Beispiel #1
0
        public override bool OnSetUp(BlockConfigObject config, World world)
        {
            if (!base.OnSetUp(config, world))
            {
                return(false);
            }

            if (config is CubeConfigObject cubeConfig)
            {
                textures    = new TextureCollection[6];
                textures[0] = world.textureProvider.GetTextureCollection(cubeConfig.TopTexture);
                textures[1] = world.textureProvider.GetTextureCollection(cubeConfig.BottomTexture);
                textures[2] = world.textureProvider.GetTextureCollection(cubeConfig.BackTexture);
                textures[3] = world.textureProvider.GetTextureCollection(cubeConfig.FrontTexture);
                textures[4] = world.textureProvider.GetTextureCollection(cubeConfig.RightTexture);
                textures[5] = world.textureProvider.GetTextureCollection(cubeConfig.LeftTexture);

                colors    = new Color32[6];
                colors[0] = cubeConfig.TopColor;
                colors[1] = cubeConfig.BottomColor;
                colors[2] = cubeConfig.BackColor;
                colors[3] = cubeConfig.FrontColor;
                colors[4] = cubeConfig.RightColor;
                colors[5] = cubeConfig.LeftColor;
            }
            else
            {
                Debug.LogError(config.GetType() + " config passed to cube block.");
                return(false);
            }

            return(true);
        }
Beispiel #2
0
        public override bool OnSetUp(BlockConfigObject config, World world)
        {
            if (!base.OnSetUp(config, world))
            {
                return(false);
            }


            //connectsToNames = _GetPropertyFromConfig(config, "connectsToNames", string.Empty).Replace(" ", string.Empty).Split(',');
            //connectsToSolid = _GetPropertyFromConfig(config, "connectsToSolid", true);

            //for (int dir = 0; dir < 6; dir++)
            //{
            //    CustomMeshBlockData d = m_datas[dir] = new CustomMeshBlockData();
            //    MeshBlockInfo i = m_info[dir] = new MeshBlockInfo();
            //    Direction direction = DirectionUtils.Get(dir);

            //    i.fileLocation = _GetPropertyFromConfig(config, direction + "FileLocation", string.Empty);
            //    if (string.IsNullOrEmpty(i.fileLocation))
            //    {
            //        continue;
            //    }

            //    string textureName = _GetPropertyFromConfig(config, direction + "Texture", string.Empty);
            //    d.textures = world.textureProvider.GetTextureCollection(textureName);

            //    i.meshOffset = new Vector3(
            //        float.Parse(_GetPropertyFromConfig(config, direction + "XOffset", "0"), CultureInfo.InvariantCulture),
            //        float.Parse(_GetPropertyFromConfig(config, direction + "YOffset", "0"), CultureInfo.InvariantCulture),
            //        float.Parse(_GetPropertyFromConfig(config, direction + "ZOffset", "0"), CultureInfo.InvariantCulture)
            //    );
            //}

            return(true);
        }
        public override bool OnSetUp(BlockConfigObject config, World world)
        {
            if (!base.OnSetUp(config, world))
            {
                return(false);
            }

            if (config is CrossMeshConfigObject crossMeshConfig)
            {
                texture = world.textureProvider.GetTextureCollection(crossMeshConfig.Texture.texture);
                color   = crossMeshConfig.Texture.color;
            }
            else
            {
                Debug.LogError(config.GetType().Name + " config passed to cross mesh block.");
                return(false);
            }

            return(true);
        }
Beispiel #4
0
        /// <summary>
        /// Assigns the variables in the config from a hashtable. When overriding this
        /// remember to call the base function first.
        /// </summary>
        /// <param name="config">Hashtable of the json config for the block</param>
        /// <param name="world">The world this block type belongs to</param>
        public virtual bool OnSetUp(BlockConfigObject config, World world)
        {
            // Obligatory parameters
            Name = config.BlockName;
            if (string.IsNullOrWhiteSpace(Name))
            {
                Debug.LogError(config.name + " can't have a empty block name!");
                return(false);
            }

            TypeInConfig = (ushort)(config.ID + BlockProvider.lastReservedType);
            Solid        = config.Solid;
            Transparent  = config.Transparent;

            // Try to associate requested render materials with one of world's materials
            RenderMaterialID = (int)config.TextureType;
            //string materialName = _GetPropertyFromConfig(config, "material", string.Empty);
            //for (int i = 0; i < world.renderMaterials.Length; i++)
            //{
            //    if (world.renderMaterials[i].name.Equals(materialName))
            //    {
            //        renderMaterialID = i;
            //        break;
            //    }
            //}

            // Try to associate requested physic materials with one of world's materials
            PhysicMaterialID = Solid ? 0 : -1; // solid objects will collide by default
                                               //string materialName = _GetPropertyFromConfig(config, "materialPx", string.Empty);
                                               //for (int i = 0; i < world.physicsMaterials.Length; i++)
                                               //{
                                               //    if (world.physicsMaterials[i].name.Equals(materialName))
                                               //    {
                                               //        physicMaterialID = i;
                                               //        break;
                                               //    }
                                               //}

            return(true);
        }
        public override bool OnSetUp(BlockConfigObject config, World world)
        {
            if (!base.OnSetUp(config, world))
            {
                return(false);
            }

            if (config is CustomMeshConfigObject meshConfig)
            {
                Data.textures = world.textureProvider.GetTextureCollection(meshConfig.Texture);
                meshGO        = meshConfig.MeshObject;
                MeshOffset    = meshConfig.MeshOffset;
                long scaleInv = 1;

                scale = 1f / scaleInv;

                return(true);
            }
            else
            {
                Debug.LogError(config.GetType() + " config passed to custom mesh block.");
                return(false);
            }
        }