Esempio n. 1
0
        public void Notice(GameMap gameMap, List<Fighter> fighters, List<Enemy> enemies)
        {
            foreach (var f in fighters)
            {
                if (!f.IsAlive) continue;

                List<Vector2> points = new List<Vector2>();
                points.Add(Vector2.Zero);
                Vector2 v = new Vector2(f.position.X - position.X, f.position.Y - position.Y);
                if (v != Vector2.Zero)
                    v.Normalize();
                points.Add(new Vector2(20*v.X,20*v.Y));
                boundaries = Boundaries.CreateFromPoints(points);

                Vector2 current = new Vector2(position.X, position.Y);
                bool intersects = false;
                int i = 0, j = 0;
                while (!current.Similar(f.position, 5) && i>= 0 && j>=0)
                {
                    i = (int)current.GetMapPosition(gameMap).X;
                    j = (int)current.GetMapPosition(gameMap).Y;

                    foreach (var mo in gameMap[i,j].mapObjects)
                        if (mo.boundaries.Intersects(boundaries + current))
                            intersects = true;

                    if (intersects)
                        break;

                    current += v * 5;
                }

                if (!intersects)
                {
                    aware = true;
                    this.moveStrategy = new PathFind(gameMap, fighters, enemies, this, f);
                    target = f;
                    break;
                }

            }
        }
Esempio n. 2
0
        public GameManager(Difficulty difficulty, ScreenManager screenManager) : this()
        {
            this.difficulty    = difficulty;
            this.screenManager = screenManager;

            //int tileCount = 50;
            //camera.Zoom = screenManager.Settings.Resolution.Y / tileCount / GameMap.TileShift.Y * 2;

            content = screenManager.Game.Content;

            Level1();

            GameInterface = new GameInterface();
            GameInterface.Load(content);

            Fighters       = new List <Fighter>();
            Enemies        = new List <Enemy>();
            Bonuses        = new List <Bonus>();
            Missiles       = new List <Missile>();
            weaponsArsenal = new Dictionary <Weapon, int>();

            //FileManager fileManager = new FileManager();
            //fileManager.Serialize<GameManager>(@"mission1", this);



            Fighter a = new Fighter(true, new Vector2(700f, 700f), camera);

            a.Load(content);
            a.moveStrategy = new GotoPoint(GameMap, Fighters, Enemies, a);

            Fighter b = new Fighter(false, new Vector2(730f, 730f), camera);

            b.Load(content);
            b.moveStrategy = new Follow(GameMap, Fighters, Enemies, b, a);

            Fighter c = new Fighter(false, new Vector2(760f, 760f), camera);

            c.Load(content);
            c.moveStrategy = new Follow(GameMap, Fighters, Enemies, c, b);

            Fighter d = new Fighter(false, new Vector2(790f, 790f), camera);

            d.Load(content);
            d.moveStrategy = new Follow(GameMap, Fighters, Enemies, d, c);

            Fighter e = new Fighter(false, new Vector2(820f, 820f), camera);

            e.Load(content);
            e.moveStrategy = new Follow(GameMap, Fighters, Enemies, e, d);

            Fighters.Add(a);
            Fighters.Add(b);
            Fighters.Add(c);
            Fighters.Add(d);
            Fighters.Add(e);

            camera.Pos = a.position;

            Enemy A = new Enemy(new Vector2(30f, 43f), camera);

            A.Load(content);
            A.moveStrategy = new Patrol(GameMap, Fighters, Enemies, A, new Vector2(100f, 50f), new Vector2(170f, 80f), 1.4f);

            Enemies.Add(A);

            A = new Enemy(new Vector2(40f, 23f), camera);
            A.Load(content);
            A.moveStrategy = new Patrol(GameMap, Fighters, Enemies, A, new Vector2(30f, 120f), new Vector2(170f, 80f), 1.7f);

            Enemies.Add(A);

            A = new Enemy(new Vector2(40f, 55f), camera);
            A.Load(content);
            A.moveStrategy = new Patrol(GameMap, Fighters, Enemies, A, new Vector2(40f, 20f), new Vector2(100f, 10f), 2.3f);

            Enemies.Add(A);

            Vector2 v;

            GameMap.CreateAdvancedGraph(Fighters, Enemies, new Vector2(100, 140), new Vector2(120, 130), out v);
        }
Esempio n. 3
0
        public GameManager(Difficulty difficulty,ScreenManager screenManager)
            : this()
        {
            this.difficulty = difficulty;
            this.screenManager = screenManager;

            //int tileCount = 50;
            //camera.Zoom = screenManager.Settings.Resolution.Y / tileCount / GameMap.TileShift.Y * 2;

            content = screenManager.Game.Content;

            Level1();

            GameInterface = new GameInterface();
            GameInterface.Load(content);

            Fighters = new List<Fighter>();
            Enemies = new List<Enemy>();
            Bonuses = new List<Bonus>();
            Missiles = new List<Missile>();
            weaponsArsenal = new Dictionary<Weapon,int>();

            //FileManager fileManager = new FileManager();
            //fileManager.Serialize<GameManager>(@"mission1", this);

            Fighter a = new Fighter(true, new Vector2(700f,700f), camera);
            a.Load(content);
            a.moveStrategy = new GotoPoint(GameMap, Fighters, Enemies, a);

            Fighter b = new Fighter(false, new Vector2(730f, 730f), camera);
            b.Load(content);
            b.moveStrategy = new Follow(GameMap, Fighters, Enemies, b, a);

            Fighter c = new Fighter(false, new Vector2(760f, 760f), camera);
            c.Load(content);
            c.moveStrategy = new Follow(GameMap, Fighters, Enemies, c, b);

            Fighter d = new Fighter(false, new Vector2(790f, 790f), camera);
            d.Load(content);
            d.moveStrategy = new Follow(GameMap, Fighters, Enemies, d, c);

            Fighter e = new Fighter(false, new Vector2(820f, 820f), camera);
            e.Load(content);
            e.moveStrategy = new Follow(GameMap, Fighters, Enemies, e, d);

            Fighters.Add(a);
            Fighters.Add(b);
            Fighters.Add(c);
            Fighters.Add(d);
            Fighters.Add(e);

            camera.Pos = a.position;

            Enemy A = new Enemy(new Vector2(30f, 43f), camera);
            A.Load(content);
            A.moveStrategy = new Patrol(GameMap, Fighters, Enemies, A, new Vector2(100f, 50f), new Vector2(170f, 80f), 1.4f);

            Enemies.Add(A);

            A = new Enemy(new Vector2(40f, 23f), camera);
            A.Load(content);
            A.moveStrategy = new Patrol(GameMap, Fighters, Enemies, A, new Vector2(30f, 120f), new Vector2(170f, 80f), 1.7f);

            Enemies.Add(A);

            A = new Enemy(new Vector2(40f, 55f), camera);
            A.Load(content);
            A.moveStrategy = new Patrol(GameMap, Fighters, Enemies, A, new Vector2(40f, 20f), new Vector2(100f, 10f), 2.3f);

            Enemies.Add(A);
        }