示例#1
0
        /// <summary>
        /// Check if the ITriggeringComponent is an IVitalsComponent, and if so that it has the vital that matches the trigger.
        /// </summary>
        /// <param name="frameInt"></param>
        /// <param name="contactEvent"></param>
        /// <returns>Returns true if this triggerer is a IVitalsComponent, and contains the indicated vital type.</returns>
        public static Vital GetTriggeringVital(this ContactEvent contactEvent, VitalNameType vitalNameType)
        {
            var ivc = (contactEvent.itc as IVitalsComponent);

            if (ReferenceEquals(ivc, null))
            {
                return(null);
            }

            Vitals vitals = ivc.Vitals;
            Vital  vital  = vitals.GetVital(vitalNameType);

            return(vital);
        }
示例#2
0
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            property.serializedObject.Update();

            SerializedProperty vitalDefs = property.FindPropertyRelative("vitalDefs");
            Vitals             ivitals   = (PropertyDrawerUtility.GetParent(vitalDefs) as Vitals);
            int vitalsCount = ivitals.vitalDefs.Count;

            float h = 0;

            for (int i = 0; i < vitalsCount; ++i)
            {
                h += EditorGUI.GetPropertyHeight(vitalDefs.GetArrayElementAtIndex(i));
                h += ADD_BUTTON_HGHT + VitalDefinitionDrawer.PAD * 2 + 2;
            }

            return(h);
        }
示例#3
0
        public override IVitalsComponent ApplyVitalsSource(Object vs)
        {
            var ivc = base.ApplyVitalsSource(vs);

            /// Apply this to Vitals to trigger its properties for dealing with changing Vitals
            Vitals     = (ivc != null) ? ivc.Vitals : null;
            vitalIndex = ivc == null ? -1 : ivc.Vitals.GetIVitalIndex(targetVital);

#if UNITY_EDITOR
            /// Changes to index should update the default bars and such in the editor.
            if (vitalIndex != prevIndex)
            {
                Recalculate();
            }

            prevIndex = vitalIndex;
#endif
            return(ivc);
        }
示例#4
0
 public Frame(int frameId, Vitals vitals) : base(frameId)
 {
     vitalsData = new VitalsData(vitals);
 }
示例#5
0
        public override void OnGUI(Rect r, SerializedProperty property, GUIContent label)
        {
            //base.OnGUI(r, property, label);

            property.serializedObject.Update();

            //property.serializedObject.Update();

            SerializedProperty vitalDefs = property.FindPropertyRelative("vitalDefs");
            Vitals             ivitals   = (PropertyDrawerUtility.GetParent(vitalDefs) as Vitals);

            int vitalsCount = vitalDefs.arraySize;

            int addIndex = -1;

            //int delIndex = -1;
            for (int i = 0; i < vitalsCount; ++i)
            {
                var element = vitalDefs.GetArrayElementAtIndex(i);
                r.height = EditorGUI.GetPropertyHeight(element);

                EditorGUI.PropertyField(new Rect(r), element, false);

                if (i > 0)
                {
                    const int XWIDTH = 18;
                    Rect      xr     = r;
                    xr.xMin   = xr.xMax - XWIDTH - VitalDefinitionDrawer.PAD;
                    xr.yMin  += VitalDefinitionDrawer.PAD;
                    xr.height = ADD_BUTTON_HGHT;
                    xr.width  = XWIDTH;
                    if (GUI.Button(xr, "X"))
                    {
                        Undo.RecordObject(vitalDefs.serializedObject.targetObject, "Delete Vital");
                        ivitals.VitalDefs.Remove(ivitals.VitalDefs[i]);
                        EditorUtility.SetDirty(vitalDefs.serializedObject.targetObject);
                        AssetDatabase.Refresh();
                        break;
                    }
                }

                r.yMin += r.height + VitalDefinitionDrawer.PAD + 2;

                r.height = ADD_BUTTON_HGHT;

                const int ADDMARGIN = 80;
                Rect      addrect   = new Rect(r)
                {
                    xMin = r.xMin + 4 + ADDMARGIN, xMax = r.xMax - ADDMARGIN
                };
                if (GUI.Button(addrect, "Add Vital", (GUIStyle)"MiniToolbarButton"))
                {
                    addIndex = i + 1;
                }

                r.yMin += r.height + VitalDefinitionDrawer.PAD;
            }

            if (addIndex != -1)
            {
                Undo.RecordObject(vitalDefs.serializedObject.targetObject, "Add Vital");
                vitalDefs.InsertArrayElementAtIndex(addIndex);
                EditorUtility.SetDirty(vitalDefs.serializedObject.targetObject);
                property.serializedObject.ApplyModifiedProperties();
                AssetDatabase.Refresh();
            }
        }
示例#6
0
 public VitalsData(Vitals vitals)
 {
     this.vitals = vitals;
     datas       = new VitalData[vitals.VitalArray.Length];
 }