Exemplo n.º 1
0
        public override void OnInspectorGUI()
        {
            var creature   = target as Creature;
            var regenerate = false;

            EditorGUILayout.PropertyField(_speciesProperty);
            EditorGUILayout.Space();

            if (creature.Species.Ecosystem.CreatureGenerationInstructions != null)
            {
                regenerate = GUILayout.Button(_regenerate);
                EditorGUILayout.Space();
            }

            using (new UndoScope(creature))
            {
                _traits.Draw();
                EditorGUILayout.Space();
                _moves.DrawList();
                EditorGUILayout.Space();
                _skills.DrawList();
            }

            if (regenerate)
            {
                EditorUpdater.StartCoroutine(creature.GenerateTraits(_context));
            }
        }
Exemplo n.º 2
0
        private void Add(object data)
        {
            var roster   = target as Roster;
            var species  = data as Species;
            var creature = Creature.Create(species);

            if (roster.Ecosystem.CreatureGenerationInstructions && (_context == null || !_context.IsRunning))
            {
                _context = new EcosystemInstructionContext(roster, "Edit Creature", null);
                EditorUpdater.StartCoroutine(creature.GenerateTraits(_context));
            }

            using (new UndoScope(roster))
            {
                Undo.RegisterCreatedObjectUndo(creature, "Undo create creature");
                roster.Creatures.Add(creature);
            }
        }
Exemplo n.º 3
0
        private void DrawSkill(Rect rect, int index)
        {
            var creature  = target as Creature;
            var skill     = creature.Species.Skills[index];
            var count     = creature.LearnCount(skill);
            var showClear = creature.HasLearned(skill);
            var showLearn = creature.CanLearn(skill);
            var label     = count == 0 ? "Unlearned" : (skill.LearnLimit == 1 ? "Learned" : string.Format("Learned {0} Times", count));

            var buttonSize = EditorGUIUtility.singleLineHeight;
            var buttonY    = rect.y + (rect.height - buttonSize) * 0.5f;
            var labelWidth = rect.width * 0.7f - 5;

            labelWidth -= buttonSize + 4;
            labelWidth -= buttonSize + 4;

            var nameRect  = new Rect(rect.x, rect.y, rect.width * 0.3f, rect.height);
            var labelRect = new Rect(nameRect.xMax + 5, rect.y, labelWidth, rect.height);
            var learnRect = new Rect(labelRect.xMax, buttonY, buttonSize, buttonSize);
            var clearRect = new Rect(learnRect.xMax + 4, buttonY, buttonSize, buttonSize);

            EditorGUI.LabelField(nameRect, skill.Name);
            EditorGUI.LabelField(labelRect, label);

            var learn = showLearn && GUI.Button(learnRect, "+");
            var clear = showClear && GUI.Button(clearRect, "x");

            if (learn)
            {
                EditorUpdater.StartCoroutine(creature.TeachSkill(_context, skill));
            }
            if (clear)
            {
                creature.ForgetSkill(skill);
            }

            if (learn || clear)
            {
                EditorUtility.SetDirty(creature);
            }
        }
Exemplo n.º 4
0
        private void DrawTrait(Rect rect, int index)
        {
            var creature = target as Creature;
            var name     = creature.Traits.Variables[index].Name;

            var variableRect = new Rect(rect.x, rect.y, rect.width * 0.8f, EditorGUIUtility.singleLineHeight);
            var applyRect    = new Rect(variableRect.xMax + 5, variableRect.y, rect.width - variableRect.width - 5, variableRect.height);

            var hasInstruction = creature.Species.Ecosystem.CreatureUpdateInstructions.ContainsKey(name);

            _traits.DrawStoreEntry(variableRect, index);

            GUI.enabled = hasInstruction;

            if (GUI.Button(applyRect, hasInstruction ? _apply : _applyDisabled))
            {
                EditorUpdater.StartCoroutine(creature.UpdateTraits(_context, name));
            }

            GUI.enabled = true;
        }