示例#1
0
        //Metodi statici di conversione dei tipi: FromStringSpecificType, FromByteSpecificByte, StringToSurfaceType, SurfaceTypeToString

        /// <summary>
        /// Restituisce la stringa relativa al tipo specifico di tile indicato in input. Viene restituita la stringa vuota
        /// in caso di mancata conversione.
        /// </summary>
        /// <param name="tt">Tipo di tile di cui si vuole sapere il tipo specifico.</param>
        /// <param name="t">Tipo specifico della tile.</param>
        /// <returns>Tipo specifico della tile convertito in stringa.</returns>
        public static string FromByteSpecificType(KulaLevel.TileType tt, byte t)
        {
            string res = "";

            if (tt == KulaLevel.TileType.Block)
            {
                if (t >= 0 && t < blocks.Length)
                {
                    res = blocks[t];
                }
            }
            else if (tt == KulaLevel.TileType.Placeable)
            {
                if (t >= 0 && t < placeables.Length)
                {
                    res = placeables[t];
                }
            }
            else if (tt == KulaLevel.TileType.Enemy)
            {
                if (t >= 0 && t < enemies.Length)
                {
                    res = enemies[t];
                }
            }
            else
            {
                throw new Exception("The input type is unknown: " + tt.ToString());
            }
            return(res);
        }
示例#2
0
        private static void AddColor(KulaLevel.TileType tt, byte st, Color c)
        {
            Pair <string> a;

            if (!colors.ContainsKey(a = new Pair <string>(tt.ToString(), TileConverter.FromByteSpecificType(tt, st))))
            {
                colors.Add(a, c);
            }
        }