Example #1
0
        private void btnAdd_MouseClick(object sender, MouseEventArgs e)
        {
            selected = true;
            foreach (string name in checkedListBox1.CheckedItems)
            {
                switch (name)
                {
                    case "AntPeasant":
                        {
                            AntPeasant p = new AntPeasant(10, 10, 10, 10, 10, 10, new LoadModel(CreatorController.content.Load<Model>("Models/ant"), CreatorController.MousePosition, new Vector3(0, 6, 0), new Vector3(0.5f), CreatorController.device,CreatorController.content), 10, 100);
                            model = p;
                            model.Model.switchAnimation("Idle");

                            break;
                        }
                    case "Log":
                        {
                            Log p = new Log(new LoadModel(CreatorController.content.Load<Model>("Models/apple_pack"), CreatorController.MousePosition, Vector3.Zero, Vector3.One, CreatorController.device), Convert.ToInt16(textBox1.Text));
                            model = p;
                            break;
                        }
                    case "Rock":
                        {
                            Rock p = new Rock(new LoadModel(CreatorController.content.Load<Model>("Models/stone2"), CreatorController.MousePosition, Vector3.Zero, Vector3.One, CreatorController.device), Convert.ToInt16(textBox1.Text));
                            model = p;
                            break;
                        }
                    case "BuildingPlace":
                        {
                            BuildingPlace p = new BuildingPlace(new LoadModel(CreatorController.content.Load<Model>("Models//buildRing"), CreatorController.MousePosition, Vector3.Zero, Vector3.One, CreatorController.device));
                            model = p;
                            break;
                        }
                    case "AntGranary":
                        {
                            AntGranary p = new AntGranary(new LoadModel(CreatorController.content.Load<Model>("Models//buildingPlace"), CreatorController.MousePosition, Vector3.Zero, Vector3.One, CreatorController.device), 100, 100, 100, 23, 10000);
                            model = p;
                            break;
                        }
                    case "TownCenter":
                        {
                            Logic.Building.AntBuildings.TownCenter p = new Logic.Building.AntBuildings.TownCenter(new LoadModel(CreatorController.content.Load<Model>("Models//buildingPlace"), CreatorController.MousePosition, Vector3.Zero, Vector3.One, CreatorController.device));
                            model = p;
                            break;
                        }
                    case "Spider":
                        {
                            Spider p = new Spider(new LoadModel(CreatorController.content.Load<Model>("Models//spider"), CreatorController.MousePosition, Vector3.Zero, Vector3.One, CreatorController.device,CreatorController.content));
                            model = p;
                            model.Model.switchAnimation("Idle");

                            break;
                        }
                    case "Tree":
                        {
                            Tree p = new Tree(new LoadModel(CreatorController.content.Load<Model>("Models//tree1"), CreatorController.MousePosition, Vector3.Zero, Vector3.One, CreatorController.device));
                            model = p;
                            break;
                        }
                    case "Tree2":
                        {
                            Tree2 p = new Tree2(new LoadModel(CreatorController.content.Load<Model>("Models//tree2"), CreatorController.MousePosition, Vector3.Zero, Vector3.One, CreatorController.device));
                            model = p;
                            break;
                        }
                    case "Szyszka":
                        {
                            Cone p = new Cone(new LoadModel(CreatorController.content.Load<Model>("Models/Szyszka1"), CreatorController.MousePosition, Vector3.Zero, Vector3.One, CreatorController.device));
                            model = p;
                            break;
                        }
                    case "Szyszka2":
                        {
                            Cone1 p = new Cone1(new LoadModel(CreatorController.content.Load<Model>("Models/Szyszka2"), CreatorController.MousePosition, Vector3.Zero, Vector3.One, CreatorController.device));
                            model = p;
                            break;
                        }
                    case "Trawa":
                        {
                            Grass p = new Grass(new LoadModel(CreatorController.content.Load<Model>("Models/grass3d"), CreatorController.MousePosition, Vector3.Zero, Vector3.One, CreatorController.device));
                            model = p;
                            break;
                        }
                    case "Zuk":
                        {
                            Beetle p = new Beetle(new LoadModel(CreatorController.content.Load<Model>("Models/beetle"), CreatorController.MousePosition, Vector3.Zero, Vector3.One, CreatorController.device,CreatorController.content));
                            model = p;
                            model.Model.switchAnimation("Idle");
                            break;
                        }
                    case "Konik":
                        {
                            GrassHopper p = new GrassHopper(new LoadModel(CreatorController.content.Load<Model>("Models/grasshopper"), CreatorController.MousePosition, Vector3.Zero, Vector3.One, CreatorController.device, CreatorController.content));
                            model = p;
                            model.Model.switchAnimation("Idle");
                            break;
                        }
                    case "Plujka":
                        {
                            AntSpitter p = new AntSpitter(new LoadModel(CreatorController.content.Load<Model>("Models/plujka"), CreatorController.MousePosition, Vector3.Zero, Vector3.One, CreatorController.device, CreatorController.content));
                            model = p;
                            model.Model.switchAnimation("Idle");
                            break;
                        }
                    case "Królowa":
                        {
                            Queen p = new Queen(new LoadModel(CreatorController.content.Load<Model>("Models/queen"), CreatorController.MousePosition, Vector3.Zero, Vector3.One, CreatorController.device, CreatorController.content));
                            model = p;
                            model.Model.switchAnimation("Idle");
                            break;
                        }
                    case "Silacz":
                        {
                            StrongAnt p = new StrongAnt(new LoadModel(CreatorController.content.Load<Model>("Models/strongAnt"), CreatorController.MousePosition, Vector3.Zero, Vector3.One, CreatorController.device, CreatorController.content));
                            model = p;
                            model.Model.switchAnimation("Idle");
                            break;
                        }
                    case "DomKoników":
                        {
                            GrassHopperBuilding p = new GrassHopperBuilding(new LoadModel(CreatorController.content.Load<Model>("Models//h3"), CreatorController.MousePosition, Vector3.Zero, Vector3.One, CreatorController.device));
                            model = p;
                            break;
                        }
                    case "DomZukow":
                        {
                            BeetleBuilding p = new BeetleBuilding(new LoadModel(CreatorController.content.Load<Model>("Models//h4"), CreatorController.MousePosition, Vector3.Zero, Vector3.One, CreatorController.device));
                            model = p;
                            break;
                        }
                }
            }
        }
Example #2
0
        public void Load(string fileName)
        {
            using (Stream stream = File.Open(fileName, FileMode.Open))
            {

                var bformatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();

                List<InteractiveModel> salesman = (List<InteractiveModel>)bformatter.Deserialize(stream);
                listBox2.DataSource = null;
                if(salesman==CreatorController.models)
                {
                    return;
                }
                foreach(InteractiveModel model in salesman)
                {

                switch(model.GetType().Name)
                {
                    case "AntPeasant":
                       AntPeasant p = new AntPeasant(null);
                     p.Model = new LoadModel(CreatorController.content.Load<Model>("Models/ant"), model.Model.Position, model.Model.Rotation, model.Model.Scale, CreatorController.device,CreatorController.content);
                     p.Model.switchAnimation("Idle");
                     CreatorController.models.Add(p);
                     _items.Add(p.ToString());

                        break;
                    case "Log":

                           Log g = new Log(null,((Log)model).ClusterSize);
                           g.Model = new LoadModel(CreatorController.content.Load<Model>("Models/apple_pack"), model.Model.Position, model.Model.Rotation, model.Model.Scale, CreatorController.device);

                     CreatorController.models.Add(g);
                     _items.Add(g.ToString());

                        break;
                    case "Rock":

                           Rock q = new Rock(null,((Rock)model).ClusterSize);
                           q.Model = new LoadModel(CreatorController.content.Load<Model>("Models/stone2"), model.Model.Position, model.Model.Rotation, model.Model.Scale, CreatorController.device);

                     CreatorController.models.Add(q);
                     _items.Add(q.ToString());

                        break;
                    case "BuildingPlace":

                        BuildingPlace w = new BuildingPlace(null);
                        w.Model = new LoadModel(CreatorController.content.Load<Model>("Models/buildRing"), model.Model.Position, model.Model.Rotation, model.Model.Scale, CreatorController.device);

                        CreatorController.models.Add(w);
                        _items.Add(w.ToString());

                        break;
                    case "AntGranary":

                        AntGranary ad = new AntGranary(null);
                        ad.Model = new LoadModel(CreatorController.content.Load<Model>("Models/buildingPlace"), model.Model.Position, model.Model.Rotation, model.Model.Scale, CreatorController.device);

                        CreatorController.models.Add(ad);
                        _items.Add(ad.ToString());

                        break;

                    case "TownCenter":

                        Logic.Building.AntBuildings.TownCenter ag = new Logic.Building.AntBuildings.TownCenter(null);
                        ag.Model = new LoadModel(CreatorController.content.Load<Model>("Models/buildingPlace"), model.Model.Position, model.Model.Rotation, model.Model.Scale, CreatorController.device);

                        CreatorController.models.Add(ag);
                        _items.Add(ag.ToString());

                        break;
                    case "Spider":

                        Spider s = new Spider(new LoadModel(CreatorController.content.Load<Model>("Models//spider"), model.Model.Position, model.Model.Rotation, model.Model.Scale, CreatorController.device, CreatorController.content));
                        s.Model.switchAnimation("Idle");
                        CreatorController.models.Add(s);
                        _items.Add(s.ToString());

                        break;
                    case "Tree":

                        Tree t = new Tree(null);
                        t.Model = new LoadModel(CreatorController.content.Load<Model>("Models//tree1"), model.Model.Position, model.Model.Rotation, model.Model.Scale, CreatorController.device);

                        CreatorController.models.Add(t);
                        _items.Add(t.ToString());

                        break;
                    case "Tree2":

                        Tree2 t2 = new Tree2(null);
                        t2.Model = new LoadModel(CreatorController.content.Load<Model>("Models//tree2"), model.Model.Position, model.Model.Rotation, model.Model.Scale, CreatorController.device);

                        CreatorController.models.Add(t2);
                        _items.Add(t2.ToString());

                        break;

                    case "Cone":

                        Cone c = new Cone(null);
                        c.Model = new LoadModel(CreatorController.content.Load<Model>("Models//Szyszka1"), model.Model.Position, model.Model.Rotation, model.Model.Scale, CreatorController.device);

                        CreatorController.models.Add(c);
                        _items.Add(c.ToString());

                        break;
                    case "Cone1":

                        Cone1 c2 = new Cone1(null);
                        c2.Model = new LoadModel(CreatorController.content.Load<Model>("Models//Szyszka2"), model.Model.Position, model.Model.Rotation, model.Model.Scale, CreatorController.device);

                        CreatorController.models.Add(c2);
                        _items.Add(c2.ToString());

                        break;
                    case "Grass":

                        Grass gr = new Grass(null);
                        gr.Model = new LoadModel(CreatorController.content.Load<Model>("Models//grass3d"), model.Model.Position, model.Model.Rotation, model.Model.Scale, CreatorController.device);

                        CreatorController.models.Add(gr);
                        _items.Add(gr.ToString());

                        break;
                    case "Beetle":

                        Beetle bt = new Beetle(new LoadModel(CreatorController.content.Load<Model>("Models//beetle"), model.Model.Position, model.Model.Rotation, model.Model.Scale, CreatorController.device,CreatorController.content));
                        bt.Model.switchAnimation("Idle");
                        CreatorController.models.Add(bt);
                        _items.Add(bt.ToString());

                        break;

                    case "GrassHopper":

                        //GrassH konik = new Beetle(new LoadModel(CreatorController.content.Load<Model>("Models//beetle"), model.Model.Position, model.Model.Rotation, model.Model.Scale, CreatorController.device, CreatorController.content));
                        GrassHopper konik = new GrassHopper(new LoadModel(CreatorController.content.Load<Model>("Models//grasshopper"), model.Model.Position, model.Model.Rotation, model.Model.Scale, CreatorController.device, CreatorController.content));
                        konik.Model.switchAnimation("Idle");
                        CreatorController.models.Add(konik);
                        _items.Add(konik.ToString());

                        break;
                    case "Queen" :

                        Queen queen = new Queen(new LoadModel(CreatorController.content.Load<Model>("Models//queen"), model.Model.Position, model.Model.Rotation, model.Model.Scale, CreatorController.device, CreatorController.content));
                        queen.Model.switchAnimation("Idle");
                        CreatorController.models.Add(queen);
                        _items.Add(queen.ToString());
                        break;

                    case "AntSpitter":

                        AntSpitter spitter = new AntSpitter(new LoadModel(CreatorController.content.Load<Model>("Models//plujka"), model.Model.Position, model.Model.Rotation, model.Model.Scale, CreatorController.device, CreatorController.content));
                        spitter.Model.switchAnimation("Idle");
                        CreatorController.models.Add(spitter);
                        _items.Add(spitter.ToString());
                        break;
                    case "StrongAnt":

                        AntSpitter strongAnt = new AntSpitter(new LoadModel(CreatorController.content.Load<Model>("Models//strongAnt"), model.Model.Position, model.Model.Rotation, model.Model.Scale, CreatorController.device, CreatorController.content));
                        strongAnt.Model.switchAnimation("Idle");
                        CreatorController.models.Add(strongAnt);
                        _items.Add(strongAnt.ToString());
                        break;
                    case "GrassHopperBuilding":

                        GrassHopperBuilding ghb = new GrassHopperBuilding(new LoadModel(CreatorController.content.Load<Model>("Models/h3"), model.Model.Position, model.Model.Rotation, model.Model.Scale, CreatorController.device));
                        CreatorController.models.Add(ghb);
                        _items.Add(ghb.ToString());

                        break;
                    case "BeetleBuilding":

                        BeetleBuilding bb = new BeetleBuilding(new LoadModel(CreatorController.content.Load<Model>("Models/h4"), model.Model.Position, model.Model.Rotation, model.Model.Scale, CreatorController.device));
                        CreatorController.models.Add(bb);
                        _items.Add(bb.ToString());

                        break;

                }

            }
                listBox2.DataSource = _items;
            }
        }
        public static void Load()
        {
            System.Windows.Forms.OpenFileDialog a = new System.Windows.Forms.OpenFileDialog();
               if (a.ShowDialog() == System.Windows.Forms.DialogResult.OK)
               {
               using (Stream stream = File.Open(a.FileName, FileMode.Open))
               {

               var bformatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();

               List<InteractiveModel> salesman = (List<InteractiveModel>)bformatter.Deserialize(stream);
               foreach (InteractiveModel model in salesman)
               {
                    Console.WriteLine(model.GetType().Name);
                   switch (model.GetType().Name)
                   {
                       case "AntPeasant":
                           AntPeasant p = new AntPeasant(new LoadModel(StaticHelpers.StaticHelper.Content.Load<Model>("Models/ant"), model.Model.Position, model.Model.Rotation, model.Model.Scale, StaticHelpers.StaticHelper.Device, StaticHelpers.StaticHelper.Content, _light));
                           p.AtackInterval = 10;
                           p.Hp =300;
                           p.Model.switchAnimation("Idle");
                           listOfAllInteractiveModelsFromFile.Add(p);
                          break;
                       case "StrongAnt":
                          StrongAnt sa = new StrongAnt(new LoadModel(StaticHelpers.StaticHelper.Content.Load<Model>("Models/strongAnt"), model.Model.Position, model.Model.Rotation, model.Model.Scale, StaticHelpers.StaticHelper.Device, StaticHelpers.StaticHelper.Content, _light));
                          sa.Model.switchAnimation("Idle");

                          listOfAllInteractiveModelsFromFile.Add(sa);
                          break;
                       case "Queen":
                          Queen qq = new Queen(new LoadModel(StaticHelpers.StaticHelper.Content.Load<Model>("Models/queen"), model.Model.Position, model.Model.Rotation, model.Model.Scale, StaticHelpers.StaticHelper.Device, StaticHelpers.StaticHelper.Content, _light));
                          qq.Model.switchAnimation("Idle");

                          listOfAllInteractiveModelsFromFile.Add(qq);
                          break;
                       case "AntSpitter":
                          AntSpitter asd = new AntSpitter(new LoadModel(StaticHelpers.StaticHelper.Content.Load<Model>("Models/plujka"), model.Model.Position, model.Model.Rotation, model.Model.Scale, StaticHelpers.StaticHelper.Device, StaticHelpers.StaticHelper.Content, _light));
                          asd.Model.switchAnimation("Idle");

                          listOfAllInteractiveModelsFromFile.Add(asd);
                          break;
                       case "Log":

                          Log g = new Log(new LoadModel(StaticHelpers.StaticHelper.Content.Load<Model>("Models//apple_pack"), model.Model.Position, model.Model.Rotation, model.Model.Scale, StaticHelpers.StaticHelper.Device, _light), ((Log)model).ClusterSize);
                           g.Model.BuildBoundingSphereMaterial(3);
                           listOfAllInteractiveModelsFromFile.Add(g);

                           break;
                       case "Rock":

                           Rock q = new Rock(new LoadModel(StaticHelpers.StaticHelper.Content.Load<Model>("Models//stone2"), model.Model.Position, model.Model.Rotation, model.Model.Scale, StaticHelpers.StaticHelper.Device, _light), ((Rock)model).ClusterSize);
                            q.Model.BuildBoundingSphereMaterial(2)  ;
                           listOfAllInteractiveModelsFromFile.Add(q);

                           break;
                       case "BuildingPlace":

                           BuildingPlace w = new BuildingPlace(new LoadModel(StaticHelpers.StaticHelper.Content.Load<Model>("Models//buildRing"), model.Model.Position, model.Model.Rotation, model.Model.Scale, StaticHelpers.StaticHelper.Device, _light));
                          w.Model.BuildBoundingSphereMaterial();

                           listOfAllInteractiveModelsFromFile.Add(w);

                           break;

                       case "AntGranary":

                           AntGranary ag = new AntGranary(new LoadModel(StaticHelpers.StaticHelper.Content.Load<Model>("Models//antGranary"), model.Model.Position, model.Model.Rotation, model.Model.Scale, StaticHelpers.StaticHelper.Device, _light));
                          // ag.Model.BuildBoundingSphereMaterial();

                           listOfAllInteractiveModelsFromFile.Add(ag);

                            break;

                       case "TownCenter":

                            Logic.Building.AntBuildings.TownCenter ad = new Logic.Building.AntBuildings.TownCenter(new LoadModel(StaticHelpers.StaticHelper.Content.Load<Model>("Models//townCenter"), model.Model.Position, model.Model.Rotation, model.Model.Scale, StaticHelpers.StaticHelper.Device, _light));
                            //ad.Model.CreateBoudingBox();
                            ad.Model.BuildBoundingSphereMaterial();

                            listOfAllInteractiveModelsFromFile.Add(ad);

                            break;

                       case "Spider":

                            Spider s = new Spider(new LoadModel(StaticHelpers.StaticHelper.Content.Load<Model>("Models//spider"), model.Model.Position, model.Model.Rotation, model.Model.Scale, StaticHelpers.StaticHelper.Device,StaticHelpers.StaticHelper.Content,_light));

                            s.Model.switchAnimation("Idle");
                          //  s.Model.Animate(s.Model.Position, new Vector3(0, -MathHelper.TwoPi, 0), TimeSpan.FromSeconds(3), true);
                            listOfAllInteractiveModelsFromFile.Add(s);

                            break;
                       case "Tree":

                            Tree t = new Tree(new LoadModel(StaticHelpers.StaticHelper.Content.Load<Model>("Models//tree1"), model.Model.Position, model.Model.Rotation, model.Model.Scale, StaticHelpers.StaticHelper.Device,_light));

                         //  t.Model.BuildBoundingSphereMaterial();

                            listOfAllInteractiveModelsFromFile.Add(t);

                            break;
                     case "Tree2":

                            Tree2 t2 = new Tree2(new LoadModel(StaticHelpers.StaticHelper.Content.Load<Model>("Models//tree2"), model.Model.Position, model.Model.Rotation, model.Model.Scale, StaticHelpers.StaticHelper.Device,_light));
                           //t2.Model.BuildBoundingSphereMaterial();

                            listOfAllInteractiveModelsFromFile.Add(t2);

                            break;
                       case "Cone":

                            Cone c = new Cone(new LoadModel(StaticHelpers.StaticHelper.Content.Load<Model>("Models//Szyszka2"), model.Model.Position, model.Model.Rotation, model.Model.Scale, StaticHelpers.StaticHelper.Device, _light));

                          //  c.Model.BuildBoundingSphereMaterial();
                           // c.Model.B_Box = BoundingBox.CreateFromSphere(c.Model.Spheres[0]);
                            listOfAllInteractiveModelsFromFile.Add(c);

                           break;
                       case "Cone1":

                           Cone1 c1 = new Cone1(new LoadModel(StaticHelpers.StaticHelper.Content.Load<Model>("Models//Szyszka1"), model.Model.Position, model.Model.Rotation, model.Model.Scale, StaticHelpers.StaticHelper.Device, _light));
                         //  c1.Model.BuildBoundingSphereMaterial();

                           // c1.Model.B_Box = BoundingBox.CreateFromSphere(c1.Model.Spheres[0]);
                           listOfAllInteractiveModelsFromFile.Add(c1);

                           break;
                       case "Grass":

                           Grass gr = new Grass(new LoadModel(StaticHelpers.StaticHelper.Content.Load<Model>("Models//Szyszka2"), model.Model.Position, model.Model.Rotation, model.Model.Scale, StaticHelpers.StaticHelper.Device, _light));
                           gr.Model.BuildBoundingSphereMaterial();
                                                     // c1.Model.CreateBoudingBox();

                           listOfAllInteractiveModelsFromFile.Add(gr);

                           break;
                       case "GrassHopper":

                           GrassHopper gr1 = new GrassHopper(new LoadModel(StaticHelpers.StaticHelper.Content.Load<Model>("Models//grasshopper"), model.Model.Position, model.Model.Rotation, model.Model.Scale, StaticHelpers.StaticHelper.Device,StaticHelpers.StaticHelper.Content, _light));
                           gr1.Armor = 20;
                           gr1.ArmorAfterBuff = 40;
                        // c1.Model.CreateBoudingBox();
                           gr1.Model.switchAnimation("Idle");
                           listOfAllInteractiveModelsFromFile.Add(gr1);

                           break;
                       case "Beetle":

                           Beetle beetle = new Beetle(new LoadModel(StaticHelpers.StaticHelper.Content.Load<Model>("Models//beetle"), model.Model.Position, model.Model.Rotation, model.Model.Scale, StaticHelpers.StaticHelper.Device, StaticHelpers.StaticHelper.Content, _light));
                        //   beetle.sfereModel.Model.Scale = new Vector3(33);
                           // c1.Model.CreateBoudingBox();
                           beetle.Model.switchAnimation("Idle");
                           listOfAllInteractiveModelsFromFile.Add(beetle);

                           break;
                       case "BeetleBuilding":

                           BeetleBuilding bb = new BeetleBuilding(new LoadModel(StaticHelpers.StaticHelper.Content.Load<Model>("Models//h3"), model.Model.Position, model.Model.Rotation, model.Model.Scale, StaticHelpers.StaticHelper.Device, _light));
                           //   beetle.sfereModel.Model.Scale = new Vector3(33);
                           // c1.Model.CreateBoudingBox();
                           listOfAllInteractiveModelsFromFile.Add(bb);

                           break;
                       case "GrassHopperBuilding":

                           GrassHopperBuilding ghb = new GrassHopperBuilding(new LoadModel(StaticHelpers.StaticHelper.Content.Load<Model>("Models//h4"), model.Model.Position, model.Model.Rotation, model.Model.Scale, StaticHelpers.StaticHelper.Device,  _light));
                           //   beetle.sfereModel.Model.Scale = new Vector3(33);
                           // c1.Model.CreateBoudingBox();
                           listOfAllInteractiveModelsFromFile.Add(ghb);

                           break;

                   }

               }
               }
               }
        }