コード例 #1
0
        void PoisonEnemy(Enemy enemy, ActivateEffect eff)
        {
            int        remainingDmg = (int)StatsManager.GetDefenseDamage(enemy, eff.TotalDamage, enemy.ObjectDesc.Defense);
            int        perDmg       = (int)(remainingDmg * 1000 / eff.DurationMS);
            WorldTimer tmr          = null;
            int        x            = 0;

            tmr = new WorldTimer(100, (w, t) =>
            {
                if (enemy.Owner == null)
                {
                    return;
                }
                w.BroadcastPacket(new ShowEffectPacket()
                {
                    EffectType = EffectType.Dead,
                    TargetId   = enemy.Id,
                    Color      = new ARGB(0xffddff00)
                }, null);

                if (x % 10 == 0)
                {
                    int thisDmg;
                    if (remainingDmg < perDmg)
                    {
                        thisDmg = remainingDmg;
                    }
                    else
                    {
                        thisDmg = perDmg;
                    }

                    enemy.Damage(this, t, thisDmg, true);
                    remainingDmg -= thisDmg;
                    if (remainingDmg <= 0)
                    {
                        return;
                    }
                }
                x++;

                tmr.Reset();

                Manager.Logic.AddPendingAction(_ => w.Timers.Add(tmr), PendingPriority.Creation);
            });
            Owner.Timers.Add(tmr);
        }
コード例 #2
0
        void PoisonEnemy(World world, Enemy enemy, ActivateEffect eff)
        {
            var remainingDmg = (int)StatsManager.GetDefenseDamage(enemy, eff.TotalDamage, enemy.ObjectDesc.Defense);
            var perDmg       = (remainingDmg * 1000) / eff.DurationMS;

            WorldTimer tmr = null;
            var        x   = 0;

            Func <World, RealmTime, bool> poisonTick = (w, t) =>
            {
                if (enemy.Owner == null || w == null)
                {
                    return(true);
                }

                /*w.BroadcastPacketConditional(new ShowEffect()
                 * {
                 *  EffectType = EffectType.Dead,
                 *  TargetObjectId = enemy.Id,
                 *  Color = new ARGB(0xffddff00)
                 * }, p => enemy.DistSqr(p) < RadiusSqr);*/

                if (x % 4 == 0) // make sure to change this if timer delay is changed
                {
                    var thisDmg = perDmg;
                    if (remainingDmg < thisDmg)
                    {
                        thisDmg = remainingDmg;
                    }

                    enemy.Damage(this, t, thisDmg, true);
                    remainingDmg -= thisDmg;
                    if (remainingDmg <= 0)
                    {
                        return(true);
                    }
                }
                x++;

                tmr.Reset();
                return(false);
            };

            tmr = new WorldTimer(250, poisonTick);
            world.Timers.Add(tmr);
        }
コード例 #3
0
        void HealingPlayersPoison(World world, Player player, ActivateEffect eff)
        {
            var remainingHeal = eff.TotalDamage;
            var perHeal       = eff.TotalDamage * 1000 / eff.DurationMS;

            WorldTimer tmr = null;
            var        x   = 0;

            Func <World, RealmTime, bool> healTick = (w, t) =>
            {
                if (player.Owner == null || w == null)
                {
                    return(true);
                }

                if (x % 4 == 0) // make sure to change this if timer delay is changed
                {
                    var thisHeal = perHeal;
                    if (remainingHeal < thisHeal)
                    {
                        thisHeal = remainingHeal;
                    }

                    List <Packet> pkts = new List <Packet>();

                    Player.ActivateHealHp(player, thisHeal, pkts);
                    w.BroadcastPackets(pkts, null);
                    remainingHeal -= thisHeal;
                    if (remainingHeal <= 0)
                    {
                        return(true);
                    }
                }
                x++;

                tmr.Reset();
                return(false);
            };

            tmr = new WorldTimer(250, healTick);
            world.Timers.Add(tmr);
        }
コード例 #4
0
    // Update is called once per frame
    void Update()
    {
        Dirs dir = Dirs.NULL;

        // // TEST CODE
        // if(Input.GetKeyDown(KeyCode.D)) {
        //  Debug.Log("Equipped dagger!");
        //  SetWeapon<DaggerWeapon>();
        // }
        // if(Input.GetKeyDown(KeyCode.S)) {
        //  Debug.Log("Equipped Longsword!");
        //  SetWeapon<LongswordWeapon>();
        // }
        // if(Input.GetKeyDown(KeyCode.A)) {
        //  Debug.Log("Equipped GUN!");
        //  SetWeapon<GunWeapon>();
        // }
        // if(Input.GetKeyDown(KeyCode.D)) {
        //  GetComponent<PlayerHealthController>().DealDamage(1);
        // }
        // if(Input.GetKeyDown(KeyCode.E)) {
        //  pcc.AddCoins(20);
        // }

        // Rightwards Movement
        if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            dir = Dirs.RIGHT;
        }

        // Leftwards Movement
        else if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            dir = Dirs.LEFT;
        }

        // Upwards Movement
        else if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            dir = Dirs.UP;
        }

        // Downwards Movement
        else if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            dir = Dirs.DOWN;
        }

        if (dir != Dirs.NULL)
        {
            // Reset the world timer so it doesn't prematurely fire off
            wt.Reset();

            bool attacked = weapon.Attack(dir);             // Attack in the given direction
            if (attacked)
            {
                eac.PlayAttack();
            }
            // returns false is there was no enemy to attack.
            else
            {
                if (gm.IsStones(dir))
                {
                    gst.StartTranslation();

                    transform.position += (Vector3)GridMovement.DirTable[dir];

                    // NOTE(clark): Testing hopping here. I really like hopping.
                    // gst.SetPosition(GridSpriteTranslate.MoveType.WALK);

                    gst.SetPosition(GridSpriteTranslate.MoveType.WALK);
                    anim.SetTrigger("Walk");
                    anim_head.SetTrigger("RESET");
                }

                // This is an ugly block. Really brute force. OH WELL
                else if (gm.IsWater(dir))
                {
                    // Shoot out a ray to check for a collision with the level layer.
                    RaycastHit2D hit = Physics2D.Raycast(transform.position + (Vector3)(GridMovement.DirTable[dir] * 2),                        // origin
                                                         Vector3.up,                                                                            // Lookup table (direction)!
                                                         0.1f,                                                                                  // Only 1 unit Grid
                                                         LayerMask.GetMask("Stones"));                                                          // Only on this layer

                    if (hit.collider != null)
                    {
                        gst.StartTranslation();

                        transform.position += ((Vector3)GridMovement.DirTable[dir] * 2);

                        // Play jump noise
                        int idx = Random.Range(0, jump_sounds.Count);
                        AudioSource.PlayClipAtPoint(jump_sounds[idx], transform.position, jump_vol);

                        // NOTE(clark): Testing hopping here. I really like hopping.
                        // gst.SetPosition(GridSpriteTranslate.MoveType.WALK);
                        gst.SetPosition(GridSpriteTranslate.MoveType.JUMP);
                        anim.SetTrigger("Jump");
                        anim_head.SetTrigger("RESET");
                    }
                    else
                    {
                        // Shoot out a ray to check for a collision with the level layer.
                        hit = Physics2D.Raycast(transform.position + (Vector3)(GridMovement.DirTable[dir] * 2),                                         // origin
                                                Vector3.up,                                                                                             // Lookup table (direction)!
                                                0.1f,                                                                                                   // Only 1 unit Grid
                                                LayerMask.GetMask("Water"));                                                                            // Only on this layer
                        // NO water
                        if (hit.collider == null)
                        {
                            gst.StartTranslation();

                            transform.position += ((Vector3)GridMovement.DirTable[dir] * 2);

                            // NOTE(clark): Testing hopping here. I really like hopping.
                            // gst.SetPosition(GridSpriteTranslate.MoveType.WALK);
                            gst.SetPosition(GridSpriteTranslate.MoveType.JUMP);
                            anim.SetTrigger("Jump");
                            anim_head.SetTrigger("RESET");
                        }
                    }
                }

                else if (gm.CanMovePlayer(dir))
                {
                    gst.StartTranslation();

                    transform.position += (Vector3)GridMovement.DirTable[dir];

                    // NOTE(clark): Testing hopping here. I really like hopping.
                    // gst.SetPosition(GridSpriteTranslate.MoveType.WALK);
                    gst.SetPosition(GridSpriteTranslate.MoveType.WALK);
                    anim.SetTrigger("Walk");
                    anim_head.SetTrigger("RESET");
                }
            }

            // NOTE(clark): Did stuff
            // Fire off a world update
            smu.UpdateWorld();
        }
    }
コード例 #5
0
        void PoisonEnemy(Enemy enemy, ActivateEffect eff)
        {
            try
            {
                if (eff.ConditionEffect != null)
                {
                    enemy.ApplyConditionEffect(new ConditionEffect[] {
                        new ConditionEffect()
                        {
                            Effect     = (ConditionEffectIndex)eff.ConditionEffect,
                            DurationMS = (int)eff.EffectDuration
                        }
                    });
                }
                int        remainingDmg = (int)StatsManager.GetDefenseDamage(enemy, eff.TotalDamage, enemy.ObjectDesc.Defense);
                int        perDmg       = (int)(remainingDmg * 1000 / eff.DurationMS);
                WorldTimer tmr          = null;
                int        x            = 0;
                tmr = new WorldTimer(100, (w, t) =>
                {
                    if (enemy.Owner == null)
                    {
                        return;
                    }
                    w.BroadcastPacket(new ShowEffectPacket()
                    {
                        EffectType = EffectType.Dead,
                        TargetId   = enemy.Id,
                        Color      = new ARGB(0xffddff00)
                    }, null);

                    if (x % 10 == 0)
                    {
                        int thisDmg;
                        if (remainingDmg < perDmg)
                        {
                            thisDmg = remainingDmg;
                        }
                        else
                        {
                            thisDmg = perDmg;
                        }

                        enemy.Damage(this, t, thisDmg, true);
                        remainingDmg -= thisDmg;
                        if (remainingDmg <= 0)
                        {
                            return;
                        }
                    }
                    x++;

                    tmr.Reset();

                    RealmManager.Logic.AddPendingAction(_ => w.Timers.Add(tmr), PendingPriority.Creation);
                });
                Owner.Timers.Add(tmr); //Disabling this causes poisons to do nothing. However, this line causes problems :/
            }
            catch
            {
                Console.ForegroundColor = ConsoleColor.DarkBlue;
                Console.Out.WriteLine("Warning! Poison Lag!");
                Console.ForegroundColor = ConsoleColor.White;
            }
        }
コード例 #6
0
ファイル: Player.UseItem.cs プロジェクト: ppmaks/LOE-V6-GAME
        private void PoisonEnemy(Enemy enemy, ActivateEffect eff)
        {
            try
            {
                if (eff.ConditionEffect != null)
                {
                    enemy?.ApplyConditionEffect(new[]
                    {
                        new ConditionEffect
                        {
                            Effect     = (ConditionEffectIndex)eff.ConditionEffect,
                            DurationMS = (int)eff.EffectDuration
                        }
                    });
                }
                int        remainingDmg = (int)StatsManager.GetDefenseDamage(enemy, eff.TotalDamage, enemy.ObjectDesc.Defense);
                int        perDmg       = remainingDmg * 1000 / eff.DurationMS;
                WorldTimer tmr          = null;
                int        x            = 0;
                tmr = new WorldTimer(100, (w, t) =>
                {
                    if (enemy.Owner == null)
                    {
                        return;
                    }
                    w.BroadcastPacket(new SHOWEFFECT
                    {
                        EffectType = EffectType.Poison,
                        TargetId   = enemy.Id,
                        Color      = new ARGB(0xffddff00)
                    }, null);

                    if (x % 10 == 0)
                    {
                        int thisDmg;
                        if (remainingDmg < perDmg)
                        {
                            thisDmg = remainingDmg;
                        }
                        else
                        {
                            thisDmg = perDmg;
                        }

                        enemy.Damage(this, t, thisDmg, true);
                        remainingDmg -= thisDmg;
                        if (remainingDmg <= 0)
                        {
                            return;
                        }
                    }
                    x++;

                    tmr.Reset();

                    Manager.Logic.AddPendingAction(_ => w.Timers.Add(tmr), PendingPriority.Creation);
                });
                Owner?.Timers.Add(tmr);
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
        }