Exemplo n.º 1
0
 public CollectResources(SelectNearestByRange s)
 {
     r = s;
 }
Exemplo n.º 2
0
        public void CreateTank(string tankName, int x, int y, int angle = 0)
        {
            UCompositeGameObject tank;

            GOParams[]           p;
            SelectNearestByAngle v;

            switch (tankName)
            {
            case "scavenger":
                p = new GOParams [] {
                    new GOParams {
                        X = x, Y = y, Velocity = 2, AngularVelocity = 3
                    },
                    new GOParams {
                        X = x, Y = y, AngularVelocity = 1.5, ChargeLevel = 1000, ChargeReady = 1000, ChargeRate = 3
                    }
                };
                p[0].Par.Add("maxSide", 60);
                p[0].Mass = 75;
                p[1].Par.Add("maxSide", 60);
                p[0].Type = UnitTypes.ground;
                tank      = AddTank(new string[] { "platformSand9", "flyerSand4" }, p);
                tank.AddBehavior(new ImpactControl(), "ImpactControl");
                tank.Par.CopyPar(p[0]);
                tank.Children[0].Par.CopyPar(p[1]);
                tank.Par.HP        = 100;
                tank.Par.Resources = 100;
                tank.clicked       = new storeLeftClick();
                SelectNearestByRange s = new SelectNearestByRange(GameObjectsList);
                tank.Children[0].AddBehavior(s, "SelectNearestByRange");
                tank.AddBehavior(new CollectResources(s), "CollectResources");
                Map.ContainerSetLeftClickHandler(tank.Container, ClickType.Left, tank.Click);
                Map.ContainerSetLeftClickHandler(tank.Children[0].Container, ClickType.Left, tank.Click);

                friendly.Add(tank);
                GameObjectsList.Add(tank);
                break;

            case "allyLightTank":
                p = new GOParams [] {
                    new GOParams {
                        X = x, Y = y, Velocity = 1.75, AngularVelocity = 1
                    },
                    new GOParams {
                        X = x, Y = y, AngularVelocity = 1.5, ChargeLevel = 1000, ChargeReady = 1000, ChargeRate = 200
                    }
                };
                p[0].Par.Add("maxSide", 60);
                p[0].Type = UnitTypes.ground;
                p[0].Mass = 100;
                p[1].Par.Add("maxSide", 60);
                p[1].Range = 400;
                tank       = AddTank(new string[] { "platformSand1", "towerSand3" }, p);
                tank.AddBehavior(new ImpactControl(), "ImpactControl");
                v = new SelectNearestByAngle(enemies);
                tank.Par.CopyPar(p[0]);
                tank.Children[0].Par.CopyPar(p[1]);
                tank.Par.HP        = 100;
                tank.Par.Resources = 100;
                tank.Children[0].Par.ParString.Add("ShellName", "LightShell");
                //добавить танк в списки союзников и игровых обьектов
                // слежение за целью и выстрел для башни
                tank.Children[0].AddBehavior(v, "SelectNearestByAngle");
                tank.Children[0].AddBehavior(new RotateTo(v, 1), "RotateTo");
                tank.Children[0].AddBehavior(new ShootWhenAimed(v, "LightShell", enemies), "ShootWhenAimed");
                tank.Children[0].AddBehavior(new Reloading(), "Reloading");
                //tank.Children[0].AddBehavior(new SynchronizeCoords(tank.Par), "SynchronizeCoords");
                tank.clicked = new storeLeftClick();
                Map.ContainerSetLeftClickHandler(tank.Container, ClickType.Left, tank.Click);
                Map.ContainerSetLeftClickHandler(tank.Children[0].Container, ClickType.Left, tank.Click);
                friendly.Add(tank);
                GameObjectsList.Add(tank);
                break;

            case "allyMediumTank":
                p = new GOParams [] {
                    new GOParams {
                        X = x, Y = y, Velocity = 0.8, AngularVelocity = 0.8
                    },
                    new GOParams {
                        X = x, Y = y, AngularVelocity = 1.1, ChargeLevel = 1200, ChargeReady = 1200, ChargeRate = 10
                    }
                };
                p[0].Par.Add("maxSide", 80);
                p[0].Type = UnitTypes.ground;
                p[0].Mass = 200;
                p[1].Par.Add("maxSide", 80);
                tank = AddTank(new string[] { "platformSand3", "towerSand4" }, p);
                v    = new SelectNearestByAngle(enemies);
                tank.Children[0].Par.ParString.Add("ShellName", "ArmorPiercing");
                p[1].Range = 500;
                tank.Par.CopyPar(p[0]);
                tank.Children[0].Par.CopyPar(p[1]);
                tank.AddBehavior(new ImpactControl(), "ImpactControl");
                tank.Par.HP        = 500;
                tank.Par.Resources = 200;
                //добавить танк в списки союзников и игровых обьектов
                // слежение за целью и выстрел для башни
                tank.Children[0].AddBehavior(v, "SelectNearestByAngle");
                tank.Children[0].AddBehavior(new RotateTo(v, 1), "RotateTo");
                tank.Children[0].AddBehavior(new ShootWhenAimed(v, "ArmorPiercing", enemies), "ShootWhenAimed");
                tank.Children[0].AddBehavior(new Reloading(), "Reloading");
                //tank.Children[0].AddBehavior(new SynchronizeCoords(tank.Par), "SynchronizeCoords");
                tank.clicked = new storeLeftClick();
                Map.ContainerSetLeftClickHandler(tank.Container, ClickType.Left, tank.Click);
                Map.ContainerSetLeftClickHandler(tank.Children[0].Container, ClickType.Left, tank.Click);
                friendly.Add(tank);
                GameObjectsList.Add(tank);
                break;

            case "Baneblade":
            {
                p = new GOParams[] {
                    new GOParams {
                        X = x, Y = y, Velocity = 0.8, AngularVelocity = 0.8
                    },
                    new GOParams {
                        X = x, Y = y, AngularVelocity = 1.1, ChargeLevel = 1200, ChargeReady = 1200, ChargeRate = 15, Range = 500
                    },
                    new GOParams {
                        X = x, Y = y, AngularVelocity = 1.1, ChargeLevel = 1200, ChargeReady = 1200, ChargeRate = 15, Range = 500
                    },
                    new GOParams {
                        X = x, Y = y, AngularVelocity = 1.1, ChargeLevel = 1200, ChargeReady = 1200, ChargeRate = 15, Range = 500
                    },
                    new GOParams {
                        X = x, Y = y, AngularVelocity = 1.1, ChargeLevel = 1200, ChargeReady = 1200, ChargeRate = 15, Range = 500
                    },
                    new GOParams {
                        X = x, Y = y, AngularVelocity = 1, ChargeLevel = 1200, ChargeReady = 1200, ChargeRate = 7, Range = 750
                    }
                };
                p[0].HP   = 5000;
                p[0].Mass = 99999;
                p[0].Par.Add("maxSide", 200);
                p[1].Par.Add("maxSide", 120);
                p[2].Par.Add("maxSide", 120);
                p[3].Par.Add("maxSide", 120);
                p[4].Par.Add("maxSide", 120);
                p[5].Par.Add("maxSide", 200);
                tank = AddBaneBlade(new string[] { "platformSand6", "towerSand4", "towerSand5" }, p);
                tank.Par.CopyPar(p[0]);
                p[0].Type          = UnitTypes.ground;
                tank.clicked       = new storeLeftClick();
                tank.Par.Resources = 1000;
                for (int i = 0; i < 4; i++)
                {
                    v = new SelectNearestByAngle(enemies);
                    tank.Children[i].Par.CopyParWithoutPosition(p[i + 1]);
                    tank.Children[i].AddBehavior(v, "SelectNearestByAngle");
                    tank.Children[i].AddBehavior(new RotateTo(v, 1), "RotateTo");
                    tank.Children[i].AddBehavior(new ShootWhenAimed(v, "ArmorPiercing", enemies), "ShootWhenAimed");
                    tank.Children[i].AddBehavior(new Reloading(), "Reloading");
                    Map.ContainerSetLeftClickHandler(tank.Children[i].Container, ClickType.Left, tank.Click);
                }
                tank.AddBehavior(new ImpactControl(), "ImpactControl");
                v = new SelectNearestByAngle(enemies);
                tank.Children[4].Par.CopyParWithoutPosition(p[5]);
                tank.Children[4].AddBehavior(v, "SelectNearestByAngle");
                tank.Children[4].AddBehavior(new RotateTo(v, 1), "RotateTo");
                tank.Children[4].AddBehavior(new ShootWhenAimed(v, "Ripper", enemies), "ShootWhenAimed");
                tank.Children[4].AddBehavior(new Reloading(), "Reloading");
                Map.ContainerSetLeftClickHandler(tank.Children[4].Container, ClickType.Left, tank.Click);
                Map.ContainerSetLeftClickHandler(tank.Container, ClickType.Left, tank.Click);
                friendly.Add(tank);
                GameObjectsList.Add(tank);
                break;
            }

            case "enemyLightTank":
                p = new GOParams [] {
                    new GOParams {
                        X = x, Y = y, Velocity = 1, AngularVelocity = 1
                    },
                    new GOParams {
                        X = x, Y = y, AngularVelocity = 3.5, ChargeLevel = 1000, ChargeReady = 1000, ChargeRate = 100
                    }
                };
                p[0].Par.Add("maxSide", 60);
                p[0].Mass = 100;
                p[1].Par.Add("maxSide", 90);
                p[1].Range = 400;
                p[0].Type  = UnitTypes.ground;
                p[0].HP    = 100;
                tank       = AddTank(new string[] { "platformRed3", "towerRed3" }, p);
                v          = new SelectNearestByAngle(friendly);
                tank.Par.CopyPar(p[0]);
                tank.Children[0].Par.CopyPar(p[1]);
                tank.Par.Resources        = 100;
                tank.destroyedPictureName = "platformRedDestroyed3";
                //добавить танк в списки союзников и игровых обьектов
                // слежение за целью и выстрел для башни
                tank.AddBehavior(new EnemyLightTankAI(friendly), "EnemyLightTankAI");
                tank.AddBehavior(new ImpactControl(), "ImpactControl");
                //tank.Children[0].AddBehavior(v, "SelectNearestByAngle");
                //tank.Children[0].AddBehavior(new RotateTo(v), "RotateTo");
                //tank.Children[0].AddBehavior(new ShootWhenAimed(v, "LightShell", friendly), "ShootWhenAimed");
                tank.Children[0].AddBehavior(new Reloading(), "Reloading");

                ////tank.Children[0].AddBehavior(new SynchronizeCoords(tank.Par), "SynchronizeCoords");
                Map.ContainerSetLeftClickHandler(tank.Container, ClickType.Right, tank.RightClick);
                Map.ContainerSetLeftClickHandler(tank.Children[0].Container, ClickType.Right, tank.RightClick);
                //tank.AddBehavior(new Patrol(5, true, new DoubleCoordinate(800, 100),
                //  new DoubleCoordinate(100, 200), new DoubleCoordinate(500, 500)), "Patrol");
                //tank.AddBehavior(new Patrol(5, true, new DoubleCoordinate(100, 100),
                //    new DoubleCoordinate(100, 200), new DoubleCoordinate(500, 500)), "Patrol");
                enemies.Add(tank);
                GameObjectsList.Add(tank);

                break;
            }
        }