Esempio n. 1
0
        private void cut_door_at(int x, int y, Vector2Int direction, FlyweightCollection door)
        {
            var data = get(x, y);

            // data.get(data.Count.x / 2, data.Count.y - 1).Prototype = door_prototype

            int tx = direction.x > 0 ? data.Count.x - 1 : direction.x < 0 ? 0 : data.Count.x / 2;
            int ty = direction.y > 0 ? data.Count.y - 1 : direction.y < 0 ? 0 : data.Count.y / 2;

            data.get(tx, ty).Flyweight = door;

            tx = tx > 0 && tx < data.Count.x - 1 ? tx - 1 : tx;
            ty = ty > 0 && ty < data.Count.y - 1 ? ty - 1 : ty;
            data.get(tx, ty).Flyweight = door;
        }
Esempio n. 2
0
        public void cut_out_doors(FlyweightCollection door_prototype)
        {
            for (int x = 0; x < Count.x; x++)
            {
                for (int y = 0; y < Count.y; y++)
                {
                    if (get(x, y) == null)
                    {
                        continue;
                    }

                    var data = get(x, y);
                    if (x > 0)
                    {
                        if (get(x - 1, y) != null)
                        {
                            cut_door_at(x, y, new Vector2Int(-1, 0), door_prototype);
                        }
                    }
                    if (y > 0)
                    {
                        if (get(x, y - 1) != null)
                        {
                            cut_door_at(x, y, new Vector2Int(0, -1), door_prototype);
                        }
                    }
                    if (x < Count.x - 1)
                    {
                        if (get(x + 1, y) != null)
                        {
                            cut_door_at(x, y, new Vector2Int(1, 0), door_prototype);
                        }
                    }
                    if (y < Count.y - 1)
                    {
                        if (get(x, y + 1) != null)
                        {
                            cut_door_at(x, y, new Vector2Int(0, 1), door_prototype);
                        }
                    }
                }
            }
        }
Esempio n. 3
0
 public void set(int x, int y, FlyweightCollection that)
 {
     enemies.Add(new FlyweightsWithPosition(that, new Vector2Int(x, y)));
 }
Esempio n. 4
0
 public FlyweightsWithPosition(FlyweightCollection flyweight, Vector2Int at)
 {
     this.flyweight = flyweight;
     this.at        = at;
 }
Esempio n. 5
0
 public PrototypeData(Vector2Int index, FlyweightCollection prototype)
 {
     this.Index      = index;
     this.prototypes = prototype;
 }