Ejemplo n.º 1
0
        public static Entity CreateEntity(EntityDef md)
        {
            //tohle je tu nejake divne....
            if (md.ET == EntityType.Player)
            {
                md.Class = "Castles.Player";
            }

            string cls = CastlesConfigurationReader.GetConfiguration().GetEntityByType(md.ET).Class;

            try
            {
                Type t = Assembly.GetExecutingAssembly().GetType(cls);

                Object oh = Activator.CreateInstance(t);
                Entity m  = oh as Entity;

                if (m != null)
                {
                    m.position         = new IGPos(md.X, md.Y, md.Layer);
                    m.positionOriginal = new IGPos(md.X, md.Y, md.Layer);

                    return(m);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Cannot create entity. Something went wrong:", ex);
            }

            return(null);
        }
Ejemplo n.º 2
0
        public static EntityDef CreatePlayer(int x, int y, int layer)
        {
            EntityDef ed = new EntityDef();

            ed.X     = x;
            ed.Y     = y;
            ed.Layer = layer;
            ed.ET    = EntityType.Player;
            ed.Class = "Castles.Player";

            return(ed);
        }