Example #1
0
    void Awake()
    {
        AttributeManager attributeManager = GetComponent <AttributeManager>();

        attributeManager.AddAttribute(AttributeType.Mana, new ResourceModifier.Attribute(100, 0, 1000));
        attributeManager.AddAttribute(AttributeType.ManaMax, new BasicAttribute(150, 0, 1000));
        attributeManager.AddAttribute(AttributeType.ManaRegen, new BasicAttribute(0.5f, 0, 100));
        attributeManager.AddAttribute(AttributeType.HealPower, new BasicAttribute(50, 0, 1000));
        attributeManager.AddModifier(Factory.GetModifier(AttributModifierType.Resource, gameObject, new ResourceModifier.Params(AttributeType.ManaRegen, AttributeType.ManaMax, AttributeType.Mana)));

        SkillGroup       progressTrackerProvider = GetComponent <SkillGroup>();
        GameObject       progressTracker         = progressTrackerProvider.CreateSkill(DataManager.Instance.CreateDisplaySkillData(SkillType.HealSingleCharacter));
        ASkillController skillController         = progressTracker.GetComponent <ASkillController>();
        ASkill           skill = new HealSingleCharacterSkill(gameObject, 3f, 50f);

        skillController.Skill           = new InteractionSkill(new SelectCharacterInteraction(this), skill);
        skillController.ProgressTracker = progressTracker.GetComponent <IProgressTracker>();
    }
        public void ListIterator(SerializedProperty listProperty, ref SerializedProperty visible)
        {
            Attributes_Debug.boolValue = EditorGUILayout.Toggle(new GUIContent("Debug Mode", "Enables editing attribute points"), Attributes_Debug.boolValue);

            EditorGUILayout.BeginHorizontal();
            visible.boolValue = EditorGUILayout.Foldout(visible.boolValue, listProperty.name, boldFoldOut);
            if (Button("+", miniButton, GUILayout.Width(20)))
            {
                Undo.RecordObject(manager, "Before Attribute Added");
                manager.AddAttribute(new Attribute()
                {
                    Name = string.Format("Attribute{0}", manager.Attributes.Count)
                });
            }
            EditorGUILayout.EndHorizontal();

            if (visible.boolValue)
            {
                EditorGUI.indentLevel++;
                for (int i = 0; i < listProperty.arraySize; i++)
                {
                    SerializedProperty attribute = listProperty.GetArrayElementAtIndex(i);
                    DrawAttribute(attribute, i);
                }
                EditorGUI.indentLevel--;
            }

            if (removeAttribute != null)
            {
                Undo.RecordObject(manager, "Before Attribute Removed");
                manager.RemoveAttribute(removeAttribute);
                removeAttribute = null;
            }
            if (moveFrom >= 0 && moveTo >= 0 && moveFrom != moveTo)
            {
                Undo.RecordObject(manager, "Before Attribute Move");
                Attribute temp = manager.Attributes[moveTo];
                manager.Attributes[moveTo]   = manager.Attributes[moveFrom];
                manager.Attributes[moveFrom] = temp;
            }
            moveFrom = -1;
            moveTo   = -1;
        }
    public void InitCharacter(CharacterType p_charachterType, BaseCharacter p_character)
    {
        AttributeManager attributeManager        = p_character.GetComponent <AttributeManager>();
        SkillGroup       progressTrackerProvider = p_character.GetComponent <SkillGroup>();

        switch (p_charachterType)
        {
        case CharacterType.None:
            // Nothing to do
            break;

        case CharacterType.LittleWarrior:
        {
            attributeManager.AddAttribute(AttributeType.Health, new ResourceModifier.Attribute(35, 0, 1000));
            attributeManager.AddAttribute(AttributeType.HealthMax, new BasicAttribute(35, 0, 1000));
            attributeManager.AddAttribute(AttributeType.HealthRegen, new BasicAttribute(0, 0, 100));
            attributeManager.AddAttribute(AttributeType.Damage, new BasicAttribute(1, 0, 1000));
            attributeManager.AddAttribute(AttributeType.AttackRate, new BasicAttribute(1, 0, 1000));
            attributeManager.AddModifier(Factory.GetModifier(AttributModifierType.Resource, p_character.gameObject, new ResourceModifier.Params(AttributeType.HealthRegen, AttributeType.HealthMax, AttributeType.Health)));
            attributeManager.AddModifier(Factory.GetModifier(AttributModifierType.DurationRatio, p_character.gameObject, new DurationModifier.Params <float>(null, false, 10, 2.0f, AttributeType.AttackRate, AttributeValueType.RelativeBonus)));

            GameObject       skill           = progressTrackerProvider.CreateSkill(CreateDisplaySkillData(SkillType.HitSingleCharacter));
            ASkillController skillController = skill.GetComponent <ASkillController>();
            skillController.Skill           = new HitSingleCharacterSkill(p_character.gameObject, AttributeType.AttackRate);
            skillController.ProgressTracker = skill.GetComponent <IProgressTracker>();
        }
        break;

        case CharacterType.Warrior:
        {
            attributeManager.AddAttribute(AttributeType.Health, new ResourceModifier.Attribute(120, 0, 1000));
            attributeManager.AddAttribute(AttributeType.HealthMax, new BasicAttribute(120, 0, 1000));
            attributeManager.AddAttribute(AttributeType.HealthRegen, new BasicAttribute(0, 0, 100));
            attributeManager.AddAttribute(AttributeType.Damage, new BasicAttribute(5, 0, 1000));
            attributeManager.AddAttribute(AttributeType.AttackRate, new BasicAttribute(2, 0, 1000));
            attributeManager.AddModifier(Factory.GetModifier(AttributModifierType.Resource, p_character.gameObject, new ResourceModifier.Params(AttributeType.HealthRegen, AttributeType.HealthMax, AttributeType.Health)));
            attributeManager.AddModifier(Factory.GetModifier(AttributModifierType.DurationRatio, p_character.gameObject, new DurationModifier.Params <float>(null, false, 10, 2.0f, AttributeType.AttackRate, AttributeValueType.RelativeBonus)));

            GameObject       skill           = progressTrackerProvider.CreateSkill(CreateDisplaySkillData(SkillType.HitSingleCharacter));
            ASkillController skillController = skill.GetComponent <ASkillController>();
            skillController.Skill           = new HitSingleCharacterSkill(p_character.gameObject, AttributeType.AttackRate);
            skillController.ProgressTracker = skill.GetComponent <IProgressTracker>();
        }
        break;

        case CharacterType.Goblin:
        {
            attributeManager.AddAttribute(AttributeType.Health, new ResourceModifier.Attribute(80, 0, 1000));
            attributeManager.AddAttribute(AttributeType.HealthMax, new BasicAttribute(80, 0, 1000));
            attributeManager.AddAttribute(AttributeType.HealthRegen, new BasicAttribute(0.5f, 0, 100));
            attributeManager.AddAttribute(AttributeType.Damage, new BasicAttribute(5, 0, 1000));
            attributeManager.AddAttribute(AttributeType.AttackRate, new BasicAttribute(2, 0, 1000));
            attributeManager.AddModifier(Factory.GetModifier(AttributModifierType.Resource, p_character.gameObject, new ResourceModifier.Params(AttributeType.HealthRegen, AttributeType.HealthMax, AttributeType.Health)));
            attributeManager.AddModifier(Factory.GetModifier(AttributModifierType.DurationRatio, p_character.gameObject, new DurationModifier.Params <float>(null, false, 10, 2.0f, AttributeType.AttackRate, AttributeValueType.RelativeBonus)));

            GameObject       skill           = progressTrackerProvider.CreateSkill(CreateDisplaySkillData(SkillType.HitSingleCharacter));
            ASkillController skillController = skill.GetComponent <ASkillController>();
            skillController.Skill           = new HitSingleCharacterSkill(p_character.gameObject, AttributeType.AttackRate);
            skillController.ProgressTracker = skill.GetComponent <IProgressTracker>();
        }
        break;

        case CharacterType.Spider:
        {
            attributeManager.AddAttribute(AttributeType.Health, new ResourceModifier.Attribute(20, 0, 1000));
            attributeManager.AddAttribute(AttributeType.HealthMax, new BasicAttribute(20, 0, 1000));
            attributeManager.AddAttribute(AttributeType.HealthRegen, new BasicAttribute(0.5f, 0, 100));
            attributeManager.AddAttribute(AttributeType.Damage, new BasicAttribute(1, 0, 1000));
            attributeManager.AddAttribute(AttributeType.AttackRate, new BasicAttribute(2, 0, 1000));
            attributeManager.AddModifier(Factory.GetModifier(AttributModifierType.Resource, p_character.gameObject, new ResourceModifier.Params(AttributeType.HealthRegen, AttributeType.HealthMax, AttributeType.Health)));
            attributeManager.AddModifier(Factory.GetModifier(AttributModifierType.DurationRatio, p_character.gameObject, new DurationModifier.Params <float>(null, false, 10, 2.0f, AttributeType.AttackRate, AttributeValueType.RelativeBonus)));


            GameObject       skill           = progressTrackerProvider.CreateSkill(CreateDisplaySkillData(SkillType.HitSingleCharacter));
            ASkillController skillController = skill.GetComponent <ASkillController>();
            skillController.Skill           = new HitSingleCharacterSkill(p_character.gameObject, AttributeType.AttackRate);
            skillController.ProgressTracker = skill.GetComponent <IProgressTracker>();
        }
        break;

        default:
            Debug.Log("The type " + p_charachterType.ToString() + " is not implemented.");
            break;
        }
    }