示例#1
0
        public void OnSelect(Item item)
        {
            var sword = item as ShortSword;

            if (sword != null)
            {
                Sample.Instance.Play(Assets.SND_EVOKE);
                ScrollOfUpgrade.Upgrade(item.CurUser);
                Item.Evoke(item.CurUser);

                GLog.Warning(ShortSword.TxtReforged, item.Name);

                ((MeleeWeapon)item).SafeUpgrade();
                item.CurUser.SpendAndNext(ShortSword.TimeToReforge);

                Badge.ValidateItemLevelAquired(item);
            }
            else
            {
                if (item is Boomerang)
                {
                    GLog.Warning(ShortSword.TxtNotBoomerang);
                }

                if (item.IsEquipped(item.CurUser))
                {
                    item.CurUser.Belongings.Weapon = item as Weapon;
                }
                else
                {
                    item.Collect(item.CurUser.Belongings.Backpack);
                }
            }
        }
示例#2
0
        public override void Execute(Hero hero, string action)
        {
            base.Execute(hero, action);

            if (!action.Equals(AcEat))
            {
                return;
            }

            switch (pdsharp.utils.Random.Int(5))
            {
            case 0:
                GLog.Warning("Oh it's hot!");
                Buff.Affect <Burning>(hero).Reignite(hero);
                break;

            case 1:
                GLog.Warning("You can't feel your legs!");
                Buff.Prolong <Roots>(hero, Paralysis.Duration(hero));
                break;

            case 2:
                GLog.Warning("You are not feeling well.");
                Buff.Affect <Poison>(hero).Set(Poison.DurationFactor(hero) * hero.HT / 5);
                break;

            case 3:
                GLog.Warning("You are stuffed.");
                Buff.Prolong <Slow>(hero, Slow.Duration(hero));
                break;
            }
        }
示例#3
0
        public void OnSelect(Item item)
        {
            if (item != null)
            {
                Sample.Instance.Play(Assets.SND_EVOKE);
                ScrollOfUpgrade.Upgrade(item.CurUser);
                Item.Evoke(item.CurUser);

                GLog.Warning(WandOfMagicMissile.TxtDisenchanted, item.Name);

                item.Upgrade();
                item.CurUser.SpendAndNext(WandOfMagicMissile.TimeToDisenchant);

                Badge.ValidateItemLevelAquired(item);
            }
            else
            {
                //TODO: WandOfMagicMissile
                var wand = item as WandOfMagicMissile;

                if (wand != null)
                {
                    if (wand.DisenchantEquipped)
                    {
                        item.CurUser.Belongings.Weapon = item as KindOfWeapon;
                        item.UpdateQuickslot();
                    }
                    else
                    {
                        item.Collect(item.CurUser.Belongings.Backpack);
                    }
                }
            }
        }
        public static void TeleportHero(Hero hero)
        {
            var count = 10;
            int pos;

            do
            {
                pos = Dungeon.Level.RandomRespawnCell();
                if (count-- <= 0)
                {
                    break;
                }
            } while (pos == -1);

            if (pos == -1)
            {
                GLog.Warning(TxtNoTeleport);
            }
            else
            {
                WandOfBlink.Appear(hero, pos);
                Dungeon.Level.Press(pos, hero);
                Dungeon.Observe();

                GLog.Information(TxtTeleported);
            }
        }
示例#5
0
        public void OnSelect(int?target)
        {
            if (target == null)
            {
                return;
            }

            if (!Level.fieldOfView[target.Value] || !(Level.passable[target.Value] || Level.avoid[target.Value]) || Actor.FindChar(target.Value) != null)
            {
                GLog.Warning(TXT_FOV);
                return;
            }

            CurUser.HP -= (CurUser.HP / 3);

            foreach (var mob in Dungeon.Level.mobs.Where(mob => Level.fieldOfView[mob.pos]))
            {
                Buff.Prolong <Blindness>(mob, 2);
                mob.State = mob.WANDERING;
                mob.Sprite.Emitter().Burst(Speck.Factory(Speck.LIGHT), 4);
            }

            WandOfBlink.Appear(CurUser, target.Value);
            CellEmitter.Get(target.Value).Burst(Speck.Factory(Speck.WOOL), 10);
            Sample.Instance.Play(Assets.SND_PUFF);
            Dungeon.Level.Press(target.Value, CurUser);
            Dungeon.Observe();

            CurUser.SpendAndNext(Actor.Tick);
        }
示例#6
0
        public override void Execute(Hero hero, string action)
        {
            if (action == AcMine)
            {
                if (Dungeon.Depth < 11 || Dungeon.Depth > 15)
                {
                    GLog.Warning(TxtNoVein);
                    return;
                }

                foreach (var neighbour in Level.NEIGHBOURS8)
                {
                    _pos = hero.pos + neighbour;

                    if (Dungeon.Level.map[_pos] != Terrain.WALL_DECO)
                    {
                        continue;
                    }

                    hero.Spend(TimeToMine);
                    hero.Busy();
                    hero.Sprite.DoAttack(_pos, this);
                    return;
                }

                GLog.Warning(TxtNoVein);
            }
            else
            {
                base.Execute(hero, action);
            }
        }
示例#7
0
        public void Upgrade(Armor armor)
        {
            Detach(CurUser.Belongings.Backpack);

            CurUser.Sprite.CenterEmitter().Start(Speck.Factory(Speck.KIT), 0.05f, 10);
            CurUser.Spend(TimeToUpgrade);
            CurUser.Busy();

            GLog.Warning(TxtUpgraded, armor.Name);

            var classArmor = ClassArmor.Upgrade(CurUser, armor);

            if (CurUser.Belongings.Armor == armor)
            {
                CurUser.Belongings.Armor = classArmor;
                ((HeroSprite)CurUser.Sprite).UpdateArmor();
            }
            else
            {
                armor.Detach(CurUser.Belongings.Backpack);
                classArmor.Collect(CurUser.Belongings.Backpack);
            }

            CurUser.Sprite.DoOperate(CurUser.pos);
            Sample.Instance.Play(Assets.SND_EVOKE);
        }
示例#8
0
        public override bool DoEquip(Hero hero)
        {
            if (hero.Belongings.Ring1 != null && hero.Belongings.Ring2 != null)
            {
                GLog.Warning("you can only wear 2 rings at a time");
                return(false);
            }
            if (hero.Belongings.Ring1 == null)
            {
                hero.Belongings.Ring1 = this;
            }
            else
            {
                hero.Belongings.Ring2 = this;
            }

            Detach(hero.Belongings.Backpack);

            Activate(hero);

            cursedKnown = true;
            if (cursed)
            {
                EquipCursed(hero);
                GLog.Negative("your " + this + " tightens around your finger painfully");
            }

            hero.SpendAndNext(TIME_TO_EQUIP);
            return(true);
        }
示例#9
0
        public override void Execute(Hero hero, string action)
        {
            if (action.Equals(AcDrink))
            {
                if (_volume > 0)
                {
                    var value  = (int)Math.Ceiling(Math.Pow(_volume, _pow) / NUM * hero.HT);
                    var effect = Math.Min(hero.HT - hero.HP, value);
                    if (effect > 0)
                    {
                        hero.HP += effect;
                        hero.Sprite.Emitter().Burst(Speck.Factory(Speck.HEALING), _volume > 5 ? 2 : 1);
                        hero.Sprite.ShowStatus(CharSprite.Positive, TxtValue, effect);
                    }

                    _volume = 0;

                    hero.Spend(TimeToDrink);
                    hero.Busy();

                    Sample.Instance.Play(Assets.SND_DRINK);
                    hero.Sprite.DoOperate(hero.pos);

                    UpdateQuickslot();
                }
                else
                {
                    GLog.Warning(TxtEmpty);
                }
            }
            else
            {
                base.Execute(hero, action);
            }
        }
示例#10
0
        public override void DoSpecial()
        {
            var proto = new Shuriken();

            foreach (var mob in Dungeon.Level.mobs)
            {
                if (!Level.fieldOfView[mob.pos])
                {
                    continue;
                }

                CurUser.Sprite.Parent.Recycle <MissileSprite>().Reset(CurUser.pos, mob.pos, proto, this);

                _targets.Add(this, mob);
            }

            if (_targets.Count == 0)
            {
                GLog.Warning(TxtNoEnemies);
                return;
            }

            CurUser.HP -= (CurUser.HP / 3);

            CurUser.Sprite.DoZap(CurUser.pos);
            CurUser.Busy();
        }
示例#11
0
        public override void Execute(Hero hero, string action)
        {
            if (action == AcSet || action == AcReturn)
            {
                if (Dungeon.BossLevel())
                {
                    hero.Spend(TimeToUse);
                    GLog.Warning(TxtPreventing);
                    return;
                }

                for (var i = 0; i < Level.NEIGHBOURS8.Length; i++)
                {
                    if (Actor.FindChar(hero.pos + Level.NEIGHBOURS8[i]) == null)
                    {
                        continue;
                    }

                    GLog.Warning(TxtCreatures);
                    return;
                }
            }

            switch (action)
            {
            case AcSet:
                _returnDepth = Dungeon.Depth;
                _returnPos   = hero.pos;
                hero.Spend(TimeToUse);
                hero.Busy();
                hero.Sprite.DoOperate(hero.pos);
                Sample.Instance.Play(Assets.SND_BEACON);
                GLog.Information(TxtReturn);
                break;

            case AcReturn:
                if (_returnDepth == Dungeon.Depth)
                {
                    Reset();
                    WandOfBlink.Appear(hero, _returnPos);
                    Dungeon.Level.Press(_returnPos, hero);
                    Dungeon.Observe();
                }
                else
                {
                    InterlevelScene.mode        = InterlevelScene.Mode.RETURN;
                    InterlevelScene.returnDepth = _returnDepth;
                    InterlevelScene.returnPos   = _returnPos;
                    Reset();
                    Game.SwitchScene <InterlevelScene>();
                }
                break;

            default:
                base.Execute(hero, action);
                break;
            }
        }
示例#12
0
        public override bool DoEquip(Hero hero)
        {
            if (hero.heroClass == HeroClass.Mage)
            {
                return(base.DoEquip(hero));
            }

            GLog.Warning(TxtNotMage);
            return(false);
        }
示例#13
0
        protected override bool Act()
        {
            if (Target.IsAlive)
            {
                var hero = (Hero)Target;

                if (IsStarving)
                {
                    if (Random.Float() < 0.3f && (Target.HP > 1 || !Target.Paralysed))
                    {
                        GLog.Negative(TxtStarving);
                        hero.Damage(1, this);

                        hero.Interrupt();
                    }
                }
                else
                {
                    var bonus = Target.Buffs <RingOfSatiety.Satiety>().Sum(buff => ((RingOfSatiety.Satiety)buff).Level);

                    var newLevel      = _level + Step - bonus;
                    var statusUpdated = false;
                    if (newLevel >= Starving)
                    {
                        GLog.Negative(TxtStarving);
                        statusUpdated = true;

                        hero.Interrupt();
                    }
                    else if (newLevel >= Hungry && _level < Hungry)
                    {
                        GLog.Warning(TxtHungry);
                        statusUpdated = true;
                    }
                    _level = newLevel;

                    if (statusUpdated)
                    {
                        BuffIndicator.RefreshHero();
                    }
                }

                var step = ((Hero)Target).heroClass == HeroClass.Rogue ? Step * 1.2f : Step;
                Spend(Target.Buff <Shadows>() == null ? step : step *1.5f);
            }
            else
            {
                Deactivate();
            }

            return(true);
        }
示例#14
0
        public static void AutoDrink(Hero hero)
        {
            var vial = hero.Belongings.GetItem <DewVial>();

            if (vial == null || !vial.IsFull)
            {
                return;
            }
            vial.Execute(hero);
            hero.Sprite.Emitter().Start(ShaftParticle.Factory, 0.2f, 3);

            GLog.Warning(TxtAutoDrink);
        }
示例#15
0
            protected override bool Act()
            {
                if (!_ring.Identified && --_ring.ticksToKnow <= 0)
                {
                    var gemName = _ring.Name;
                    _ring.Identify();
                    GLog.Warning(TXT_IDENTIFY, gemName, _ring.ToString());
                    Badge.ValidateItemLevelAquired(_ring);
                }

                Spend(Tick);

                return(true);
            }
示例#16
0
        // 0xDD3333
        public static void Trigger(int pos, Character ch)
        {
            foreach (var mob in Dungeon.Level.mobs.Where(mob => mob != ch))
            {
                mob.Beckon(pos);
            }

            if (Dungeon.Visible[pos])
            {
                GLog.Warning("The trap emits a piercing sound that echoes throughout the dungeon!");
                CellEmitter.Center(pos).Start(Speck.Factory(Speck.SCREAM), 0.3f, 3);
            }

            Sample.Instance.Play(Assets.SND_ALERT);
        }
示例#17
0
    IEnumerator LoadAsyncImpl <T>(string abName, string assetName, System.Action <T> finishLoad) where T : UnityEngine.Object
    {
#if UNITY_EDITOR
        if (!bundleLoadMode)//编辑器下的非Bundle加载模式
        {
            string[] assetPaths = AssetDatabase.GetAssetPathsFromAssetBundleAndAssetName(abName, assetName);

            T target = null;
            if (assetPaths.Length > 0)
            {
                target = AssetDatabase.LoadAssetAtPath <T>(assetPaths[0]);
            }

            yield return(null);

            if (finishLoad != null)
            {
                finishLoad(target);
            }

            yield break;
        }
#endif
        yield return(StartCoroutine(LoadAssetBundle(abName)));

        AssetBundleInfo abInfo = null;
        if (assetBundleInfoDic.TryGetValue(abName, out abInfo))
        {
            AssetBundleRequest abRequest = abInfo.ab.LoadAssetAsync <T>(assetName);
            //abRequest.priority;
            while (!abRequest.isDone)
            {
                yield return(null);
            }

            T res = abRequest.asset as T;
            if (res == null)
            {
                GLog.Warning("assetName :" + assetName + " not find");
            }
            finishLoad(res);
            abInfo.TakeAsset(assetName);
        }
        else
        {
            GLog.Error(abName + " is not find~");
        }
    }
示例#18
0
        protected internal override void DoRead()
        {
            foreach (var mob in Dungeon.Level.mobs)
            {
                mob.Beckon(CurUser.pos);
            }

            GLog.Warning("The scroll emits a challenging roar that echoes throughout the dungeon!");
            SetKnown();

            CurUser.Sprite.CenterEmitter().Start(Speck.Factory(Speck.SCREAM), 0.3f, 3);
            Sample.Instance.Play(Assets.SND_CHALLENGE);
            Invisibility.Dispel();

            CurUser.SpendAndNext(TimeToRead);
        }
示例#19
0
        protected internal virtual bool Steal(Hero hero)
        {
            var item = hero.Belongings.RandomUnequipped();

            if (item == null)
            {
                return(false);
            }

            GLog.Warning(TxtStole, Name, item.Name);

            item.DetachAll(hero.Belongings.Backpack);
            Item = item;

            return(true);
        }
示例#20
0
        public override void Execute(Hero hero, string action)
        {
            if (action.Equals(AcRead))
            {
                if (hero.Buff <Blindness>() != null)
                {
                    GLog.Warning(TxtBlinded);
                    return;
                }

                CurUser = hero;

                HeroSubClass way1 = null;
                HeroSubClass way2 = null;
                switch (hero.heroClass.Ordinal())
                {
                case HeroClassType.Warrior:
                    way1 = HeroSubClass.GLADIATOR;
                    way2 = HeroSubClass.BERSERKER;
                    break;

                case HeroClassType.Mage:
                    way1 = HeroSubClass.BATTLEMAGE;
                    way2 = HeroSubClass.WARLOCK;
                    break;

                case HeroClassType.Rogue:
                    way1 = HeroSubClass.FREERUNNER;
                    way2 = HeroSubClass.ASSASSIN;
                    break;

                case HeroClassType.Huntress:
                    way1 = HeroSubClass.SNIPER;
                    way2 = HeroSubClass.WARDEN;
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                GameScene.Show(new WndChooseWay(this, way1, way2));
            }
            else
            {
                base.Execute(hero, action);
            }
        }
示例#21
0
        private bool ActUnlock(HeroAction.Unlock action)
        {
            var doorCell = action.Dst;

            if (Level.Adjacent(pos, doorCell))
            {
                _theKey = null;
                var door = Dungeon.Level.map[doorCell];

                if (door == Terrain.LOCKED_DOOR)
                {
                    _theKey = Belongings.GetKey <IronKey>(Dungeon.Depth);
                }
                else if (door == Terrain.LOCKED_EXIT)
                {
                    _theKey = Belongings.GetKey <SkeletonKey>(Dungeon.Depth);
                }

                if (_theKey != null)
                {
                    Spend(Key.TIME_TO_UNLOCK);
                    Sprite.DoOperate(doorCell);

                    Sample.Instance.Play(Assets.SND_UNLOCK);
                }
                else
                {
                    GLog.Warning(TxtLockedDoor);
                    Ready();
                }

                return(false);
            }

            if (GetCloser(doorCell))
            {
                return(true);
            }

            Ready();

            return(false);
        }
示例#22
0
        public override void Damage(int dmg, object src)
        {
            base.Damage(dmg, src);

            if (!IsAlive || _enraged || HP >= HT / 4)
            {
                return;
            }

            _enraged = true;
            Spend(Tick);

            if (!Dungeon.Visible[pos])
            {
                return;
            }

            GLog.Warning(TxtEnraged, Name);
            Sprite.ShowStatus(CharSprite.Negative, "enraged");
        }
示例#23
0
 public override void Execute(Hero hero, string action)
 {
     if (action.Equals(AcRead))
     {
         if (hero.Buff <Blindness>() != null)
         {
             GLog.Warning(TxtBlinded);
         }
         else
         {
             CurUser = hero;
             curItem = Detach(hero.Belongings.Backpack);
             DoRead();
         }
     }
     else
     {
         base.Execute(hero, action);
     }
 }
示例#24
0
        public virtual void Choose(HeroSubClass way)
        {
            Detach(CurUser.Belongings.Backpack);

            CurUser.Spend(TimeToRead);
            CurUser.Busy();

            CurUser.subClass = way;

            CurUser.Sprite.DoOperate(CurUser.pos);
            Sample.Instance.Play(Assets.SND_MASTERY);

            SpellSprite.Show(CurUser, SpellSprite.Mastery);
            CurUser.Sprite.Emitter().Burst(Speck.Factory(Speck.MASTERY), 12);
            GLog.Warning("You have chosen the way of the {0}!", Utils.Capitalize(way.Title));

            if (way == HeroSubClass.BERSERKER && CurUser.HP <= CurUser.HT * Fury.Level)
            {
                Buff.Affect <Fury>(CurUser);
            }
        }
示例#25
0
        public override int AttackProc(Character enemy, int damage)
        {
            if (Random.Int(6) != 0 || enemy != Dungeon.Hero)
            {
                return(damage);
            }

            var hero   = Dungeon.Hero;
            var weapon = hero.Belongings.Weapon;

            if (weapon == null || weapon is Knuckles || weapon.cursed)
            {
                return(damage);
            }

            hero.Belongings.Weapon = null;
            Dungeon.Level.Drop(weapon, hero.pos).Sprite.Drop();
            GLog.Warning(TxtDisarm, Name, weapon.Name);

            return(damage);
        }
示例#26
0
        protected internal override void OnZap(int cell)
        {
            var ch = Actor.FindChar(cell);

            if (ch == CurUser)
            {
                SetKnown();
                ScrollOfTeleportation.TeleportHero(CurUser);
            }
            else
            if (ch != null)
            {
                var count = 10;
                int pos;
                do
                {
                    pos = Dungeon.Level.RandomRespawnCell();
                    if (count-- <= 0)
                    {
                        break;
                    }
                } while (pos == -1);

                if (pos == -1)
                {
                    GLog.Warning(ScrollOfTeleportation.TxtNoTeleport);
                }
                else
                {
                    ch.pos = pos;
                    ch.Sprite.Place(ch.pos);
                    ch.Sprite.Visible = Dungeon.Visible[pos];
                    GLog.Information(CurUser.Name + " teleported " + ch.Name + " to somewhere");
                }
            }
            else
            {
                GLog.Information("nothing happened");
            }
        }
示例#27
0
        public virtual Item Upgrade(bool enchant)
        {
            if (enchantment != null)
            {
                if (enchant || pdsharp.utils.Random.Int(level) <= 0)
                {
                    return(base.Upgrade());
                }

                GLog.Warning(TxtIncompatible);
                Enchant(null);
            }
            else
            {
                if (enchant)
                {
                    Enchant(Enchantment.Random());
                }
            }

            return(base.Upgrade());
        }
示例#28
0
                public override bool Collect(Bag container)
                {
                    if (!base.Collect(container))
                    {
                        return(false);
                    }

                    if (Dungeon.Level == null)
                    {
                        return(true);
                    }

                    foreach (var mob in Dungeon.Level.mobs)
                    {
                        mob.Beckon(Dungeon.Hero.pos);
                    }

                    GLog.Warning("The seed emits a roar that echoes throughout the dungeon!");
                    CellEmitter.Center(Dungeon.Hero.pos).Start(Speck.Factory(Speck.SCREAM), 0.3f, 3);
                    Sample.Instance.Play(Assets.SND_CHALLENGE);

                    return(true);
                }
示例#29
0
 public override void Execute(Hero hero, string action)
 {
     if (action == Special())
     {
         if (hero.HP < 3)
         {
             GLog.Warning(TxtLowHealth);
         }
         else if (!IsEquipped(hero))
         {
             GLog.Warning(TxtNotEquipped);
         }
         else
         {
             CurUser = hero;
             DoSpecial();
         }
     }
     else
     {
         base.Execute(hero, action);
     }
 }
示例#30
0
        public virtual int Proc(Character attacker, Character defender, int damage)
        {
            if (glyph != null)
            {
                damage = glyph.Proc(this, attacker, defender, damage);
            }

            if (levelKnown)
            {
                return(damage);
            }

            if (--_hitsToKnow > 0)
            {
                return(damage);
            }

            levelKnown = true;
            GLog.Warning(TxtIdentify, Name, ToString());
            Badge.ValidateItemLevelAquired(this);

            return(damage);
        }