Exemplo n.º 1
0
    void OnEnable()
    {
        emitter = (PolygonEmitter)target;
        //new the uninitialized vas
        // if (emitter == null)
        // emitter = new PolygonEmitter();

        patternList = new ReorderableList(
            serializedObject,
            serializedObject.FindProperty("patterns"),
            true,
            true,
            true,
            true
            );
        patternList.drawElementCallback =
            (Rect rect, int index, bool isActive, bool isFocused) =>
        {
            var element = patternList.serializedProperty.GetArrayElementAtIndex(index);

            rect.y += 2;
            EditorGUI.PropertyField(
                new Rect(rect.x, rect.y, 250, EditorGUIUtility.singleLineHeight),
                element.FindPropertyRelative("spawnPattern"),
                GUIContent.none
                );

            rect.x += 250 + 30;
            EditorGUI.PropertyField(
                new Rect(rect.x, rect.y, 70, EditorGUIUtility.singleLineHeight),
                element.FindPropertyRelative("repeat"),
                GUIContent.none
                );
            rect.x += 70 + 30;
            EditorGUI.PropertyField(
                new Rect(rect.x, rect.y, 70, EditorGUIUtility.singleLineHeight),
                element.FindPropertyRelative("delay"),
                GUIContent.none
                );
            rect.x += 70;
        };
        patternList.drawHeaderCallback =
            (Rect rect) =>
        {
            EditorGUI.LabelField(
                new Rect(rect.x, rect.y, 250, EditorGUIUtility.singleLineHeight),
                "Attack patterns"
                );
            rect.x += 250 + 30;
            EditorGUI.LabelField(
                new Rect(rect.x + 10, rect.y, 250, EditorGUIUtility.singleLineHeight),
                "repeat"
                );
            rect.x += 70 + 30;
            EditorGUI.LabelField(
                new Rect(rect.x + 10, rect.y, 250, EditorGUIUtility.singleLineHeight),
                "delay"
                );
        };
    }
Exemplo n.º 2
0
    public void LoadEmitter(PolygonEmitter emitter)
    {
        e = emitter;

        emitterObject = GameObject.Instantiate(e.visualObject, e.position, Quaternion.identity) as GameObject;
        emitterObject.transform.localScale *= e.scale;
        emitterObject.GetComponent <SpriteRenderer>().sortingOrder = 2;
        enemy      = emitterObject.GetComponent <Enemy>();
        enemy.life = e.life;
        enemy.name = e.name;
        e.patterns.ForEach(sp => sp.spawnPattern.attachedGameObject = emitterObject);
        if (e.first != null)
        {
            e.first.attachedGameObject = emitterObject;
        }
        if (e.last != null)
        {
            e.last.attachedGameObject = emitterObject;
        }
    }
Exemplo n.º 3
0
    void OnEnable()
    {
        stage       = (PolygonStage)target;
        emitterList = new ReorderableList(
            serializedObject,
            serializedObject.FindProperty("emitters"),
            true,
            true,
            true,
            true
            );

        emitterList.drawElementCallback =
            (Rect rect, int index, bool isActive, bool isFocused) =>
        {
            //get the PolygonEmitter element:
            var            element = emitterList.serializedProperty.GetArrayElementAtIndex(index);
            PolygonEmitter peo     = element.objectReferenceValue as System.Object as PolygonEmitter;

            rect.y += 2;
            EditorGUI.PropertyField(
                new Rect(rect.x, rect.y, 300, EditorGUIUtility.singleLineHeight),
                element,
                GUIContent.none
                );
            rect.x += 300 + 20;

            //add missing delay for emitters
            while (stage.transitionDelay.Count < stage.emitters.Count)
            {
                stage.transitionDelay.Add(0);
            }

            if (peo != null && stage.transitionDelay.Count > index)
            {
                EditorGUI.LabelField(
                    new Rect(rect.x, rect.y, 90, EditorGUIUtility.singleLineHeight),
                    "transition (ms)"
                    );
                rect.x += 90 + 20;
                stage.transitionDelay[index] = EditorGUI.FloatField(
                    new Rect(rect.x, rect.y, 60, EditorGUIUtility.singleLineHeight),
                    stage.transitionDelay[index]
                    );
            }
        };
        emitterList.onSelectCallback = (ReorderableList l) => {
            var prefab = l.serializedProperty.GetArrayElementAtIndex(l.index).objectReferenceValue as System.Object as PolygonEmitter;
            if (prefab)
            {
                EditorGUIUtility.PingObject(prefab);
            }
        };
        emitterList.onRemoveCallback = (ReorderableList l) => {
            if (l.serializedProperty.GetArrayElementAtIndex(l.index).objectReferenceValue as System.Object as PolygonEmitter != null)
            {
                ReorderableList.defaultBehaviours.DoRemoveButton(l);
            }
            ReorderableList.defaultBehaviours.DoRemoveButton(l);
        };
        //new the uninitialized vas
    }