Esempio n. 1
0
        //This method calls the factory object to create all objects in the "objectsToCreate" list based off the string within them
        public void CallFactoryToCreate()
        {
            //Somehwere in here we need to force it to create lemmings last because they need the 5 second interval between them.
            //Other objects, spider, floor etc. can be created and drawn at the same time as the first lemming however.

            //Goes through each string object in the objectsToCreate list and makes the factory create objects based off of it.
            //The object is then added to the defaultdefaultObjectsToDraw list of parent objects.
            foreach (string obj in objectsToCreate)
            {
                if (obj.Contains("Lemming") || obj.Contains("lemming"))
                {
                    defaultObjectsToDraw.Add(factory.CreateObjects(ObjectType.Lemming));
                    sManager.AddEntitiesToScene(defaultObjectsToDraw[defaultObjectsToDraw.Count - 1]);
                }

                else if (obj.Contains("Spider"))
                {
                    defaultObjectsToDraw.Add(factory.CreateObjects(ObjectType.Spider));
                    sManager.AddEntitiesToScene(defaultObjectsToDraw[defaultObjectsToDraw.Count - 1]);
                }

                else if (obj.Contains("Floor"))
                {
                    defaultObjectsToDraw.Add(factory.CreateObjects(ObjectType.Floor));
                    sManager.AddEntitiesToScene(defaultObjectsToDraw[defaultObjectsToDraw.Count - 1]);
                }

                else if (obj.Contains("Edge_Top"))
                {
                    factory.GetEdgeType("Top");
                    defaultObjectsToDraw.Add(factory.CreateObjects(ObjectType.Edge));
                    sManager.AddEntitiesToScene(defaultObjectsToDraw[defaultObjectsToDraw.Count - 1]);
                }

                else if (obj.Contains("Edge_Bottom"))
                {
                    factory.GetEdgeType("Bottom");
                    defaultObjectsToDraw.Add(factory.CreateObjects(ObjectType.Edge));
                    sManager.AddEntitiesToScene(defaultObjectsToDraw[defaultObjectsToDraw.Count - 1]);
                }

                else if (obj.Contains("Edge_Left"))
                {
                    factory.GetEdgeType("Left");
                    defaultObjectsToDraw.Add(factory.CreateObjects(ObjectType.Edge));
                    sManager.AddEntitiesToScene(defaultObjectsToDraw[defaultObjectsToDraw.Count - 1]);
                }

                else if (obj.Contains("Edge_Right"))
                {
                    factory.GetEdgeType("Right");
                    defaultObjectsToDraw.Add(factory.CreateObjects(ObjectType.Edge));
                    sManager.AddEntitiesToScene(defaultObjectsToDraw[defaultObjectsToDraw.Count - 1]);
                }

                else if (obj.Contains("Gate"))
                {
                    defaultObjectsToDraw.Add(factory.CreateObjects(ObjectType.Gate));
                    sManager.AddEntitiesToScene(defaultObjectsToDraw[defaultObjectsToDraw.Count - 1]);
                }
            }
            objectsToCreate.Clear();

            //This code is just to force the floors to appear in a different place.
            defaultObjectsToDraw[0].position = new Vector2(85, 550);
            defaultObjectsToDraw[1].position = new Vector2(85, 300);
            defaultObjectsToDraw[2].position = new Vector2(460, 300);
            defaultObjectsToDraw[3].position = new Vector2(266, 450);
            defaultObjectsToDraw[4].position = new Vector2(430, 550);

            defaultObjectsToDraw.Clear();     //This list is only needed to help the creation of the default objects.
        }