Exemplo n.º 1
0
        public static void Draw(Rect position, InstructionVariable variable, GUIContent label)
        {
            var typeNames = GetTypeNames();

            var typeWidth = position.width * 0.5f;
            var typeRect  = new Rect(position.x, position.y, typeWidth, position.height);
            var valueRect = new Rect(typeRect.xMax + 5, position.y, position.width - typeWidth - 5, position.height);

            var index = GetTypeIndex(variable);

            using (var changes = new EditorGUI.ChangeCheckScope())
            {
                index = EditorGUI.Popup(typeRect, index, typeNames);

                if (changes.changed)
                {
                    SetTypeIndex(variable, index);
                }
            }

            if (variable.IsReference)
            {
                VariableReferenceDrawer.DrawName(valueRect, variable.Reference);
            }
            else
            {
                VariableValueDrawer.DrawValue(valueRect, variable.Value, null, null);
            }
        }
Exemplo n.º 2
0
        private void DrawMove(Rect rect, int index)
        {
            var creature = target as Creature;
            var move     = creature.Moves[index];

            var labelRect  = new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight);
            var traitsRect = new Rect(rect.x + 10, labelRect.yMax + 5, rect.width - 10, EditorGUIUtility.singleLineHeight);

            EditorGUI.LabelField(labelRect, move.Ability.name);

            for (var i = 0; i < move.Traits.Count; i++)
            {
                var trait     = move.Traits.GetVariable(i);
                var traitRect = EditorGUI.PrefixLabel(traitsRect, new GUIContent(trait.Name));
                VariableValueDrawer.DrawValue(traitRect, trait, null, null);
                traitsRect.y += EditorGUIUtility.singleLineHeight + 5;
            }
        }
Exemplo n.º 3
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            var typeNames           = GetTypeNames();
            var nameProperty        = property.FindPropertyRelative("Name");
            var isReferenceProperty = property.FindPropertyRelative("IsReference");

            var nameWidth = position.width * 0.3f;
            var typeWidth = position.width * 0.3f;
            var nameRect  = new Rect(position.x, position.y, nameWidth, position.height);
            var typeRect  = new Rect(nameRect.xMax + 5, position.y, typeWidth, position.height);
            var valueRect = new Rect(typeRect.xMax + 5, position.y, position.width - nameWidth - typeWidth - 10, position.height);

            var index = GetTypeIndex(property);

            EditorGUI.PropertyField(nameRect, nameProperty, GUIContent.none);

            using (var changes = new EditorGUI.ChangeCheckScope())
            {
                index = EditorGUI.Popup(typeRect, index, typeNames);

                if (changes.changed)
                {
                    SetTypeIndex(property, index);
                }
            }

            if (isReferenceProperty.boolValue)
            {
                var referenceProperty = property.FindPropertyRelative("Reference");
                VariableReferenceDrawer.DrawName(valueRect, referenceProperty);
            }
            else
            {
                var valueProperty = property.FindPropertyRelative("Value");
                VariableValueDrawer.DrawValue(valueRect, valueProperty);
            }
        }
Exemplo n.º 4
0
        private void DrawSkill(Rect rect, int index)
        {
            var skill  = _species.Skills[index];
            var inputs = _inputLists[index];

            var labelRect       = new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight);
            var conditionRect   = new Rect(rect.x + 10, labelRect.yMax + 5, rect.width - 10, EditorGUIUtility.singleLineHeight);
            var limitRect       = new Rect(rect.x + 10, conditionRect.yMax + 5, rect.width * 0.75f, EditorGUIUtility.singleLineHeight);
            var limitAmountRect = new Rect(limitRect.xMax + 5, limitRect.y, rect.width - limitRect.width - 15, limitRect.height);
            var instructionRect = new Rect(rect.x + 10, limitRect.yMax + 5, rect.width - 10, EditorGUIUtility.singleLineHeight);
            var inputsRect      = new Rect(rect.x + 10, instructionRect.yMax + 5, rect.width - 10, EditorGUIUtility.singleLineHeight);

            EditorGUI.LabelField(labelRect, skill.Name, EditorStyles.boldLabel);

            using (var changes = new EditorGUI.ChangeCheckScope())
            {
                conditionRect = EditorGUI.PrefixLabel(conditionRect, new GUIContent("Condition"));
                var condition = EditorGUI.DelayedTextField(conditionRect, skill.Condition.Statement);

                if (changes.changed)
                {
                    skill.Condition.Statement = condition;
                    skill.UpdateTriggers();
                }
            }

            var limitIndex = EditorGUI.Popup(limitRect, "Learn Limit", skill.LearnLimit == 0 ? 2 : (skill.LearnLimit == 1 ? 0 : 1), _limits);

            if (limitIndex == 0)
            {
                skill.LearnLimit = 1;
            }
            else if (limitIndex == 1)
            {
                if (skill.LearnLimit == 0 || skill.LearnLimit == 1)
                {
                    skill.LearnLimit = 10;
                }

                skill.LearnLimit = EditorGUI.IntField(limitAmountRect, skill.LearnLimit);
            }
            else if (limitIndex == 2)
            {
                skill.LearnLimit = 0;
            }

            using (var changes = new EditorGUI.ChangeCheckScope())
            {
                instructionRect = EditorGUI.PrefixLabel(instructionRect, new GUIContent("Instruction"));
                skill.Instruction.Instruction = InstructionDrawer.Draw(instructionRect, null, skill.Instruction.Instruction, GUIContent.none);

                if (changes.changed && skill.Instruction.Instruction != null)
                {
                    RefreshInputs(inputs, skill.Instruction);
                }
            }

            for (var i = 0; i < skill.Instruction.Inputs.Count; i++)
            {
                var input     = skill.Instruction.Inputs[i];
                var inputRect = EditorGUI.PrefixLabel(inputsRect, new GUIContent(input.Name));
                VariableValueDrawer.DrawValue(inputRect, input, inputs.Inputs[i].Type, inputs.Inputs[i].ParentType);
                inputsRect.y += EditorGUIUtility.singleLineHeight + 5;
            }
        }