Esempio n. 1
0
        internal OgmoObjectLayer(ContentReader reader, OgmoLevel level)
            : base(reader)
        {
            int objectCount = reader.ReadInt32();

            if (objectCount > 0)
            {
                for (int i = 0; i < objectCount; i++)
                {
                    OgmoObject obj = new OgmoObject(reader);
                    if (obj != null)
                    {
                        if (objects.ContainsKey(obj.Name))
                        {
                            objects[obj.Name].Add(obj);
                        }
                        else
                        {
                            objects.Add(obj.Name, new List <OgmoObject>()
                            {
                                obj
                            });
                        }
                    }
                    allObjects.Add(obj);
                }
            }
        }
Esempio n. 2
0
 public Chest(OgmoObject obj, Level level)
     : base(obj, level)
 {
     OgmoIntegerValue coins = obj.GetValue<OgmoIntegerValue>("coins");
     if (coins != null)
         this.Coins = coins.Value;
     this.Collision += new EventHandler<CollisionEventArgs>(Chest_Collision);
 }
Esempio n. 3
0
        public Chest(OgmoObject obj, Level level)
            : base(obj, level)
        {
            OgmoIntegerValue coins = obj.GetValue <OgmoIntegerValue>("coins");

            if (coins != null)
            {
                this.Coins = coins.Value;
            }
            this.Collision += new EventHandler <CollisionEventArgs>(Chest_Collision);
        }
Esempio n. 4
0
 protected GameObject(OgmoObject obj, Level level)
 {
     this.Level = level;
     this.Height = obj.Height;
     this.Name = obj.Name;
     this.Origin = obj.Origin;
     this.Position = obj.Position;
     this.Source = obj.Source;
     this.Texture = obj.Texture;
     this.Width = obj.Width;
     this.IsTiled = obj.IsTiled;
 }
Esempio n. 5
0
 public MovingPlatform(OgmoObject obj, Level level)
     : base(obj, level)
 {
     nodes.AddRange(obj.Nodes);
     if (nodes.Count > 0)
     {
         direction = Vector2.Normalize(nodes[currentNode].Position - this.Position);
         nodes.Add(new OgmoNode(this.Position));
     }
     OgmoNumberValue speedValue = obj.GetValue<OgmoNumberValue>("speed");
     if (speedValue != null)
         speed = speedValue.Value;
 }
Esempio n. 6
0
 protected GameObject(OgmoObject obj, Level level)
 {
     this.Level                  = level;
     this.Height                 = obj.Height;
     this.Name                   = obj.Name;
     this.Origin                 = obj.Origin;
     this.Position               = obj.Position;
     this.Source                 = obj.Source;
     this.Texture                = obj.Texture;
     this.Width                  = obj.Width;
     this.IsTiled                = obj.IsTiled;
     this.mSamplerState          = new SamplerState();
     this.mSamplerState.AddressU = TextureAddressMode.Wrap;
     this.mSamplerState.AddressV = TextureAddressMode.Wrap;
 }
Esempio n. 7
0
        public MovingPlatform(OgmoObject obj, Level level)
            : base(obj, level)
        {
            nodes.AddRange(obj.Nodes);
            if (nodes.Count > 0)
            {
                direction = Vector2.Normalize(nodes[currentNode].Position - this.Position);
                nodes.Add(new OgmoNode(this.Position));
            }
            OgmoNumberValue speedValue = obj.GetValue <OgmoNumberValue>("speed");

            if (speedValue != null)
            {
                speed = speedValue.Value;
            }
        }
 internal OgmoObjectLayer(ContentReader reader, OgmoLevel level)
     : base(reader)
 {
     int objectCount = reader.ReadInt32();
     if (objectCount > 0)
     {
         for (int i = 0; i < objectCount; i++)
         {
             OgmoObject obj = new OgmoObject(reader);
             if(obj != null)
             if (objects.ContainsKey(obj.Name))
                 objects[obj.Name].Add(obj);
             else
                 objects.Add(obj.Name, new List<OgmoObject>() { obj });
             allObjects.Add(obj);
         }
     }
 }
Esempio n. 9
0
        /// <summary>
        /// From an Ogmo object, instanciate it
        /// </summary>
        /// <returns></returns>
        public static OgmoObjectEntity InstanciateOgmoObject(OgmoObject oobject)
        {
            Type type = null;

            if (_ogmoObjectsDictionary.TryGetValue(oobject.Name, out type))
            {
                var constructor = type.GetConstructor(new Type[] { typeof(Vector2) });
                var obj = constructor.Invoke(new object[] { oobject.Position });

                var ogmoObject = obj as OgmoObjectEntity;

                foreach (var value in oobject.Values)
                {
                    ogmoObject.OnValueFound(value.Name, value);
                }

                if (obj is OgmoMovingObjectEntity)
                {
                    var movObj = obj as OgmoMovingObjectEntity;

                    // Add nodes
                    foreach (OgmoNode node in oobject.Nodes)
                    {
                        movObj.Points.Add(node.Position);
                    }

                    // Add current location
                    movObj.Points.Add(oobject.Position);

                }

                return ogmoObject;
            }

            throw new ArgumentException("Invalid object ID: " + oobject.Name);
        }
Esempio n. 10
0
 public Spike(OgmoObject obj, Level level)
     : base(obj, level)
 {
     this.Collision += new EventHandler <CollisionEventArgs>(Spike_Collision);
 }
Esempio n. 11
0
File: Ogmo.cs Progetto: endy/OgmoXNA
 public Ogmo(OgmoObject obj, Level level)
     : base(obj, level)
 {
     startPosition = obj.Position;
     this.Die += new EventHandler(Ogmo_Die);
 }
Esempio n. 12
0
 public Spike(OgmoObject obj, Level level)
     : base(obj, level)
 {
     this.Collision += new EventHandler<CollisionEventArgs>(Spike_Collision);
 }
Esempio n. 13
0
 public Ogmo(OgmoObject obj, Level level)
     : base(obj, level)
 {
     startPosition = obj.Position;
     this.Die     += new EventHandler(Ogmo_Die);
 }