Exemplo n.º 1
0
        public void TestMethod1()
        {
            IEntity entity        = new Entity(null, Vector2.Zero, Vector2.Zero, false);
            var     healComponent = new HealComponent(entity);

            entity.Update();

            Assert.IsTrue(entity.HasComponent <HealComponent>());
            Assert.AreSame(healComponent, entity.GetComponent <HealComponent>());
            Assert.AreSame(entity, entity.GetComponent <HealComponent>().Parent);
        }
Exemplo n.º 2
0
    public override void Execute(Spell spell, RollContext context)
    {
        context.GetCaster().OnSpellComponentCaster.Invoke(spell, context, this);
        int heal = GetValue();

        GetTargets(context).ForEach(pawn => {
            HealComponent singleTarget = new HealComponent(targetType, heal);
            pawn.OnSpellComponentTarget.Invoke(spell, context, singleTarget);
            EventBus.DamageHealEvent healEvent = new EventBus.DamageHealEvent(spell, singleTarget, singleTarget.GetValue());
            pawn.CmdHeal(healEvent);
        });
    }
Exemplo n.º 3
0
    public void LoadData(List<string> data, bool isHeroSkill)
    {
        for (int i = 1; i < data.Count; i++)
        {
            switch (data[i])
            {
                case ".id":
                    Id = data[++i];
                    break;
                case ".level":
                    Level = int.Parse(data[++i]);
                    break;
                case ".type":
                    Type = data[++i];
                    break;
                case ".atk":
                    Accuracy = float.Parse(data[++i]) / 100;
                    break;
                case ".dmg":
                    if(isHeroSkill)
                        DamageMod = float.Parse(data[++i]) / 100;
                    else
                    {
                        DamageMin = float.Parse(data[++i]);
                        DamageMax = float.Parse(data[++i]);
                    }
                    break;
                case ".crit":
                    CritMod = float.Parse(data[++i]) / 100;
                    break;
                case ".launch":
                    LaunchRanks = new FormationSet(data[++i]);
                    break;
                case ".target":
                    if (++i < data.Count && data[i--][0] != '.')
                        TargetRanks = new FormationSet(data[++i]);
                    else
                        TargetRanks = new FormationSet("");
                    break;
                case ".is_crit_valid":
                    IsCritValid = bool.Parse(data[++i].ToLower());
                    break;
                case ".self_target_valid":
                    IsSelfValid = bool.Parse(data[++i].ToLower());
                    break;
                case ".extra_targets_count":
                    ExtraTargetsCount = int.Parse(data[++i]);
                    break;
                case ".extra_targets_chance":
                    ExtraTargetsChance = float.Parse(data[++i]);
                    break;
                case ".is_user_selected_targets":
                    IsUserSelectedTarget = bool.Parse(data[++i].ToLower());
                    break;
                case ".can_miss":
                    CanMiss = bool.Parse(data[++i].ToLower());
                    break;
                case ".is_continue_turn":
                    IsContinueTurn = bool.Parse(data[++i].ToLower());
                    break;
                case ".per_turn_limit":
                    LimitPerTurn = int.Parse(data[++i]);
                    break;
                case ".per_battle_limit":
                    LimitPerBattle = int.Parse(data[++i]);
                    break;
                case ".valid_modes":
                    while (++i < data.Count && data[i--][0] != '.')
                    {
                        if (data[++i].Length < 2)
                            continue;

                        ValidModes.Add(data[i]);
                    }
                    break;
                case ".human_effects":
                    var humanEffects = new List<Effect>();
                    ModeEffects.Add("human", humanEffects);
                    while (++i < data.Count && data[i--][0] != '.')
                    {
                        if (data[++i].Length < 2)
                            continue;

                        if (DarkestDungeonManager.Data.Effects.ContainsKey(data[i]))
                            humanEffects.Add(DarkestDungeonManager.Data.Effects[data[i]]);
                        else
                            Debug.LogError("Missing effect " + data[i] + " in skill " + Id);
                    }
                    break;
                case ".beast_effects":
                    var beastEffects = new List<Effect>();
                    ModeEffects.Add("beast", beastEffects);
                    while (++i < data.Count && data[i--][0] != '.')
                    {
                        if (data[++i].Length < 2)
                            continue;

                        if (DarkestDungeonManager.Data.Effects.ContainsKey(data[i]))
                            beastEffects.Add(DarkestDungeonManager.Data.Effects[data[i]]);
                        else
                            Debug.LogError("Missing effect " + data[i] + " in skill " + Id);
                    }
                    break;
                case ".effect":
                    while (++i < data.Count && data[i--][0] != '.')
                    {
                        if (data[++i].Length < 2)
                            continue;

                        if(DarkestDungeonManager.Data.Effects.ContainsKey(data[i]))
                            Effects.Add(DarkestDungeonManager.Data.Effects[data[i]]);
                        else
                            Debug.LogError("Missing effect " + data[i] + " in skill " + Id);
                    }
                    break;
                case ".generation_guaranteed":
                    IsGenerationGuaranteed = bool.Parse(data[++i].ToLower());
                    break;
                case ".is_knowledgeable":
                    IsKnowledgeable = bool.Parse(data[++i].ToLower());
                    break;
                case ".heal":
                    Heal = new HealComponent(int.Parse(data[++i]), int.Parse(data[++i]));
                    break;
                case ".move":
                    Move = new MoveComponent(int.Parse(data[++i]), int.Parse(data[++i]));
                    break;
                case "combat_skill:":
                    break;
                default:
                    Debug.LogError("Unexpected token in combat skill: " + data[i]);
                    break;
            }
        }
        if (Accuracy == 0 || TargetRanks.IsSelfFormation || TargetRanks.IsSelfTarget)
        {
            if (Heal == null)
                Category = SkillCategory.Support;
            else
                Category = SkillCategory.Heal;
        }
    }