Exemple #1
0
    public override void WindowGUI()
    {
        string targetButtonText = "Target:  Self";

        if (targetEntityIsActivator)
        {
            targetButtonText = "Target:  Activators";
        }
        else if (targetEntity != null)
        {
            targetButtonText = "Target:  " + targetEntity.ToString();
        }
        TutorialGUI.TutorialHighlight("behavior target");
        if (GUIUtils.HighlightedButton(targetButtonText))
        {
            entityPicker = PropertyGUIs.BehaviorTargetPicker(gameObject, voxelArray, self, value =>
            {
                targetEntity            = value.targetEntity.entity;
                targetEntityIsActivator = value.targetEntityIsActivator;
                UpdateBehaviorList();
            });
        }
        TutorialGUI.ClearHighlight();
        if (typePicker != null)
        {
            typePicker.scroll = scroll;
            typePicker.WindowGUI();
            scroll = typePicker.scroll;
        }

        // prevent panel from closing when entity picker closes
        holdOpen = entityPicker != null;
    }
Exemple #2
0
 public override IEnumerable <Property> Properties()
 {
     return(Property.JoinProperties(base.Properties(), new Property[]
     {
         new Property("dat", "Sound",
                      () => soundData,
                      v => soundData = (EmbeddedData)v,
                      PropertyGUIs.EmbeddedData(EmbeddedDataType.Audio, SoundPlayer.Factory)),
         new Property("pmo", "Play mode",
                      () => playMode,
                      v => playMode = (PlayMode)v,
                      PropertyGUIs.Enum),
         new Property("vol", "Volume",
                      () => volume,
                      v => volume = (float)v,
                      PropertyGUIs.Float),
         new Property("fin", "Fade in",
                      () => fadeIn,
                      v => fadeIn = (float)v,
                      PropertyGUIs.Float),
         new Property("fou", "Fade out",
                      () => fadeOut,
                      v => fadeOut = (float)v,
                      PropertyGUIs.Float)
     }));
 }
Exemple #3
0
 public override IEnumerable <Property> Properties()
 {
     return(Property.JoinProperties(base.Properties(), new Property[]
     {
         new Property("loc", "To",
                      () => dest,
                      v => dest = (EntityReference)v,
                      PropertyGUIs.EntityReference),
         new Property("rel", "Relative to",
                      () => origin,
                      v => origin = (EntityReference)v,
                      (Property property) => {
             var reference = (EntityReference)property.value;
             // TODO: this is not a good solution
             Entity targetEntity = target.GetEntity(
                 EntityReferencePropertyManager.CurrentEntity());
             if (reference.entity == null && targetEntity != null)
             {
                 property.value = new EntityReference(targetEntity);
             }
             PropertyGUIs._EntityReferenceCustom(property, targetEntity == null,
                                                 targetEntity == null ? "Activator" : "None");
         })
     }));
 }
Exemple #4
0
 public override ICollection <Property> Properties()
 {
     return(Property.JoinProperties(base.Properties(), new Property[]
     {
         new Property("loc", "To",
                      () => target,
                      v => target = (EntityReference)v,
                      PropertyGUIs.EntityReference),
         new Property("rel", "Relative to",
                      () => origin,
                      v => origin = (EntityReference)v,
                      (Property property) => {
             var reference = (EntityReference)property.value;
             if (reference.entity == null)
             {
                 if (targetEntity.entity != null)
                 {
                     property.value = targetEntity;
                 }
                 else if (!targetEntityIsActivator)
                 {
                     // TODO: this is not a good solution
                     property.value = new EntityReference(
                         EntityReferencePropertyManager.CurrentEntity());
                 }
             }
             PropertyGUIs._EntityReferenceCustom(property, targetEntityIsActivator,
                                                 targetEntityIsActivator ? "Activator" : "None");
         })
     }));
 }
Exemple #5
0
    public virtual ICollection <Property> Properties()
    {
        return(new Property[]
        {
            new Property("tar", "Target",
                         () => new BehaviorTargetProperty(targetEntity, targetEntityIsActivator),
                         v => {
                var prop = (BehaviorTargetProperty)v;

                // selfEntity will be null if multiple entities are selected
                Entity selfEntity = EntityReferencePropertyManager.CurrentEntity();

                var oldTargetEntity = targetEntity.entity;
                var newTargetEntity = prop.targetEntity.entity;
                if (oldTargetEntity == null && !targetEntityIsActivator)
                {
                    oldTargetEntity = selfEntity;
                }
                if (newTargetEntity == null && !prop.targetEntityIsActivator)
                {
                    newTargetEntity = selfEntity;
                }

                if (oldTargetEntity != null)
                {
                    // replace all property values referencing the old target with the new target
                    // the new target could be null
                    foreach (Property _selfProp in this.Properties())
                    {
                        var selfProp = _selfProp;
                        selfProp.value = PropertiesObjectType.PropertyValueReplaceEntity(
                            selfProp.value, oldTargetEntity, newTargetEntity);
                    }
                }

                targetEntity = prop.targetEntity;
                targetEntityIsActivator = prop.targetEntityIsActivator;
            },
                         PropertyGUIs.BehaviorTarget),
            new Property("con", "Condition",
                         () => condition,
                         v => condition = (Condition)v,
                         (Property property) => {
                if (targetEntityIsActivator)
                {
                    PropertyGUIs.ActivatorBehaviorCondition(property);
                }
                else
                {
                    PropertyGUIs.BehaviorCondition(property);
                }
            })
        });
    }
Exemple #6
0
 public override IEnumerable <Property> Properties()
 {
     return(Property.JoinProperties(base.Properties(), new Property[]
     {
         new Property("siz", "Size",
                      () => size,
                      v => size = (float)v,
                      PropertyGUIs.Slider(0.5f, 15)),
         new Property("col", "Color",
                      () => color,
                      v => color = (Color)v,
                      PropertyGUIs.Color)
     }));
 }
Exemple #7
0
 public override IEnumerable <Property> Properties()
 {
     return(Property.JoinProperties(base.Properties(), new Property[]
     {
         new Property("siz", "Range",
                      () => size,
                      v => size = (float)v,
                      PropertyGUIs.Slider(1, 100)),
         new Property("int", "Intensity",
                      () => intensity,
                      v => intensity = (float)v,
                      PropertyGUIs.Slider(0, 1.5f)),
         new Property("upd", "Real-time?",
                      () => realtime,
                      v => realtime = (bool)v,
                      PropertyGUIs.Toggle)
     }));
 }
Exemple #8
0
    public override IEnumerable <Property> Properties()
    {
        return(new Property[]
        {
            new Property("tar", "Target",
                         () => target,
                         v => {
                var prop = (BehaviorTargetProperty)v;

                // selfEntity will be null if multiple entities are selected
                Entity selfEntity = EntityReferencePropertyManager.CurrentEntity();
                var oldTargetEntity = target.GetEntity(selfEntity);
                var newTargetEntity = prop.GetEntity(selfEntity);

                if (oldTargetEntity != null)
                {
                    // replace all property values referencing the old target with the new target
                    // the new target could be null
                    foreach (Property _selfProp in this.Properties())
                    {
                        var selfProp = _selfProp;
                        selfProp.value = PropertiesObject.PropertyValueReplaceEntity(
                            selfProp.value, oldTargetEntity, newTargetEntity);
                    }
                }

                target = prop;
            },
                         PropertyGUIs.BehaviorTarget),
            new Property("con", "Condition",
                         () => condition,
                         v => condition = (Condition)v,
                         (Property property) => {
                if (target.targetEntityIsActivator)
                {
                    PropertyGUIs.ActivatorBehaviorCondition(property);
                }
                else
                {
                    PropertyGUIs.BehaviorCondition(property);
                }
            })
        });
    }
Exemple #9
0
 public override ICollection <Property> Properties()
 {
     return(Property.JoinProperties(base.Properties(), new Property[]
     {
         new Property("mat", "Material",
                      () => material,
                      v =>
         {
             material = (Material)v;
             if (marker != null)
             {
                 marker.storedMaterials[0] = material;
                 marker.UpdateMarker();
             }
         },
                      PropertyGUIs.Material("Materials", true,
                                            MaterialSelectorGUI.ColorModeSet.OBJECT, true))
     }));
 }
Exemple #10
0
 public override ICollection <Property> Properties()
 {
     return(Property.JoinProperties(base.Properties(), new Property[]
     {
         new Property("Size",
                      () => size,
                      v => size = (float)v,
                      PropertyGUIs.Slider(1, 30)),
         new Property("Color",
                      () => color,
                      v => color = (Color)v,
                      PropertyGUIs.Color),
         new Property("Intensity",
                      () => intensity,
                      v => intensity = (float)v,
                      PropertyGUIs.Slider(0, 5)),
         new Property("Halo?",
                      () => halo,
                      v => halo = (bool)v,
                      PropertyGUIs.Toggle)
     }));
 }
Exemple #11
0
 public override IEnumerable <Property> Properties()
 {
     return(Property.JoinProperties(base.Properties(), new Property[]
     {
         new Property("siz", "Size",
                      () => size,
                      v => size = (float)v,
                      PropertyGUIs.Slider(1, 30)),
         new Property("col", "Color",
                      () => color,
                      v => color = (Color)v,
                      PropertyGUIs.Color),
         new Property("int", "Intensity",
                      () => intensity,
                      v => intensity = (float)v,
                      PropertyGUIs.Slider(0, 5)),
         new Property("sha", "Shadows?",
                      () => shadows,
                      v => shadows = (bool)v,
                      PropertyGUIs.Toggle)
     }));
 }
Exemple #12
0
    // merge properties of objects
    public StoredPropertiesObject(PropertiesObject[] objects)
    {
        properties = new List <Property>();
        if (objects.Length == 0)
        {
            return;
        }
        if (objects[0] != null)
        {
            type = objects[0].ObjectType();
        }
        // check that all objects have the same type. if they don't, fail
        foreach (PropertiesObject obj in objects)
        {
            PropertiesObjectType objType = null;
            if (obj != null)
            {
                objType = obj.ObjectType();
            }
            if (objType != type)
            {
                type = DIFFERENT_OBJECT_TYPE;
                return;
            }
        }
        if (type == null)
        {
            return; // null objects, no properties
        }
        // first index: object
        // second index: property
        List <List <Property> > objectPropertiesSets = new List <List <Property> >();

        foreach (PropertiesObject obj in objects)
        {
            objectPropertiesSets.Add(new List <Property>(obj.Properties()));
        }

        int numObjects    = objectPropertiesSets.Count;
        int numProperties = objectPropertiesSets[0].Count;

        for (int propertyI = 0; propertyI < numProperties; propertyI++)
        {
            int      _propertyI    = propertyI; // for use in lambda functions -- won't change
            Property firstProperty = objectPropertiesSets[0][propertyI];

            GetProperty getter = () =>
            {
                object value = objectPropertiesSets[0][_propertyI].getter();
                for (int objectI = 0; objectI < numObjects; objectI++)
                {
                    if (!(objectPropertiesSets[objectI][_propertyI].getter().Equals(value)))
                    {
                        return(NOT_EQUAL_VALUE);
                    }
                }
                return(value);
            };

            SetProperty setter = value =>
            {
                for (int objectI = 0; objectI < numObjects; objectI++)
                {
                    objectPropertiesSets[objectI][_propertyI].setter(value);
                }
            };

            PropertyGUI gui = property =>
            {
                if (property.getter() == (object)NOT_EQUAL_VALUE)
                {
                    GUILayout.BeginHorizontal();
                    PropertyGUIs.AlignedLabel(property);
                    if (GUILayout.Button("different"))
                    {
                        // set all properties to one value
                        property.setter(firstProperty.getter());
                    }
                    GUILayout.EndHorizontal();
                }
                else
                {
                    firstProperty.gui(property);
                }
            };

            properties.Add(new Property(
                               firstProperty.id, firstProperty.name, getter, setter, gui, firstProperty.explicitType));
        }
    }
Exemple #13
0
    public ICollection <Property> Properties()
    {
        return(new Property[]
        {
            new Property("sky", "Sky",
                         () => RenderSettings.skybox,
                         v => {
                SetSky((Material)v);
            },
                         PropertyGUIs.Material("GameAssets/Skies", false, MaterialSelectorGUI.ColorModeSet.UNLIT_ONLY)),
            new Property("amb", "Ambient light intensity",
                         () => RenderSettings.ambientIntensity,
                         v => RenderSettings.ambientIntensity = (float)v,
                         PropertyGUIs.Slider(0, 3)),
            new Property("sin", "Sun intensity",
                         () => RenderSettings.sun.intensity,
                         v => RenderSettings.sun.intensity = (float)v,
                         PropertyGUIs.Slider(0, 3)),
            new Property("sco", "Sun color",
                         () => RenderSettings.sun.color,
                         v => RenderSettings.sun.color = (Color)v,
                         PropertyGUIs.Color),
            new Property("spi", "Sun pitch",
                         () => {
                float value = RenderSettings.sun.transform.rotation.eulerAngles.x;
                if (value > 270)
                {
                    value -= 360;
                }
                return value;
            },
                         v => {
                Vector3 eulerAngles = RenderSettings.sun.transform.rotation.eulerAngles;
                eulerAngles.x = (float)v;
                RenderSettings.sun.transform.rotation = Quaternion.Euler(eulerAngles);
            },
                         PropertyGUIs.Slider(-90, 90)),
            new Property("sya", "Sun yaw",
                         () => RenderSettings.sun.transform.rotation.eulerAngles.y,
                         v => {
                Vector3 eulerAngles = RenderSettings.sun.transform.rotation.eulerAngles;
                eulerAngles.y = (float)v;
                RenderSettings.sun.transform.rotation = Quaternion.Euler(eulerAngles);

                UpdateSky();
            },
                         PropertyGUIs.Slider(0, 360)),
            new Property("fdn", "Fog density",
                         () => RenderSettings.fog ? Mathf.Sqrt(RenderSettings.fogDensity) : 0.0f,
                         v => {
                float value = (float)v;
                if (value == 0)
                {
                    RenderSettings.fog = false;
                }
                else
                {
                    RenderSettings.fog = true;
                    RenderSettings.fogDensity = value * value;
                }
            },
                         PropertyGUIs.Slider(0, 1)),
            new Property("fco", "Fog color",
                         () => RenderSettings.fogColor,
                         v => RenderSettings.fogColor = (Color)v,
                         PropertyGUIs.Color)
        });
    }
Exemple #14
0
    public override IEnumerable <Property> Properties()
    {
        return(new Property[]
        {
            new Property("sky", "Sky",
                         () => RenderSettings.skybox,
                         v => {
                SetSky((Material)v);
            },
                         PropertyGUIs.Material("Skies", false)),
            new Property("amb", "Ambient light intensity",
                         () => RenderSettings.ambientIntensity,
                         v => RenderSettings.ambientIntensity = (float)v,
                         PropertyGUIs.Slider(0, 3)),
            new Property("sin", "Sun intensity",
                         () => RenderSettings.sun.intensity,
                         v => RenderSettings.sun.intensity = (float)v,
                         PropertyGUIs.Slider(0, 3)),
            new Property("sco", "Sun color",
                         () => RenderSettings.sun.color,
                         v => RenderSettings.sun.color = (Color)v,
                         PropertyGUIs.Color),
            new Property("spi", "Sun pitch",
                         () => {
                float value = RenderSettings.sun.transform.rotation.eulerAngles.x;
                if (value >= 270)
                {
                    value -= 360;
                }
                return value;
            },
                         v => {
                Vector3 eulerAngles = RenderSettings.sun.transform.rotation.eulerAngles;
                eulerAngles.x = (float)v;
                RenderSettings.sun.transform.rotation = Quaternion.Euler(eulerAngles);

                UpdateEnvironment();
            },
                         PropertyGUIs.Slider(-90, 90)),
            new Property("sya", "Sun yaw",
                         () => RenderSettings.sun.transform.rotation.eulerAngles.y,
                         v => {
                Vector3 eulerAngles = RenderSettings.sun.transform.rotation.eulerAngles;
                eulerAngles.y = (float)v;
                RenderSettings.sun.transform.rotation = Quaternion.Euler(eulerAngles);

                UpdateSky();
            },
                         PropertyGUIs.Slider(0, 360)),
            new Property("sha", "Shadows",
                         () => RenderSettings.sun.shadowStrength,
                         v => RenderSettings.sun.shadowStrength = (float)v,
                         PropertyGUIs.Slider(0, 1)),
            new Property("ref", "Reflections",
                         () => GetReflectionProbe().intensity,
                         v => GetReflectionProbe().intensity = (float)v,
                         PropertyGUIs.Slider(0, 1)),
            new Property("fdn", "Fog density",
                         () => RenderSettings.fog ? Mathf.Sqrt(RenderSettings.fogDensity) : 0.0f,
                         v => {
                float value = (float)v;
                if (value == 0)
                {
                    RenderSettings.fog = false;
                }
                else
                {
                    RenderSettings.fog = true;
                    RenderSettings.fogDensity = value * value;
                }
            },
                         PropertyGUIs.Slider(0, 1)),
            new Property("fco", "Fog color",
                         () => RenderSettings.fogColor,
                         v => RenderSettings.fogColor = (Color)v,
                         PropertyGUIs.Color)
        });
    }