Пример #1
0
        private void OnTriPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            var new_value = sender.GetType().GetProperty(e.PropertyName).GetValue(sender, null);

            for (int i = 1; i < EditorSelection.SelectedObjects.Count; i++)
            {
                CollisionProperty tri_props = EditorSelection.SelectedObjects[i].Properties;
                tri_props.GetType().GetProperty(e.PropertyName).SetValue(tri_props, new_value, null);
            }
        }
Пример #2
0
        protected override void Init(MyObjectBuilder_DefinitionBase builder)
        {
            base.Init(builder);

            var materialBuilder = builder as MyObjectBuilder_PhysicalMaterialDefinition;

            if (materialBuilder != null)
            {
                //MyDebug.AssertDebug(materialBuilder != null, "Initializing physical material definition using wrong object builder.");
                Density = materialBuilder.Density;
                HorisontalTransmissionMultiplier = materialBuilder.HorisontalTransmissionMultiplier;
                HorisontalFragility = materialBuilder.HorisontalFragility;
                SupportMultiplier   = materialBuilder.SupportMultiplier;
                CollisionMultiplier = materialBuilder.CollisionMultiplier;
                DamageDecal         = materialBuilder.DamageDecal;
            }
            var soundBuilder = builder as MyObjectBuilder_MaterialPropertiesDefinition;

            if (soundBuilder != null)
            {
                InheritSoundsFrom = MyStringHash.GetOrCompute(soundBuilder.InheritFrom);


                foreach (var sound in soundBuilder.ContactProperties)
                {
                    var type = MyStringId.GetOrCompute(sound.Type);
                    if (!CollisionProperties.ContainsKey(type))
                    {
                        CollisionProperties[type] = new Dictionary <MyStringHash, CollisionProperty>(MyStringHash.Comparer);
                    }
                    var material = MyStringHash.GetOrCompute(sound.Material);

                    Debug.Assert(!CollisionProperties[type].ContainsKey(material), "Overwriting material sound!");

                    CollisionProperties[type][material] = new CollisionProperty(sound.SoundCue, sound.ParticleEffect, sound.ParticleProperties);
                }

                foreach (var sound in soundBuilder.GeneralProperties)
                {
                    GeneralSounds[MyStringId.GetOrCompute(sound.Type)] = new MySoundPair(sound.SoundCue);
                }
            }
        }
        protected override void Init(MyObjectBuilder_DefinitionBase builder)
        {
            base.Init(builder);

            var materialBuilder = builder as MyObjectBuilder_PhysicalMaterialDefinition;
            if (materialBuilder != null)
            {
                //MyDebug.AssertDebug(materialBuilder != null, "Initializing physical material definition using wrong object builder.");
                Density = materialBuilder.Density;
                HorisontalTransmissionMultiplier = materialBuilder.HorisontalTransmissionMultiplier;
                HorisontalFragility = materialBuilder.HorisontalFragility;
                SupportMultiplier = materialBuilder.SupportMultiplier;
                CollisionMultiplier = materialBuilder.CollisionMultiplier;
                DamageDecal = materialBuilder.DamageDecal;
            }
            var soundBuilder = builder as MyObjectBuilder_MaterialPropertiesDefinition;
            if(soundBuilder != null)
            {
                InheritSoundsFrom = MyStringHash.GetOrCompute(soundBuilder.InheritFrom);
                

                foreach(var sound in soundBuilder.ContactProperties)
                {
                    var type = MyStringId.GetOrCompute(sound.Type);
                    if (!CollisionProperties.ContainsKey(type))
                        CollisionProperties[type] = new Dictionary<MyStringHash, CollisionProperty>(MyStringHash.Comparer);
                    var material = MyStringHash.GetOrCompute(sound.Material);

                    Debug.Assert(!CollisionProperties[type].ContainsKey(material), "Overwriting material sound!");

                    CollisionProperties[type][material] = new CollisionProperty(sound.SoundCue, sound.ParticleEffect, sound.ParticleProperties);
                }

                foreach(var sound in soundBuilder.GeneralProperties)
                {
                    GeneralSounds[MyStringId.GetOrCompute(sound.Type)] = new MySoundPair(sound.SoundCue);
                }
            }
        }   
Пример #4
0
        /// <summary>
        /// Load a new tile and gives it a texture and collision property.
        /// </summary>
        public void LoadTile()
        {
            // 16 x 16 red block
            if (tileRepresentation == '*')
            {
                // Load the texture. We use Game1's ContentManager here.
                texture = content.Load <Texture2D>("Tiles/test1");

                // Set the collision property of a block.
                collisionProperty = CollisionProperty.Impassable;
            }

            // Transparent Block.
            else if (tileRepresentation == 't')
            {
                texture           = content.Load <Texture2D>("Tiles/TransparentBlock");
                collisionProperty = CollisionProperty.Passable;
            }

            // Player Block. This will be used to get the starting position of the player.
            else if (tileRepresentation == 'P')
            {
                texture           = content.Load <Texture2D>("Tiles/TransparentBlock");
                collisionProperty = CollisionProperty.Passable;
            }

            else if (tileRepresentation == 'g')
            {
                texture           = content.Load <Texture2D>("Tiles/Goal-16");
                collisionProperty = CollisionProperty.Passable;
            }
            else if (tileRepresentation == 'G')
            {
                texture           = content.Load <Texture2D>("Tiles/Sandwich");
                collisionProperty = CollisionProperty.Passable;
            }
            else if (tileRepresentation == 'S')
            {
                texture           = content.Load <Texture2D>("Tiles/spring");
                collisionProperty = CollisionProperty.Impassable;
            }
            else if (tileRepresentation == '1' || tileRepresentation == '2' || tileRepresentation == '3' || tileRepresentation == '4' || tileRepresentation == '6' || tileRepresentation == '7' || tileRepresentation == '8' || tileRepresentation == '9')
            {
                texture           = content.Load <Texture2D>("Tiles/launcher_0");
                collisionProperty = CollisionProperty.Impassable;
                isLauncher        = true;
            }
            else if (tileRepresentation == 'z' || tileRepresentation == 'x' || tileRepresentation == 'c' || tileRepresentation == 'a' || tileRepresentation == 'd' || tileRepresentation == 'q' || tileRepresentation == 'w' || tileRepresentation == 'e')
            {
                texture           = content.Load <Texture2D>("Tiles/AirCannon");
                collisionProperty = CollisionProperty.Passable;
                isAirCannon       = true;
                putCannonIntoCorrectList(this);
            }
            else if (tileRepresentation == 'Z' || tileRepresentation == 'X' || tileRepresentation == 'C' || tileRepresentation == 'A' || tileRepresentation == 'D' || tileRepresentation == 'Q' || tileRepresentation == 'W' || tileRepresentation == 'E')
            {
                texture           = content.Load <Texture2D>("Tiles/AirCannonSwitch");
                collisionProperty = CollisionProperty.Passable;
                isAirCannonSwitch = true;
            }
        }
Пример #5
0
		/// <summary>
		/// Load a new tile and gives it a texture and collision property.
		/// </summary>
		public void LoadTile()
		{        
			// 16 x 16 red block
			if (tileRepresentation == '*')
			{
				// Load the texture. We use Game1's ContentManager here.
				texture = content.Load<Texture2D>("Tiles/test1");

				// Set the collision property of a block.
				collisionProperty = CollisionProperty.Impassable;                
			}

			// Transparent Block.
			else if (tileRepresentation == 't')
			{
				texture = content.Load<Texture2D>("Tiles/TransparentBlock");
				collisionProperty = CollisionProperty.Passable;
			}

			// Player Block. This will be used to get the starting position of the player.
			else if (tileRepresentation == 'P')
			{
				texture = content.Load<Texture2D>("Tiles/TransparentBlock");
				collisionProperty = CollisionProperty.Passable;
			}

			else if (tileRepresentation == 'G')
			{
				texture = content.Load<Texture2D>("Tiles/Goal-16");
				collisionProperty = CollisionProperty.Passable;
			}
			else if (tileRepresentation == 'S')
			{
				texture = content.Load<Texture2D>("Tiles/spring");
				collisionProperty = CollisionProperty.Impassable;
			}
			else if (tileRepresentation == '1' || tileRepresentation == '2' || tileRepresentation == '3' || tileRepresentation == '4' || tileRepresentation == '6' || tileRepresentation == '7' || tileRepresentation == '8' || tileRepresentation == '9')
			{
				texture = content.Load<Texture2D>("Tiles/launcher_0");
				collisionProperty = CollisionProperty.Impassable;
				isLauncher = true;
			}
			else if (tileRepresentation == 'z' || tileRepresentation == 'x' || tileRepresentation == 'c' || tileRepresentation == 'a' || tileRepresentation == 'd' || tileRepresentation == 'q' || tileRepresentation == 'w' || tileRepresentation == 'e')
			{
				texture = content.Load<Texture2D>("Tiles/AirCannon");
				collisionProperty = CollisionProperty.Passable;
				isAirCannon = true;
			}
		}