コード例 #1
0
ファイル: UseAbility.cs プロジェクト: mxgmn/GENW
    public void Use(Ability ability)
    {
        Ability.TargetType tt = ability.targetType;

        if (tt == Ability.TargetType.Direction || tt == Ability.TargetType.Point || tt == Ability.TargetType.Creature)
            B.ability = ability;

        else if (tt == Ability.TargetType.None)
        {
            PayAbilityCost(ability);

            if (ability is ClassAbility)
            {
                ClassAbility ca = ability as ClassAbility;
                Action<string> log = s => B.log.Add(" " + s, ca.color);

                if (ca.NameIs("Meld"))
                {
                    t.effects.Add("Melded", 20);

                    AnimateByDefault(ability.castTime);
                    log("melds with surroundings.");
                }
                else if (ca.NameIs("Hide in Shadows"))
                {
                    t.effects.Add("Hidden", 20);

                    AnimateByDefault(ability.castTime);
                    log("hides in shadows.");
                }
            }

            else if (ability is ItemAbility)
            {
                ItemAbility ia = ability as ItemAbility;

                if (ability.NameIs("Drink"))
                {
                    if (ia.itemShape == ItemShape.Get("Nourishing Mix")) t.hp.AddStamina(100, true);
                    else if (ia.itemShape == ItemShape.Get("Bottled Blood"))
                    {
                        int amount = t.HasAbility("Omnivore") ? 2 : -2;
                        t.hp.Add(amount, true);
                        t.hp.AddStamina(amount, true);
                    }

                    t.inventory.Remove(ia.itemShape);
                    t.inventory.Add("Empty Bottle");

                    AnimateByDefault(ability.castTime);
                }
                else if (ability.NameIs("Apply to Weapon"))
                {
                    t.effects.Add("Poisoned Weapon", 20, ia.itemShape.name);

                    t.inventory.Remove(ia.itemShape);
                    t.inventory.Add("Empty Bottle");

                    AnimateByDefault(ability.castTime);
                }
                else if (ability.NameIs("Dip"))
                {
                    t.inventory.Remove(ia.itemShape);

                    var query = from o in B.GetAll(t.p.value) select o.CommonName;
                    if (query.Contains("Blood")) t.inventory.Add(ItemShape.Get("Bottled Blood"));
                }
            }

            t.initiative.PassTurn(ability.castTime);
        }
    }
コード例 #2
0
ファイル: UseAbility.cs プロジェクト: mxgmn/GENW
    public void Use(Ability ability, ZPoint.Direction direction)
    {
        if (ability is ClassAbility)
        {
            ClassAbility ca = ability as ClassAbility;
            Action<string> log = s => B.log.Add(" " + s, ca.color);

            if (ca.NameIs("Bull Rush"))
            {
                Kick(t.p.value, direction, 2, true, ability.castTime);
                log("bull-rushes somebody.");
            }
            else if (ca.NameIs("Kick"))
            {
                Kick(t.p.value, direction, 2, false, ability.castTime);
                log("kicks somebody.");
            }
            else if (ca.NameIs("Power Strike"))
            {
                t.effects.Add("Power Strike", 10, direction);

                AnimateByDefault(ability.castTime);
                LocalObject lc = B.Get(t.p.value + direction);
                log("prepares to do a powerful attack" + (lc != null ? " on " + lc.CommonName : "") + ".");
            }
            else if (ca.NameIs("Hurl Rock"))
            {
                ZPoint p = t.p.value + direction;
                while (B.IsFlat(p) && t.p.Distance(p) <= ability.range) p = p + direction;
                LocalObject lc = B.Get(p);

                B.combatAnimations.Add(new TextureAnimation(NamedTexture.Get("local/stone"), t.p.GC, Battlefield.GC(p), 0.5f * ability.castTime));
                log("throws a rock and hits");

                if (lc != null)
                {
                    Kick(p, direction, 1, true, 0.5f * ability.castTime);
                    t.p.DoDamage(lc, 2, false);

                    log(lc.CommonName + ".");
                }
                else
                {
                    AnimateByDefault(0.5f * ability.castTime);
                    log("nobody.");
                }
            }
        }
        else if (ability is ItemAbility)
        {
            ItemAbility ia = ability as ItemAbility;
            if (ability.NameIs("Throw"))
            {
                ZPoint p = t.p.value + direction;
                while (B.IsFlat(p) && t.p.Distance(p) <= ability.range) p = p + direction;
                LocalObject lc = B.Get(p);

                B.combatAnimations.Add(new TextureAnimation(ia.itemShape.texture, t.p.GC, Battlefield.GC(p), ability.castTime));

                if (ia.itemShape.name == "Net")
                {
                    if (lc != null) lc.effects.Add("Net", 6);
                    else B.Add(new LocalObject(new Item(ia.itemShape)), p);
                }
                else
                {
                    if (lc != null) t.p.DoDamage(lc, t.attack.Damage * 2, false);
                    B.Add(new LocalObject(new Item(ia.itemShape)), p);
                }

                t.inventory.Remove(ia.itemShape);
            }
            else if (ability.NameIs("Push"))
            {
                ZPoint p = t.p.value + direction;
                while (B.IsFlat(p) && t.p.Distance(p) <= ability.range) p = p + direction;
                LocalObject lc = B.Get(p);

                if (lc != null) Kick(lc.p.value, direction, 2, true, ability.castTime);
            }
            else if (ability.NameIs("Power Shot"))
            {
                var ray = B.Ray(t.p.value, direction, ability.range, true);
                B.combatAnimations.Add(new TextureAnimation(NamedTexture.Get("local/arrow"),
                    Battlefield.GC(ray.First()), Battlefield.GC(ray.Last()), ability.castTime));
                foreach (LocalObject lc in B.ActiveObjects.Where(c => c.p.value.IsIn(ray) && c != t))
                    t.p.DoDamage(lc, ia.itemShape.bonus.damage + 1, false);
            }
        }
    }