Exemplo n.º 1
0
        public static void CreatePerson(Entity person)
        {
            if (PeopleTable.ContainsKey(person.Name))
                return;

            SpritesetInstance sprite = AssetManager.GetSpriteset(person.Spriteset);
            Person p = new Person(person.Name, sprite, true);
            p.Layer = person.Layer;
            int w = (int)p.Base["x2"] - (int)p.Base["x1"];
            int h = (int)p.Base["y2"] - (int)p.Base["y1"];
            p.Position = new Vector2f(person.X - w/2, person.Y - h/2);
            for (var i = 0; i < person.Scripts.Count; ++i)
                p.SetScript((PersonScripts)i, person.Scripts[i]);

            PeopleTable.Add(person.Name, p);
            _personlist.Add(person.Name);
            People.Add(p);
        }
Exemplo n.º 2
0
        public static void CreatePerson(string name, string ss, [DefaultParameterValue(true)] bool destroy = true)
        {
            if (PeopleTable.ContainsKey(name))
                return;

            SpritesetInstance sprite = AssetManager.GetSpriteset(ss);
            Person p = new Person(name, sprite, destroy);
            PeopleTable.Add(name, p);
            _personlist.Add(name);
            People.Add(p);

            Map start = MapEngineHandler.Map;
            if (start != null)
            {
                p.Layer = start.StartLayer;
                SetPersonXY(p.Name, start.StartX, start.StartY);
            }
        }
Exemplo n.º 3
0
 public static bool CheckPersonObstructions(ref Vector2f position, Person person)
 {
     foreach (Person p in People)
     {
         if (p.Layer == person.Layer && p.Name != person.Name &&
             person.CheckObstructions(ref position, p))
         {
             ObstPerson = p.Name;
             return true;
         }
     }
     return false;
 }
Exemplo n.º 4
0
        public bool CheckObstructions(ref Vector2f pos, Person other)
        {
            if (other.IgnorePersons || other.Layer != Layer)
                return false;

            Line[] baselines1 = _innerSS.GetLineBase();
            Line[] baselines2 = other._innerSS.GetLineBase();
            Vector2f pos1 = pos - new Vector2f(_base.Left, _base.Top);
            Vector2f pos2 = other.Position - new Vector2f(other._base.Left, other._base.Top);

            foreach (Line l1 in baselines1)
            {
                Line A = l1.Offset(pos1);
                foreach (Line l2 in baselines2)
                {
                    if (Line.Intersects(A, l2.Offset(pos2)))
                        return true;
                }
            }

            return false;
        }
Exemplo n.º 5
0
 public static bool CheckTileObstruction(ref Vector2f position, Person person)
 {
     int tw = _map.Tileset.TileWidth, th = _map.Tileset.TileHeight;
     int sx = (int)position.X / tw + 2;
     int sy = (int)position.Y / th + 2;
     Vector2f pos = new Vector2f();
     for (var y = sy - 2; y < sy; ++y)
     {
         pos.Y = y * th;
         for (var x = sx - 2; x < sx; ++x)
         {
             pos.X = x * tw;
             int t = _map.Layers[person.Layer].GetTile(x, y);
             if (t >= 0 && person.CheckObstructions(ref position, ref pos, _map.Tileset.Tiles[t]))
                 return true;
         }
     }
     return false;
 }
Exemplo n.º 6
0
 public static bool CheckLineObstruction(ref Vector2f position, Person person)
 {
     foreach (Segment s in _map.Layers[person.Layer].Segments)
     {
         if (person.CheckObstructions(ref position, s.Line))
             return true;
     }
     return false;
 }