Ejemplo n.º 1
0
        private static bool isOrgPresent(UnitMap umap, Point p, String org)
        {
            if (p.X < 0 || p.Y < 0 || p.X >= umap.NumX || p.Y >= umap.NumY)
                return false;

            if (!umap.isUnit(p.X, p.Y))
                return false;

            return umap.get(p.X, p.Y).Organization == org;
        }
Ejemplo n.º 2
0
        public static Unit[] region(UnitMap umap, Tilemap tm, String org, Map map, ref Boolean dun)
        {
            Unit u;
            Point ne;
            Point d;

            for (int i = 0; i < umap.NumX; i++)
                for (int e = 0; e < umap.NumY; e++)
                    if (umap.isUnit(i, e) && umap.get(i, e).movement > 0 && umap.get(i, e).Organization == org)
                    {
                        if (map.CursorPosition != new Point(i, e))
                        {
                            map.changeCursor(new Point(i, e));
                            return null;
                        }

                        u = umap.get(i, e);

                        if (u.hasLeader())
                        {
                            ne = nearest(umap, new Point(i, e), "main");

                            if (isAdj(new Point(i, e), ne))
                            {
                                u.movement = 0;
                                return new Unit[] { umap.get(ne.X, ne.Y), u };
                            }

                            //finds path to nearest ennemy
                            d = pathFind(umap, tm, new Point(i, e), nearest(umap, new Point(i, e), "main"), org);

                            umap.move(i, e, d.X, d.Y);
                            map.changeCursor(new Point(d.X, d.Y));

                            u.movement--;
                        }
                        return null;
                    }
            dun = true;
            return null;
        }