Inheritance: TileSet
Esempio n. 1
0
        private static void _AddActivity(ContentManager _content, ActorView actor, string character, string action, Backend.Activity activity)
        {
            if (System.IO.File.Exists(".\\content\\" + character + "-" + action + ".xnb"))
            {
                try
                {
                    Texture2D texture = _content.Load<Texture2D>(character + "-" + action);
                    int size = texture.Height / 8;
                    int cols = texture.Width / size;
                    actor.width = size;
                    actor.height = size;
                    int diff = 0;
                    if (size < 128)
                    {
                        diff = 128 - size;
                    }

                    // add offset / crop
                    actor.Add(activity, Backend.Direction.DownRight, character + "-" + action, new Backend.Coords(size * 0, size * 0), cols, 1, new Backend.Coords(diff / 2, diff / 2), new Backend.Coords(diff - diff / 2, diff - diff / 2));
                    actor.Add(activity, Backend.Direction.UpRight, character + "-" + action, new Backend.Coords(size * 0, size * 1), cols, 1, new Backend.Coords(diff / 2, diff / 2), new Backend.Coords(diff - diff / 2, diff - diff / 2)); // Ok
                    actor.Add(activity, Backend.Direction.Right, character + "-" + action, new Backend.Coords(size * 0, size * 2), cols, 1, new Backend.Coords(diff / 2, diff / 2), new Backend.Coords(diff - diff / 2, diff - diff / 2)); // OK
                    actor.Add(activity, Backend.Direction.Up, character + "-" + action, new Backend.Coords(size * 0, size * 3), cols, 1, new Backend.Coords(diff / 2, diff / 2), new Backend.Coords(diff - diff / 2, diff - diff / 2)); // Ok
                    actor.Add(activity, Backend.Direction.DownLeft, character + "-" + action, new Backend.Coords(size * 0, size * 4), cols, 1, new Backend.Coords(diff / 2, diff / 2), new Backend.Coords(diff - diff / 2, diff - diff / 2)); // Ok
                    actor.Add(activity, Backend.Direction.Down, character + "-" + action, new Backend.Coords(size * 0, size * 5), cols, 1, new Backend.Coords(diff / 2, diff / 2), new Backend.Coords(diff - diff / 2, diff - diff / 2));
                    actor.Add(activity, Backend.Direction.Left, character + "-" + action, new Backend.Coords(size * 0, size * 6), cols, 1, new Backend.Coords(diff / 2, diff / 2), new Backend.Coords(diff - diff / 2, diff - diff / 2)); // OK
                    actor.Add(activity, Backend.Direction.UpLeft, character + "-" + action, new Backend.Coords(size * 0, size * 7), cols, 1, new Backend.Coords(diff / 2, diff / 2), new Backend.Coords(diff - diff / 2, diff - diff / 2));
                }
                catch
                {

                }
                _content.Unload();
            }
        }
Esempio n. 2
0
 public static void CreateActor(Mainmap _map, ContentManager _content, Camera _camera, string character = "")
 {
     Backend.Actor tmp = new Backend.Actor(Backend.ActorType.NPC, 20, 20, 20);
     ActorView player = new ActorView(_camera, _map, 0, _content, Backend.Coords.Zero, tmp);
     _AddActivity(_content, player, character, "walk", Backend.Activity.Walk);
     _AddActivity(_content, player, character, "hit", Backend.Activity.Hit);
     _AddActivity(_content, player, character, "die", Backend.Activity.Die);
     _AddActivity(_content, player, character, "talk", Backend.Activity.Talk);
     _AddActivity(_content, player, character, "attack", Backend.Activity.Attack);
     _AddActivity(_content, player, character, "special", Backend.Activity.Special);
     player.Save("Content\\" + character + ".xml");
 }