コード例 #1
0
ファイル: LoadLevel1.cs プロジェクト: lyrene123/GalagaX4
        void loadCommanders(List <int> commanderInt, List <Point> commanderPoint, List <String> commanderPath, Player player)
        {
            int spaceX = 0;

            for (int i = 0; i < commanderInt.Count; i++)
            {
                if (commanderInt[i] == 1)
                {
                    commanderPic[i]        = new Image();
                    commanderPic[i].Source = UtilityMethods.LoadImageFullPath(commanderPath[i]);
                    commanderPic[i].Width  = 34;
                    commanderPic[i].Height = 26;
                    canvas.Children.Add(commanderPic[i]);
                    Canvas.SetLeft(commanderPic[i], commanderPoint[i].X + spaceX);
                    Canvas.SetTop(commanderPic[i], commanderPoint[i].Y);
                    spaceX += 90;
                    Point commanderPos = new Point();
                    commanderPos.X = commanderPoint[i].X;
                    commanderPos.Y = commanderPoint[i].Y;
                    Animation commanderAnimation = new Animation(commanderPic[i], commanderImages, true);
                    Commander commander          = new Commander(commanderPos, commanderPic[i], canvas, commanderAnimation);
                    commanders.Add(commander);
                    enemies.Add(commanders[i]);
                    commanders[i].setTarget(player);
                    commanders[i].Fly(200);
                    arr2.Add(i);
                }
            }
        }
コード例 #2
0
ファイル: LoadLevel1.cs プロジェクト: lyrene123/GalagaX4
        void loadBug(List <int> bugInt, List <Point> bugPoint, List <String> bugPath, Player player)
        {
            BitmapImage[] beeImages = { UtilityMethods.LoadImage("pics/bee0.png"),
                                        UtilityMethods.LoadImage("pics/bee1.png") };

            BitmapImage[] bugImages = { UtilityMethods.LoadImage("pics/redBug0.png"),
                                        UtilityMethods.LoadImage("pics/redBug1.png") };

            int spaceX = 0;

            Image[] beesPic = new Image[bugPath.Count];

            for (int i = 0; i < bugInt.Count; i++)
            {
                if (bugInt[i] == 2)
                {
                    if (bugPath[i].Contains("bee0.png"))
                    {
                        bees              = new Bug[beesPic.Length];
                        beesPic[i]        = new Image();
                        beesPic[i].Source = UtilityMethods.LoadImageFullPath(bugPath[i]);
                        beesPic[i].Width  = 34;
                        beesPic[i].Height = 26;
                        canvas.Children.Add(beesPic[i]);
                        Canvas.SetLeft(beesPic[i], bugPoint[i].X + spaceX);
                        Canvas.SetTop(beesPic[i], bugPoint[i].Y);
                        spaceX += 60;

                        Point beePos = new Point();
                        beePos.X = bugPoint[i].X;
                        beePos.Y = bugPoint[i].Y;
                        Animation beeAnimation = new Animation(beesPic[i], beeImages, true);
                        Bug       bee          = new Bug(beePos, beesPic[i], canvas, beeAnimation);
                        bees[i] = bee;
                        enemies.Add(bees[i]);
                        bees[i].setTarget(player);
                        bees[i].Fly(200);
                    }
                    else
                    {
                        Image[] bugsPic = new Image[beesPic.Length];
                        redbugs           = new Bug[bugsPic.Length];
                        spaceX            = 0;
                        bugsPic[i]        = new Image();
                        bugsPic[i].Width  = 34;
                        bugsPic[i].Height = 26;
                        canvas.Children.Add(bugsPic[i]);
                        Canvas.SetLeft(bugsPic[i], bugPoint[i].X + spaceX);
                        Canvas.SetTop(bugsPic[i], bugPoint[i].Y);
                        spaceX += 60;

                        Point bugPos = new Point();
                        bugPos.X = bugPoint[i].X;
                        bugPos.Y = bugPoint[i].Y;
                        Animation bugAnimation = new Animation(bugsPic[i], bugImages, true);
                        Bug       bug          = new Bug(bugPos, bugsPic[i], canvas, bugAnimation);
                        redbugs[i] = bug;
                        enemies.Add(redbugs[i]);
                        redbugs[i].setTarget(player);
                        redbugs[i].Fly(200);
                    }
                }
            }
        }
コード例 #3
0
ファイル: LoadLevel1.cs プロジェクト: lyrene123/GalagaX4
        void loadShip(List <int> shipInt, List <Point> shipPoint, List <String> shipPath, Player player)
        {
            Image[] shipsPic = new Image[shipPath.Count];
            int     spaceX   = 0;

            for (int i = 0; i < shipInt.Count; i++)
            {
                if (shipInt[i] == 0)
                {
                    if (shipPath[i].Contains("spaceShip.png"))
                    {
                        shipsPic[i]        = new Image();
                        shipsPic[i].Source = UtilityMethods.LoadImage("pics/spaceShip.png");
                        shipsPic[i].Width  = 34;
                        shipsPic[i].Height = 26;
                        canvas.Children.Add(shipsPic[i]);
                        Canvas.SetLeft(shipsPic[i], shipPoint[i].X + spaceX);
                        Canvas.SetTop(shipsPic[i], shipPoint[i].Y);
                        spaceX += 60;
                        Point shipPos = new Point();
                        shipPos.X = shipPoint[i].X;
                        shipPos.Y = shipPoint[i].Y;

                        SpaceShip ship = new SpaceShip(shipPos, shipsPic[i], canvas);
                        ships.Add(ship);
                        enemies.Add(ships[i]);
                        ships[i].setTarget(player);
                        ships[i].Fly(200);
                        // ships[i].Shoot(200);
                        arr1.Add(i);
                    }
                    else if (shipPath[i].Contains("UFO.png"))
                    {
                        Image[] ufoPics = new Image[shipInt.Count];
                        spaceX = 0;


                        ufoPics[i]        = new Image();
                        ufoPics[i].Source = UtilityMethods.LoadImageFullPath(shipPath[i]);
                        ufoPics[i].Width  = 34;
                        ufoPics[i].Height = 26;
                        canvas.Children.Add(ufoPics[i]);
                        Canvas.SetLeft(ufoPics[i], shipPoint[i].X + spaceX);
                        Canvas.SetTop(ufoPics[i], shipPoint[i].Y);
                        spaceX += 60;

                        Point ufoPos = new Point();
                        ufoPos.X = shipPoint[i].X;
                        ufoPos.Y = shipPoint[i].Y;

                        SpaceShip ufo = new SpaceShip(ufoPos, ufoPics[i], canvas);
                        ufos.Add(ufo);
                    }
                }
            }
            for (int i = 0; i < ufos.Count; i++)
            {
                enemies.Add(ufos[i]);
                ufos[i].setTarget(player);
                ufos[i].setMoveCounter(2);
                ufos[i].Fly(180);
                // ships[i].Shoot(200);
            }
        }