Ejemplo n.º 1
0
    public void DestroyAllSceneObject()
    {
        initialcords = false;

        for (int i = 0; i < SceneObjects.Count; i++)
        {
            Destroy(SceneObjects[i].gameObject);
        }
        DestroyAllBalls();
        Application.LoadLevel("MaineMenu");
        SceneObjects.Clear();
        //InitNewRound();
    }
Ejemplo n.º 2
0
 /// <summary>
 /// Should be called by implementing engine upon a scene change, if relevent
 /// </summary>
 public static void ClearSceneIDs()
 {
     SceneObjects.Clear();
 }
Ejemplo n.º 3
0
 static void ClearAll()
 {
     SceneObjects.Clear();
     roomLayers.Clear();
 }
Ejemplo n.º 4
0
        public static void __loadGameObjects(List <GameObject> objects, bool execCreateEvt = true, bool execLoadEvt = true, bool execSetupEvt = true, bool reset = true)
        {
            SceneObjects.Clear();

            foreach (RoomLayer rl in currentRoom.Layers)
            {
                if (rl is ObjectLayer)
                {
                    ObjectLayer ol = (ObjectLayer)rl;
                    ol.Objects.Clear();
                }
            }

            foreach (GameObject g in objects)
            {
                if (reset)
                {
                    g.Reset();
                }

                Spritesheet s = Sprites.FirstOrDefault(x => x.Name == g.Sprite.TextureSource);

                g.Position   = g.__DefaultPosition;
                g.ImageAngle = g.__DefaultImageAngle;
                g.Direction  = g.__DefaultDirection;
                g.ImageScale = g.__DefaultImageScale;
                g.ImageIndex = g.__DefaultImageIndex;

                g.Sprite.Texture            = s.Texture;
                g.Sprite.ImageRectangle     = new Microsoft.Xna.Framework.Rectangle(0, 0, s.CellWidth, s.CellHeight);
                g.Sprite.TextureRows        = s.Rows;
                g.Sprite.TextureCellsPerRow = s.Texture.Width / s.CellWidth;
                g.Sprite.ImageSize          = new Vector2(s.CellWidth, s.CellHeight);
                g.Sprite.FramesCount        = (s.Texture.Width / s.CellWidth) * (s.Texture.Height / s.CellHeight) - 1;
                g.FramesCount  = g.Sprite.FramesCount - 1;
                g.Sprite.cellW = s.CellHeight;
                g.Sprite.cellH = s.CellWidth;

                RoomLayer rt = currentRoom.Layers.FirstOrDefault(x => x.Name == g.LayerName);
                g.Layer = (ObjectLayer)rt;

                g.Sprite.UpdateImageRectangle();
                g.UpdateState();
                g.UpdateColliders();

                // Need to give object OriginalType !!!
                g.OriginalType = Type.GetType(g.TypeString);

                currentObject = g;

                if (execCreateEvt)
                {
                    g.EvtCreate();
                }

                if (execLoadEvt)
                {
                    g.EvtLoad();
                }

                if (execSetupEvt)
                {
                    g.EvtSetup();
                }

                SceneObjects.Add(g);
                g.Layer.Objects.Add(g);
                sh.RegisterObject(g);

                if (g.Colliders.Count > 0)
                {
                    SceneColliders.Add(g);
                }
            }

            foreach (GameObject g in SceneObjects)
            {
                g.EvtCreateEnd();
            }
        }