コード例 #1
0
 public void ExpandWithBounds(TextureBounds b)
 {
     xMin = Math.Min(xMin, b.xMin);
     xMax = Math.Max(xMax, b.xMax);
     yMin = Math.Min(yMin, b.yMin);
     yMax = Math.Max(yMax, b.yMax);
 }
コード例 #2
0
        public Material CreateMaterial()
        {
            TextureBounds       b = texture;
            Material            baseMaterial;
            SemiTransparentMode stMode = BlendMode;

            if (IsLight || stMode == SemiTransparentMode.MinusOne)
            {
                baseMaterial = MapLoader.Loader.baseLightMaterial;
            }
            else if (/*m.colors.Any(c => c.a != 1f) || */ IsTransparent || stMode != SemiTransparentMode.One)
            {
                baseMaterial = MapLoader.Loader.baseTransparentMaterial;
            }
            else
            {
                baseMaterial = MapLoader.Loader.baseMaterial;
            }
            // TODO: Figure out transparency for these games

            /*if (Settings.s.game == Settings.Game.JungleBook || Settings.s.game == Settings.Game.DD) {
             *  baseMaterial = MapLoader.Loader.baseMaterial;
             * }*/
            Material mat = new Material(baseMaterial);

            mat.SetInt("_NumTextures", 1);
            string    textureName = "_Tex0";
            Texture2D tex         = b.texture;

            if (ScrollingEnabled)
            {
                tex.wrapMode = TextureWrapMode.Repeat;
            }
            mat.SetTexture(textureName, tex);

            mat.SetVector(textureName + "Params", new Vector4(0,
                                                              ScrollingEnabled ? 1f : 0f,
                                                              0f, 0f));
            mat.SetVector(textureName + "Params2", new Vector4(
                              0f, 0f,
                              ScrollX, ScrollY));
            mat.SetVector("_AmbientCoef", Vector4.one);
            mat.SetFloat("_Prelit", 1f);
            switch (stMode)
            {
            case SemiTransparentMode.MinusOne:
                mat.SetInt("_BlendOp", (int)UnityEngine.Rendering.BlendOp.ReverseSubtract);
                mat.SetInt("_SrcBlendMode", (int)UnityEngine.Rendering.BlendMode.One);
                mat.SetInt("_DstBlendMode", (int)UnityEngine.Rendering.BlendMode.One);
                break;
            }
            return(mat);
        }
コード例 #3
0
        public bool HasOverlap(TextureBounds b)
        {
            if (b.pageInfo != pageInfo || b.paletteInfo != paletteInfo)
            {
                return(false);
            }

            bool xOverlap = (xMin >= b.xMin || xMin <= b.xMax) && (xMax >= b.xMin || xMax <= b.xMax);
            bool yOverlap = (yMin >= b.yMin || yMin <= b.yMax) && (yMax >= b.yMin || yMax <= b.yMax);

            return(xOverlap && yOverlap);
        }