Exemplo n.º 1
0
        public Sprite(string name, int[] frame)
        {
            type = ""; gen = 1; breathAnim = new List <int[]>(); walkAnim = new List <int[]>(); jumpAnim = new List <int[]>(); sneakAnim = new List <int[]>(); runAnim = new List <int[]>();

            Spritejson j = new Spritejson();

            j.name       = name;
            j.type       = type;
            j.gen        = gen;
            j.breathAnim = breathAnim;
            j.breathAnim.Add(frame);
            j.walkAnim   = walkAnim;
            j.jumpAnim   = jumpAnim;
            j.sneakAnim  = sneakAnim;
            j.dimensions = new int[] { 0, 0 };
            j.runAnim    = runAnim;
            j.deathAnim  = new List <int[]>();
            FileStream stream = new FileStream(name + ".json", FileMode.OpenOrCreate);
            DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Spritejson));

            ser.WriteObject(stream, j);
            stream.Position = 0;
            StreamReader sr = new StreamReader(stream);

            stream.Close();
            sr.Close();
        }
Exemplo n.º 2
0
        public static List <int[]> GetrunAnim(string name)
        {
            FileStream stream = new FileStream(name + ".json", FileMode.Open);
            DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Spritejson));
            Spritejson s = (Spritejson)ser.ReadObject(stream);

            stream.Close();
            return(s.runAnim);
        }
Exemplo n.º 3
0
        public static void SetrunAnim(string name, List <int[]> objet)
        {
            FileStream stream = new FileStream(name + ".json", FileMode.Open);
            DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Spritejson));
            Spritejson s = (Spritejson)ser.ReadObject(stream);

            s.runAnim       = objet;
            stream.Position = 0;
            ser.WriteObject(stream, s);
            stream.Close();
        }