예제 #1
0
 public ChangedTilePropertiesEventArgs(Editor ed)
 {
     if (ed == null)
     {
         return;
     }
     if (ed.Mode == EditorMode.SelectMode)
     {
         KulaLevel.MapTile t = ed.PointedTile;
         if (t != null)
         {
             curTileType         = t.TileType;
             curSpecificTileType = TileConverter.FromByteSpecificType(curTileType, t.Type);
             curMode             = ed.Mode;
             curSurface          = ed.ChosenFaceDirection;
         }
     }
     else if (ed.Mode == EditorMode.InsertMode)
     {
         KulaLevel.MapTile t = ed.TileToBeAdded;
         if (t != null)
         {
             curTileType         = t.TileType;
             curSpecificTileType = TileConverter.FromByteSpecificType(curTileType, t.Type);
             curMode             = ed.Mode;
             curSurface          = ed.ChosenFaceDirection;
         }
     }
 }
예제 #2
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);
        }
예제 #3
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);
            }
        }
예제 #4
0
        /// <summary>
        /// Restituisce il tipo specifico di un tile sottoforma di byte. In caso di stringa non valida, viene restituito 255
        /// </summary>
        /// <param name="tt">Tipo di tile in input</param>
        /// <param name="s">Stringa che dovrebbe rappresentare un tipo specifico di tile.</param>
        /// <returns></returns>
        public static byte FromStringSpecificType(KulaLevel.TileType tt, string s)
        {
            byte res = 255;

            if (tt == KulaLevel.TileType.Block)
            {
                res = (byte)(blocks.ToList <string>().FindIndex(0, (x => x == s)));
            }
            else if (tt == KulaLevel.TileType.Placeable)
            {
                res = (byte)(placeables.ToList <string>().FindIndex(0, (x => x == s)));
            }
            else if (tt == KulaLevel.TileType.Enemy)
            {
                res = (byte)(enemies.ToList <string>().FindIndex(0, (x => x == s)));
            }
            return(res);
        }
예제 #5
0
 /// <summary>
 /// Restituisce l'array contenente i tipi specifici di un dato tipo di tile, sottoforma di stringa
 /// </summary>
 /// <param name="tt">Tipo di tile di cui si vuole ottenere le stringhe relative ai tipi specifici.</param>
 /// <returns></returns>
 public static string[] GetSpecificTypesOf(KulaLevel.TileType tt)
 {
     if (tt == KulaLevel.TileType.Block)
     {
         return(blocks.DeepClone <string[]>());
     }
     else if (tt == KulaLevel.TileType.Enemy)
     {
         return(enemies.DeepClone <string[]>());
     }
     else if (tt == KulaLevel.TileType.Placeable)
     {
         return(placeables.DeepClone <string[]>());
     }
     else
     {
         return(null);
     }
 }