Beispiel #1
0
 public void Initialize()
 {
     StaticObjects.Clear();
     DynamicObjects.Clear();
     NonCollidableObjects.Clear();
     dynamicLoader.Initialize();
 }
        // Reloads the level and reinitializes Mario to his default state.
        public void Reset()
        {
            Enemies.Clear();
            Blocks.Clear();
            Pipes.Clear();
            Coins.Clear();
            Checkpoints.Clear();
            Flagpoles.Clear();
            levelData.Clear();

            InvisibleBarrier = new InvisibleBarrier(Vector2.Zero);
            CoinRoomPosition = Vector2.Zero;

            DynamicObjects.Clear();
            StaticObjects.Clear();

            PowerUpState = false;

            Mario.Instance.ResetPlayer();

            SoundManager.Instance.gameOverPlayOnce = true;

            levelData = ParseLevelCSV(fileName);
            BuildLevel(levelData);
        }
Beispiel #3
0
        // Update world physics
        public void Update(float dt)
        {
            // Update the position of each rigid body & texture
            foreach (PhysObject po in DynamicObjects)
            {
                po.RigidBody.Update(dt, this, po);
                po.TexturePos = new Vector2(po.RigidBody.Position.X - (po.RigidBody.Width / 2), po.RigidBody.Position.Y - (po.RigidBody.Height / 2));
                po.Position   = po.RigidBody.Position;

                if (po.IsTarget)
                {
                    if (Math.Abs(po.RigidBody.LinearVelocity.X) != _portalSpeed)
                    {
                        po.RigidBody.LinearVelocity = new Vector2(Math.Sign(po.RigidBody.LinearVelocity.X) * _portalSpeed, po.RigidBody.LinearVelocity.Y);
                    }
                }

                if (po is Projectile)
                {
                    if (Math.Abs(po.RigidBody.LinearVelocity.Length()) != _projectileSpeed)
                    {
                        po.RigidBody.LinearVelocity = Vector2.Normalize(po.RigidBody.LinearVelocity);
                        po.RigidBody.LinearVelocity = new Vector2(po.RigidBody.LinearVelocity.X * _projectileSpeed, po.RigidBody.LinearVelocity.Y * _projectileSpeed);
                    }
                }

                if (po.MarkedForDeletion)
                {
                    DeletionList.Add(po);
                }
            }

            foreach (PhysObject po in StaticObjects)
            {
                if (po is MovingPlatform || po is Pendulum)
                {
                    po.RigidBody.Update(dt, this, po);
                    po.TexturePos = new Vector2(po.RigidBody.Position.X - (po.RigidBody.Width / 2), po.RigidBody.Position.Y - (po.RigidBody.Height / 2));
                    po.Position   = po.RigidBody.Position;
                }
            }

            // Delete objects marked for deletion
            for (int i = 0; i < DeletionList.Count; i++)
            {
                DynamicObjects.Remove(DeletionList[i]);
                AllPhysObjects.Remove(DeletionList[i]);

                if (DeletionList[i] is Character)
                {
                    World.Enemies.Remove((Character)DeletionList[i]);
                }

                DeletionList[i] = null;
            }
            DeletionList.Clear();

            CollisionDetection();
        }
        public void TestObject()
        {
            var obj = new { a = 1, b = "2" };
            dynamic d = new DynamicObjects(obj);

            var z = d.a;

            Assert.AreEqual(1, z);
        }
Beispiel #5
0
        public void TestObject()
        {
            var     obj = new { a = 1, b = "2" };
            dynamic d   = new DynamicObjects(obj);

            var z = d.a;

            Assert.AreEqual(1, z);
        }
Beispiel #6
0
 public void AddDynamicObject(IDynamicObject dynamicObject)
 {
     dynamicObject.ParentSimulation = this;
     if (dynamicObject.Name == string.Empty)
     {
         _name = dynamicObject.GetType().ToString() + DynamicObjects.Count.ToString() ?? "0";
     }
     DynamicObjects.Add(dynamicObject);
 }
Beispiel #7
0
        public void TestArray()
        {
            string[] a = new string[] { "a", "b", "c" };

            dynamic d = new DynamicObjects(a);


            Assert.AreEqual("a", d[0]);
        }
        public void TestArray()
        {
            string[] a = new string[] { "a", "b", "c" };

            dynamic d = new DynamicObjects(a);


            Assert.AreEqual("a", d[0]);
        }
Beispiel #9
0
        public void TestIDic()
        {
            var dic = new Dictionary <string, object> {
                { "a", 1 }, { "b", 2 }
            };

            dynamic d = new DynamicObjects(dic);

            Assert.AreEqual(1, d.a);
        }
Beispiel #10
0
        /// <summary>
        /// ПОлучение ширины поля
        /// </summary>
        /// <returns></returns>
        public int GetMaxX()
        {
            int iStaticMaxX =
                StaticObjects.Max(p => p.Location.X);
            int iDynamicMaxX =
                DynamicObjects.Max(p => p.Location.X);

            return(iStaticMaxX > iDynamicMaxX
        ? iStaticMaxX
        : iDynamicMaxX);
        }
Beispiel #11
0
        /// <summary>
        /// ПОлучение высоты поля
        /// </summary>
        /// <returns></returns>
        public int GetMaxY()
        {
            int iStaticMaxY =
                StaticObjects.Max(p => p.Location.Y);
            int iDynamicMaxY =
                DynamicObjects.Max(p => p.Location.Y);

            return(iStaticMaxY > iDynamicMaxY
        ? iStaticMaxY
        : iDynamicMaxY);
        }
Beispiel #12
0
        private void KassaForm_Load(object sender, EventArgs e)
        {
            dynamicClass.aggregateKassaForm = this;
            dynamicClass.KassaFormFill();
            Thread thread = new Thread(dgvSelecionFill);

            thread.Start();
            DynamicObjects classDynamicObjects = new DynamicObjects();

            classDynamicObjects.aggregateKassaForm = this;
            classDynamicObjects.KassaFormFill();
        }
Beispiel #13
0
 private void MoveToCollidable(IObject gameObject)
 {
     NonCollidableObjects.Remove(gameObject);
     if (gameObject is IDynamic)
     {
         DynamicObjects.Add((IDynamic)gameObject);
     }
     if (gameObject is IStatic)
     {
         StaticObjects.Add((IStatic)gameObject);
     }
 }
Beispiel #14
0
        public void CreateObject(Type type, Vector2 position)
        {
            IObject obj = (IObject)Activator.CreateInstance(type, position);

            if (obj is IStatic)
            {
                StaticObjects.Add((IStatic)obj);
            }
            if (obj is IDynamic)
            {
                DynamicObjects.Add((IDynamic)obj);
            }
        }
        internal object FindObjectById(string id, string idstr)
        {
            var obj = _staticObjects.FirstOrDefault(x => x.Key == idstr + id);

            if (obj.Value == null)
            {
                obj = DynamicObjects.FirstOrDefault(x => x.Key == idstr + id);
            }
            if (obj.Value == null)
            {
                _logger.Warn("Could not find object with id {0}", id);
            }
            return(obj.Value);
        }
Beispiel #16
0
        public void TestMethod12()
        {
            var list = new[] { 100, 2, 3, 4 };

            var obj = list.Select(x => new
            {
                l = new { a = x, b = x }
            });

            dynamic d = new DynamicObjects(obj);

            var z = d[0].l.a;

            Assert.AreEqual(100, z);
        }
Beispiel #17
0
        public void TestMethod1()
        {
            var list = new[] { 1, 2, 3, 4 };

            var obj = list.Select(x => new
            {
                x
            });

            dynamic d = new DynamicObjects(obj);

            var z = d[0].x;

            Assert.AreEqual(1, z);
        }
        public void TestMethod1()
        {
            var list = new[] { 1, 2, 3, 4 };

            var obj = list.Select(x => new
            {
                x
            });

            dynamic d = new DynamicObjects(obj);

            var z = d[0].x;

            Assert.AreEqual(1, z);

        }
        public void TestMethod12()
        {
            var list = new[] { 100, 2, 3, 4 };

            var obj = list.Select(x => new
            {
                l = new { a = x, b = x }
            });

            dynamic d = new DynamicObjects(obj);

            var z = d[0].l.a;

            Assert.AreEqual(100, z);

        }
Beispiel #20
0
        public void GroupbyTest()
        {
            var list = new[] { 100, 2, 3, 4 };

            var obj = list.Select(x => new
            {
                l = new { a = x, b = x, c = 9 }
            }).GroupBy(x => new { x.l.a, x.l.b });

            dynamic d = new DynamicObjects(obj);


            var key = d[0];
            var v   = key[0];
            var w   = v.l;
            var l   = w.a;
        }
    //places an object mentioned within files section.//
    void placeDObject(string objName, string name, string x, string y, string z)
    {
        UnityEngine.Debug.Log("placing object...");
        objName = objName.Replace("\"", "");
        name    = name.Replace("\"", "");
        //check for availability of object(objName).
        int index = -1;

        for (int i = 0; i < Data.files.Count; i++)
        {
            if (Data.files[i].rcname == objName)
            {
                index = i; break;
            }
        }
        if (index < 0)
        {
            UnityEngine.Debug.Log(objName + " does not exist!!!"); return;
        }

        //check for redundant names.
        string suffix = "";

        for (int i = 0, count = 0; i < Data.dObjects.Count; i++)
        {
            if (Data.dObjects[i].rcname == name + suffix)
            {
                UnityEngine.Debug.Log(name + " already exists!!!"); return; count++; suffix = count.ToString(); i = 0;
            }
        }
        name += suffix;

        //instantiate a new object and push it in stack.//
        float _x = float.Parse(x);
        float _y = float.Parse(y);
        float _z = float.Parse(z);

        UnityEngine.GameObject obj = UnityEngine.GameObject.Instantiate(Data.files[index].file);
        obj.transform.position = new UnityEngine.Vector3(_x, _y, _z);
        DynamicObjects dobj = new DynamicObjects();

        dobj.rcname     = name;
        dobj.gameObject = obj;
        Data.dObjects.Add(dobj);
    }
        public void GroupbyTest()
        {
            var list = new[] { 100, 2, 3, 4 };

            var obj = list.Select(x => new
            {
                l = new { a = x, b = x, c = 9 }
            }).GroupBy(x => new { x.l.a, x.l.b });

            dynamic d = new DynamicObjects(obj);


            var key = d[0];
            var v = key[0];
            var w = v.l;
            var l = w.a;


        }
        private void btVhod_Click(object sender, EventArgs e)
        {
            Registry_Class registry = new Registry_Class();

            //registry.Registry_Set("31.31.198.31", "u0695785_TatarBase", "u0695785_TatarBase", "TatarBase123IIL");
            Authoriz(tbLogin.Text, tbPass.Text);
            if (Role_ID != 0)
            {
                switch (Role_ID)
                {
                case 6:

                    DynamicObjects classDynamicObjects = new DynamicObjects();
                    classDynamicObjects.MainFormFill(false, true, false, false, false, false);
                    break;
                }
                MainForm mainFrm = new MainForm();
                this.Hide();
                mainFrm.Show();
            }
        }
Beispiel #24
0
        public void MainForm_Load(object sender, EventArgs e)
        {
            DynamicObjects classDynamicObjects = new DynamicObjects();

            classDynamicObjects.aggregateMainForm = this;
            switch (AuthorizForm.Role_ID)
            {
            case 1:
                classDynamicObjects.MainFormFill(false, false, false, false, true, false);
                break;

            case 2:

                classDynamicObjects.MainFormFill(false, false, true, false, false, false);
                break;

            case 3:

                classDynamicObjects.MainFormFill(true, false, false, false, false, false);
                break;

            case 4:

                classDynamicObjects.MainFormFill(false, false, false, true, false, false);
                break;

            case 5:

                classDynamicObjects.MainFormFill(true, true, true, true, true, true);
                break;

            case 6:

                classDynamicObjects.MainFormFill(false, false, false, false, false, false);
                break;
            }
        }
Beispiel #25
0
 public void SetMario(IMario mario)
 {
     Mario = mario;
     DynamicObjects.Add(mario);
 }
Beispiel #26
0
        // Create platforms & environment
        private void CreateEnvironment(GraphicsDevice g)
        {
            #region Create Player & Target
            // First objects to create are the player and the target
            Player          = new Character(true);
            Player.Position = new Vector2(_nearEdge + 32, _bottomEdge - 128);
            Player.IsPlayer = true;
            RigidBody playerBody = Player.RigidBody;
            playerBody.Position         = Player.Position;
            playerBody.Width            = 32;
            playerBody.Height           = 32;
            playerBody.CollidableObject = new BoxCollider();
            Player.TexturePos           = new Vector2(Player.Position.X - playerBody.Width / 2, Player.Position.Y - playerBody.Height / 2);
            DynamicObjects.Add(Player);
            AllPhysObjects.Add(Player);

            Target            = new PhysObject();
            Target.Position   = new Vector2(_farEdge / 2, _bottomEdge - 256);
            Target.IsTarget   = true;
            Target.Elasticity = 1;
            RigidBody targetBody = Target.RigidBody;
            targetBody.Mass                      = 100.0f;
            targetBody.Position                  = Target.Position;
            targetBody.Width                     = 32;
            targetBody.Height                    = 32;
            targetBody.CollidableObject          = new BoxCollider();
            targetBody.CollidableObject.IsCircle = true;
            targetBody.AffectedByPhysics         = false;
            targetBody.IgnoreGravity             = true;

            float targetYVelocity = ((float)World.RandomGen.Next(3, 7) / 10.0f);
            if (World.RandomGen.Next(0, 1) == 0)
            {
                targetYVelocity *= -1;
            }
            float targetXVelocity = ((float)World.RandomGen.Next(3, 7) / 10.0f);
            if (World.RandomGen.Next(0, 1) == 0)
            {
                targetXVelocity *= -1;
            }
            targetBody.LinearVelocity = new Vector2(targetXVelocity * _portalSpeed, targetYVelocity * _portalSpeed);

            Target.TexturePos = new Vector2(targetBody.Position.X - targetBody.Width / 2, targetBody.Position.X - targetBody.Height / 2);
            DynamicObjects.Add(Target);
            AllPhysObjects.Add(Target);
            #endregion

            #region Edges
            // EDGES - Create the far left walls
            PhysObject block = new PhysObject();
            block.Position = new Vector2(_nearEdge - 480, _bottomEdge / 2);
            RigidBody body = block.RigidBody;
            body.Mass             = _maximumMass;
            body.IgnoreGravity    = true;
            body.IsDynamic        = false;
            body.Position         = block.Position;
            body.Width            = _farEdge / 2;
            body.Height           = _bottomEdge;
            body.CollidableObject = new BoxCollider();
            StaticObjects.Add(block);
            AllPhysObjects.Add(block);

            // EDGES - Create the far right wall
            block                 = new PhysObject();
            block.Position        = new Vector2(_farEdge + 480, _bottomEdge / 2);
            body                  = block.RigidBody;
            body.Mass             = _maximumMass;
            body.IgnoreGravity    = true;
            body.IsDynamic        = false;
            body.Position         = block.Position;
            body.Width            = _farEdge / 2;
            body.Height           = _bottomEdge;
            body.CollidableObject = new BoxCollider();
            StaticObjects.Add(block);
            AllPhysObjects.Add(block);

            // EDGES - Create the main floor
            block                 = new PhysObject();
            block.Position        = new Vector2(_farEdge / 2, _bottomEdge + 480);
            body                  = block.RigidBody;
            body.Mass             = _maximumMass;
            body.IgnoreGravity    = true;
            body.IsDynamic        = false;
            body.Position         = block.Position;
            body.Width            = 4096;
            body.Height           = 1024;
            body.CollidableObject = new BoxCollider();
            StaticObjects.Add(block);
            AllPhysObjects.Add(block);

            // EDGES - Create the roof
            block                 = new PhysObject();
            block.Position        = new Vector2(_farEdge / 2, _topEdge - 480);
            body                  = block.RigidBody;
            body.Mass             = _maximumMass;
            body.IgnoreGravity    = true;
            body.IsDynamic        = false;
            body.Position         = block.Position;
            body.Width            = 4096;
            body.Height           = 1024;
            body.CollidableObject = new BoxCollider();
            StaticObjects.Add(block);
            AllPhysObjects.Add(block);
            #endregion

            #region Platforms - Tier 0
            // Platform
            block                 = new PhysObject();
            block.Position        = new Vector2(_nearEdge + 320, _bottomEdge - 32);
            body                  = block.RigidBody;
            body.Mass             = _maximumMass;
            body.IgnoreGravity    = true;
            body.IsDynamic        = false;
            body.Position         = block.Position;
            body.Width            = 640;
            body.Height           = 64;
            body.CollidableObject = new BoxCollider();
            StaticObjects.Add(block);
            AllPhysObjects.Add(block);


            // Platform
            block                 = new PhysObject();
            block.Position        = new Vector2(_farEdge - 320, _bottomEdge - 32);
            body                  = block.RigidBody;
            body.Mass             = _maximumMass;
            body.IgnoreGravity    = true;
            body.IsDynamic        = false;
            body.Position         = block.Position;
            body.Width            = 640;
            body.Height           = 64;
            body.CollidableObject = new BoxCollider();
            StaticObjects.Add(block);
            AllPhysObjects.Add(block);
            #endregion

            #region Platforms - Tier 1
            // Platform
            block                 = new PhysObject();
            block.Position        = new Vector2(_nearEdge + 256, _bottomEdge - 240);
            body                  = block.RigidBody;
            body.Mass             = _maximumMass;
            body.IgnoreGravity    = true;
            body.IsDynamic        = false;
            body.Position         = block.Position;
            body.Width            = 256;
            body.Height           = 32;
            body.CollidableObject = new BoxCollider();
            StaticObjects.Add(block);
            AllPhysObjects.Add(block);

            // Moving Platform
            block = new MovingPlatform(new Vector2(_nearEdge + 256, _bottomEdge - 144),
                                       new Vector2(_nearEdge + 192, _bottomEdge - 144),
                                       new Vector2(_nearEdge + (_farEdge / 2) - 160, _bottomEdge - 144),
                                       new Vector2(100, 0));
            body                  = block.RigidBody;
            body.Mass             = _maximumMass;
            body.IgnoreGravity    = true;
            body.IsDynamic        = false;
            body.Position         = block.Position;
            body.Width            = 256;
            body.Height           = 32;
            body.CollidableObject = new BoxCollider();
            StaticObjects.Add(block);
            AllPhysObjects.Add(block);

            // Moving Platform
            block = new MovingPlatform(new Vector2(_farEdge - 256, _bottomEdge - 144),
                                       new Vector2((_farEdge / 2) + 160, _bottomEdge - 144),
                                       new Vector2(_farEdge - 192, _bottomEdge - 144),
                                       new Vector2(-100, 0));
            body                  = block.RigidBody;
            body.Mass             = _maximumMass;
            body.IgnoreGravity    = true;
            body.IsDynamic        = false;
            body.Position         = block.Position;
            body.Width            = 256;
            body.Height           = 32;
            body.CollidableObject = new BoxCollider();
            StaticObjects.Add(block);
            AllPhysObjects.Add(block);

            // Platform
            block                 = new PhysObject();
            block.Position        = new Vector2(_farEdge - 256, _bottomEdge - 240);
            body                  = block.RigidBody;
            body.Mass             = _maximumMass;
            body.IgnoreGravity    = true;
            body.IsDynamic        = false;
            body.Position         = block.Position;
            body.Width            = 256;
            body.Height           = 32;
            body.CollidableObject = new BoxCollider();
            StaticObjects.Add(block);
            AllPhysObjects.Add(block);
            #endregion

            #region Platforms - Tier 2
            // Platform
            block                 = new PhysObject();
            block.Position        = new Vector2(_farEdge / 2 - 448, _bottomEdge - 400);
            body                  = block.RigidBody;
            body.Mass             = _maximumMass;
            body.IgnoreGravity    = true;
            body.IsDynamic        = false;
            body.Position         = block.Position;
            body.Width            = 128;
            body.Height           = 32;
            body.CollidableObject = new BoxCollider();
            StaticObjects.Add(block);
            AllPhysObjects.Add(block);

            // Platform
            block                 = new PhysObject();
            block.Position        = new Vector2(_farEdge / 2 + 448, _bottomEdge - 400);
            body                  = block.RigidBody;
            body.Mass             = _maximumMass;
            body.IgnoreGravity    = true;
            body.IsDynamic        = false;
            body.Position         = block.Position;
            body.Width            = 128;
            body.Height           = 32;
            body.CollidableObject = new BoxCollider();
            StaticObjects.Add(block);
            AllPhysObjects.Add(block);
            #endregion

            #region Platforms - Tier 3
            // Platform
            block                 = new PhysObject();
            block.Position        = new Vector2(_farEdge / 2, _bottomEdge - 496);
            body                  = block.RigidBody;
            body.Mass             = _maximumMass;
            body.IgnoreGravity    = true;
            body.IsDynamic        = false;
            body.Position         = block.Position;
            body.Width            = 512;
            body.Height           = 32;
            body.CollidableObject = new BoxCollider();
            StaticObjects.Add(block);
            AllPhysObjects.Add(block);

            /*
             * // Pendulum (spins, collisions partially broken though, uncomment if you want to see (spawns to the right of the player start))
             * block = new Pendulum(new Vector2(_farEdge / 2, _bottomEdge - 496), new Vector2(0, 128));
             * DynamicObjects.Add(block);
             * AllPhysObjects.Add(block);
             */

            #endregion

            #region Platforms - Tier 4
            // Platform
            block                 = new PhysObject();
            block.Position        = new Vector2(_nearEdge + 256, _bottomEdge - 592);
            body                  = block.RigidBody;
            body.Mass             = _maximumMass;
            body.IgnoreGravity    = true;
            body.IsDynamic        = false;
            body.Position         = block.Position;
            body.Width            = 512;
            body.Height           = 32;
            body.CollidableObject = new BoxCollider();
            StaticObjects.Add(block);
            AllPhysObjects.Add(block);

            // Platform
            block                 = new PhysObject();
            block.Position        = new Vector2(_farEdge - 256, _bottomEdge - 592);
            body                  = block.RigidBody;
            body.Mass             = _maximumMass;
            body.IgnoreGravity    = true;
            body.IsDynamic        = false;
            body.Position         = block.Position;
            body.Width            = 512;
            body.Height           = 32;
            body.CollidableObject = new BoxCollider();
            StaticObjects.Add(block);
            AllPhysObjects.Add(block);
            #endregion

            #region Platforms - Tier 5
            // Platform
            block                 = new PhysObject();
            block.Position        = new Vector2(_nearEdge + 128, _bottomEdge - 784);
            body                  = block.RigidBody;
            body.Mass             = _maximumMass;
            body.IgnoreGravity    = true;
            body.IsDynamic        = false;
            body.Position         = block.Position;
            body.Width            = 256;
            body.Height           = 32;
            body.CollidableObject = new BoxCollider();
            StaticObjects.Add(block);
            AllPhysObjects.Add(block);

            // Platform
            block                 = new PhysObject();
            block.Position        = new Vector2(_farEdge / 2 - 208, _bottomEdge - 784);
            body                  = block.RigidBody;
            body.Mass             = _maximumMass;
            body.IgnoreGravity    = true;
            body.IsDynamic        = false;
            body.Position         = block.Position;
            body.Width            = 352;
            body.Height           = 32;
            body.CollidableObject = new BoxCollider();
            StaticObjects.Add(block);
            AllPhysObjects.Add(block);

            // Thicker block
            block                 = new PhysObject();
            block.Position        = new Vector2(_farEdge / 2 + 80, _bottomEdge - 704);
            body                  = block.RigidBody;
            body.Mass             = _maximumMass;
            body.IgnoreGravity    = true;
            body.IsDynamic        = false;
            body.Position         = block.Position;
            body.Width            = 96;
            body.Height           = 128;
            body.CollidableObject = new BoxCollider();
            StaticObjects.Add(block);
            AllPhysObjects.Add(block);

            // Thicker block
            block                 = new PhysObject();
            block.Position        = new Vector2(_farEdge / 2 - 80, _bottomEdge - 704);
            body                  = block.RigidBody;
            body.Mass             = _maximumMass;
            body.IgnoreGravity    = true;
            body.IsDynamic        = false;
            body.Position         = block.Position;
            body.Width            = 96;
            body.Height           = 128;
            body.CollidableObject = new BoxCollider();
            StaticObjects.Add(block);
            AllPhysObjects.Add(block);

            // Platform
            block                 = new PhysObject();
            block.Position        = new Vector2(_farEdge / 2 + 208, _bottomEdge - 784);
            body                  = block.RigidBody;
            body.Mass             = _maximumMass;
            body.IgnoreGravity    = true;
            body.IsDynamic        = false;
            body.Position         = block.Position;
            body.Width            = 352;
            body.Height           = 32;
            body.CollidableObject = new BoxCollider();
            StaticObjects.Add(block);
            AllPhysObjects.Add(block);

            // Platform
            block                 = new PhysObject();
            block.Position        = new Vector2(_farEdge - 128, _bottomEdge - 784);
            body                  = block.RigidBody;
            body.Mass             = _maximumMass;
            body.IgnoreGravity    = true;
            body.IsDynamic        = false;
            body.Position         = block.Position;
            body.Width            = 256;
            body.Height           = 32;
            body.CollidableObject = new BoxCollider();
            StaticObjects.Add(block);
            AllPhysObjects.Add(block);
            #endregion

            #region Platforms - Tier 6
            // Platform
            block                 = new PhysObject();
            block.Position        = new Vector2(_nearEdge + 432, _bottomEdge - 1008);
            body                  = block.RigidBody;
            body.Mass             = _maximumMass;
            body.IgnoreGravity    = true;
            body.IsDynamic        = false;
            body.Position         = block.Position;
            body.Width            = 288;
            body.Height           = 32;
            body.CollidableObject = new BoxCollider();
            StaticObjects.Add(block);
            AllPhysObjects.Add(block);

            // Thicker block
            block                 = new PhysObject();
            block.Position        = new Vector2(_farEdge / 2 - 80, _bottomEdge - 1040);
            body                  = block.RigidBody;
            body.Mass             = _maximumMass;
            body.IgnoreGravity    = true;
            body.IsDynamic        = false;
            body.Position         = block.Position;
            body.Width            = 96;
            body.Height           = 160;
            body.CollidableObject = new BoxCollider();
            StaticObjects.Add(block);
            AllPhysObjects.Add(block);

            // Thicker block
            block                 = new PhysObject();
            block.Position        = new Vector2(_farEdge / 2 + 80, _bottomEdge - 1040);
            body                  = block.RigidBody;
            body.Mass             = _maximumMass;
            body.IgnoreGravity    = true;
            body.IsDynamic        = false;
            body.Position         = block.Position;
            body.Width            = 96;
            body.Height           = 160;
            body.CollidableObject = new BoxCollider();
            StaticObjects.Add(block);
            AllPhysObjects.Add(block);

            // Platform
            block                 = new PhysObject();
            block.Position        = new Vector2(_farEdge - 432, _bottomEdge - 1008);
            body                  = block.RigidBody;
            body.Mass             = _maximumMass;
            body.IgnoreGravity    = true;
            body.IsDynamic        = false;
            body.Position         = block.Position;
            body.Width            = 288;
            body.Height           = 32;
            body.CollidableObject = new BoxCollider();
            StaticObjects.Add(block);
            AllPhysObjects.Add(block);
            #endregion

            #region Platforms - Tier 7
            // Platform
            block                 = new PhysObject();
            block.Position        = new Vector2(_nearEdge + 560, _bottomEdge - 1072);
            body                  = block.RigidBody;
            body.Mass             = _maximumMass;
            body.IgnoreGravity    = true;
            body.IsDynamic        = false;
            body.Position         = block.Position;
            body.Width            = 32;
            body.Height           = 96;
            body.CollidableObject = new BoxCollider();
            StaticObjects.Add(block);
            AllPhysObjects.Add(block);

            // Platform
            block                 = new PhysObject();
            block.Position        = new Vector2(_farEdge - 560, _bottomEdge - 1072);
            body                  = block.RigidBody;
            body.Mass             = _maximumMass;
            body.IgnoreGravity    = true;
            body.IsDynamic        = false;
            body.Position         = block.Position;
            body.Width            = 32;
            body.Height           = 96;
            body.CollidableObject = new BoxCollider();
            StaticObjects.Add(block);
            AllPhysObjects.Add(block);
            #endregion

            #region Platforms - Tier 8
            // Platform
            block                 = new PhysObject();
            block.Position        = new Vector2(_farEdge / 2 - 256, _bottomEdge - 1136);
            body                  = block.RigidBody;
            body.Mass             = _maximumMass;
            body.IgnoreGravity    = true;
            body.IsDynamic        = false;
            body.Position         = block.Position;
            body.Width            = 448;
            body.Height           = 32;
            body.CollidableObject = new BoxCollider();
            StaticObjects.Add(block);
            AllPhysObjects.Add(block);

            // Platform
            block                 = new PhysObject();
            block.Position        = new Vector2(_farEdge / 2 + 256, _bottomEdge - 1136);
            body                  = block.RigidBody;
            body.Mass             = _maximumMass;
            body.IgnoreGravity    = true;
            body.IsDynamic        = false;
            body.Position         = block.Position;
            body.Width            = 448;
            body.Height           = 32;
            body.CollidableObject = new BoxCollider();
            StaticObjects.Add(block);
            AllPhysObjects.Add(block);
            #endregion

            #region Platforms - Tier 9
            // Platform
            block                 = new PhysObject();
            block.Position        = new Vector2(_nearEdge + 128, _bottomEdge - 1424);
            body                  = block.RigidBody;
            body.Mass             = _maximumMass;
            body.IgnoreGravity    = true;
            body.IsDynamic        = false;
            body.Position         = block.Position;
            body.Width            = 256;
            body.Height           = 32;
            body.CollidableObject = new BoxCollider();
            StaticObjects.Add(block);
            AllPhysObjects.Add(block);

            // Platform
            block                 = new PhysObject();
            block.Position        = new Vector2(_farEdge / 2 - 288, _bottomEdge - 1424);
            body                  = block.RigidBody;
            body.Mass             = _maximumMass;
            body.IgnoreGravity    = true;
            body.IsDynamic        = false;
            body.Position         = block.Position;
            body.Width            = 256;
            body.Height           = 32;
            body.CollidableObject = new BoxCollider();
            StaticObjects.Add(block);
            AllPhysObjects.Add(block);

            // Platform
            block                 = new PhysObject();
            block.Position        = new Vector2(_farEdge / 2 + 288, _bottomEdge - 1424);
            body                  = block.RigidBody;
            body.Mass             = _maximumMass;
            body.IgnoreGravity    = true;
            body.IsDynamic        = false;
            body.Position         = block.Position;
            body.Width            = 256;
            body.Height           = 32;
            body.CollidableObject = new BoxCollider();
            StaticObjects.Add(block);
            AllPhysObjects.Add(block);

            // Platform
            block                 = new PhysObject();
            block.Position        = new Vector2(_farEdge - 128, _bottomEdge - 1424);
            body                  = block.RigidBody;
            body.Mass             = _maximumMass;
            body.IgnoreGravity    = true;
            body.IsDynamic        = false;
            body.Position         = block.Position;
            body.Width            = 256;
            body.Height           = 32;
            body.CollidableObject = new BoxCollider();
            StaticObjects.Add(block);
            AllPhysObjects.Add(block);
            #endregion

            #region Platforms - Tier 10
            // Platform
            block                 = new PhysObject();
            block.Position        = new Vector2(_farEdge / 2, _bottomEdge - 1680);
            body                  = block.RigidBody;
            body.Mass             = _maximumMass;
            body.IgnoreGravity    = true;
            body.IsDynamic        = false;
            body.Position         = block.Position;
            body.Width            = 640;
            body.Height           = 32;
            body.CollidableObject = new BoxCollider();
            StaticObjects.Add(block);
            AllPhysObjects.Add(block);
            #endregion

            #region Platforms - Tier 11
            // Platform
            block                 = new PhysObject();
            block.Position        = new Vector2(_farEdge / 2, _bottomEdge - 1760);
            body                  = block.RigidBody;
            body.Mass             = _maximumMass;
            body.IgnoreGravity    = true;
            body.IsDynamic        = false;
            body.Position         = block.Position;
            body.Width            = 256;
            body.Height           = 128;
            body.CollidableObject = new BoxCollider();
            StaticObjects.Add(block);
            AllPhysObjects.Add(block);
            #endregion

            #region Platforms - Tier 12
            // Moving Platform
            block = new MovingPlatform(new Vector2(_nearEdge + 256, _bottomEdge - 2000),
                                       new Vector2(_nearEdge + 160, _bottomEdge - 2000),
                                       new Vector2(_nearEdge + (_farEdge / 2) - 160, _bottomEdge - 2000),
                                       new Vector2(100, 0));
            body                  = block.RigidBody;
            body.Mass             = _maximumMass;
            body.IgnoreGravity    = true;
            body.IsDynamic        = false;
            body.Position         = block.Position;
            body.Width            = 256;
            body.Height           = 32;
            body.CollidableObject = new BoxCollider();
            StaticObjects.Add(block);
            AllPhysObjects.Add(block);

            // Moving Platform
            block = new MovingPlatform(new Vector2(_farEdge - 256, _bottomEdge - 2000),
                                       new Vector2((_farEdge / 2) + 160, _bottomEdge - 2000),
                                       new Vector2(_farEdge - 160, _bottomEdge - 2000),
                                       new Vector2(-100, 0));
            body                  = block.RigidBody;
            body.Mass             = _maximumMass;
            body.IgnoreGravity    = true;
            body.IsDynamic        = false;
            body.Position         = block.Position;
            body.Width            = 256;
            body.Height           = 32;
            body.CollidableObject = new BoxCollider();
            StaticObjects.Add(block);
            AllPhysObjects.Add(block);
            #endregion

            #region Platforms - Tier 13
            // Platform
            block                 = new PhysObject();
            block.Position        = new Vector2(_farEdge / 2, _bottomEdge - 2288);
            body                  = block.RigidBody;
            body.Mass             = _maximumMass;
            body.IgnoreGravity    = true;
            body.IsDynamic        = false;
            body.Position         = block.Position;
            body.Width            = 512;
            body.Height           = 32;
            body.CollidableObject = new BoxCollider();
            StaticObjects.Add(block);
            AllPhysObjects.Add(block);
            #endregion
        }
Beispiel #27
0
 private void DestroyFromManager(IDynamic gameObject)
 {
     DynamicObjects.Remove(gameObject);
     gameObject.Destroy();
 }
        private void BuildLevel(List <string[]> levelData)
        {
            // iterate through lines
            for (int i = 0; i < levelData.Count(); i++)
            {
                switch (levelData[i][0])
                {
                case "00":
                    // mario
                    Mario.Instance.PlayableObjectState = new SmallRightIdleMario(Mario.Instance);
                    Mario.Instance.Position            = new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize);
                    break;

                case "01":
                    // floor tiles
                    StaticObjects.Add(new FloorTile(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), new Vector2(StringToInt(i, 3), StringToInt(i, 4)), levelData[i][5]));
                    break;

                case "02":
                    // blocks
                    Blocks.Add(new Block(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), levelData[i][3], levelData[i][4]));
                    break;

                case "03":
                    // floating coins
                    Coins.Add(new Item(new Vector2((StringToInt(i, 1) * levelCellSize) + (levelCellSize / 4), StringToInt(i, 2) * levelCellSize), "FloatingCoin"));
                    break;

                case "04":
                    // pipes
                    Pipes.Add(new Pipe(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), StringToInt(i, 3), Convert.ToBoolean(levelData[i][4]), levelData[i][5]));
                    break;

                case "05":
                    // enemies
                    Enemies.Add(new Enemy(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize - 10), levelData[i][3]));
                    break;

                case "06":
                    // hills
                    BackgroundItems.Add(new Hill(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), StringToInt(i, 3)));
                    break;

                case "07":
                    // bushes
                    BackgroundItems.Add(new Bush(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), StringToInt(i, 3)));
                    break;

                case "08":
                    // clouds
                    BackgroundItems.Add(new Cloud(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), StringToInt(i, 3)));
                    break;

                case "09":
                    // castle
                    Castle = new Castle(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize));
                    break;

                case "10":
                    // flag pole
                    Flagpoles.Add(new Flagpole(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize), levelCellSize));
                    break;

                case "11":
                    // check point
                    Checkpoints.Add(new CheckPoint(new Vector2(StringToInt(i, 1) * levelCellSize, StringToInt(i, 2) * levelCellSize)));
                    break;

                case "12":
                    // coin room
                    CoinRoomPosition = new Vector2(StringToInt(i, 1) * levelCellSize + (levelCellSize / 8), StringToInt(i, 2) * levelCellSize);
                    break;
                }
            }

            DynamicObjects.Add(Mario.Instance);

            foreach (Block block in Blocks)
            {
                DynamicObjects.Add(block);
                DynamicObjects.Add(block.Item); // Add items in each block too.
            }

            foreach (Item coin in Coins)
            {
                DynamicObjects.Add(coin);
            }

            foreach (Enemy enemy in Enemies)
            {
                // Added such that the Koopa spawns in a correct position before any updates are made, otherwise he spawns in the floor to start.
                if (enemy.EnemyState.ToString() == "SuperMario.EnemyStates.LeftWalkingKoopa" || enemy.EnemyState.ToString() == "SuperMario.EnemyStates.RightWalkingKoopa")
                {
                    enemy.Position = new Vector2(enemy.Position.X, enemy.Position.Y - GameValues.KoopaPositionOffset);
                }
                DynamicObjects.Add(enemy);
            }

            foreach (Pipe pipe in Pipes)
            {
                StaticObjects.Add(pipe);
            }

            foreach (Flagpole flagpole in Flagpoles)
            {
                StaticObjects.Add(flagpole);
            }

            if (Flagpoles.Count > 0)
            {
                Flag.Position = new Vector2(Flagpoles[0].CollisionRectangle.X - GameValues.FlagPositionOffsetVector.X, Flagpoles[0].CollisionRectangle.Y + GameValues.FlagPositionOffsetVector.Y);
            }
        }
        public void TestIDic()
        {
            var dic = new Dictionary<string, object> { { "a", 1 }, { "b", 2 } };

            dynamic d = new DynamicObjects(dic);

            Assert.AreEqual(1, d.a);
        }
Beispiel #30
0
 public void AddObject(IDynamic gameObject)
 {
     DynamicObjects.Add(gameObject);
 }