当前位置: 首页>>代码示例>>C#>>正文


C# Player.TakeDamage方法代码示例

本文整理汇总了C#中Player.TakeDamage方法的典型用法代码示例。如果您正苦于以下问题:C# Player.TakeDamage方法的具体用法?C# Player.TakeDamage怎么用?C# Player.TakeDamage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Player的用法示例。


在下文中一共展示了Player.TakeDamage方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Hit

 public void Hit(Player _player, WeaponCol _col)
 {
     if(isAttacking)
     {
         _player.TakeDamage(damage);
         _col.hasAttacked = true;
     }
 }
开发者ID:GlitchBoss,项目名称:TextWars,代码行数:8,代码来源:Melee.cs

示例2: OnPlayerCollide

 public override void OnPlayerCollide(Room room, int x, int y, Player player)
 {
     const float offset = 0.25f;
     const float size = Tile.tileSize * (1 - 2 * offset);
     Hitbox lavaBox = new Hitbox(Tile.tileSize * new Vector2(x + offset, y + offset), size, size);
     Hitbox playerBox = player.hitbox;
     if (playerBox.topRight.X >= lavaBox.bottomLeft.X && playerBox.topLeft.X <= lavaBox.bottomRight.X
         && playerBox.bottomLeft.Y >= lavaBox.topLeft.Y && playerBox.topLeft.Y <= lavaBox.bottomLeft.Y)
     {
         player.invincible = 0;
         player.TakeDamage(10);
     }
 }
开发者ID:bluemagic123,项目名称:Slip,代码行数:13,代码来源:Lava.cs

示例3: HandlePlayerCollision

 public void HandlePlayerCollision(Player p)
 {
     if (p.invulnCount > 0)
         return;
     if (knockbackcount <= 0 && p.shouldDamage && this.isColliding(p.swordCollision))
     {
         Vector2 diff = (p.GetPosition() - this.GetPosition()).normalized;
         this.xVel -= diff.x * 7f;
         this.yVel -= diff.y * 7f;
         knockbackcount = 1.0f;
     }
     if (p.isColliding(this))
     {
         FSoundManager.PlaySound("orbExplosion");
         p.TakeDamage(p.GetPosition() - new Vector2(xVel, yVel));
         SpawnParticles(30, true);
         world.removeObject(this);
     }
 }
开发者ID:maggardJosh,项目名称:SpiritGuard,代码行数:19,代码来源:MagicOrb.cs

示例4: CheckDamage

    public void CheckDamage(Player p)
    {
        if (this.State == KnightState.INVULNERABLE || this.State == KnightState.DYING)
            return;

        if (p.shouldDamage && (p.State == Player.PlayerState.SWORD || p.State == Player.PlayerState.SWORD_TWO))
        {
            if (isColliding(p.swordCollision))
            {
                TakeDamage(p.GetPosition());
            }
        }
        else
        {
            if (p.invulnCount > 0)// || (p.StateCount > .01f && p.State == Player.PlayerState.JUMP))
                return;
            if (isColliding(p))
            {
                p.TakeDamage(this.GetPosition());
            }
        }

        switch (State)
        {
            case KnightState.IDLE:
            case KnightState.MOVING:
                switch (_direction)
                {
                    case Direction.RIGHT:
                    case Direction.LEFT:
                        if (this.y - attackSideDist < p.y && this.y + attackSideDist > p.y)
                            if (_direction == Direction.LEFT && this.x > p.x && this.x - attackDist < p.x)
                            {
                                FSoundManager.PlaySound("knightAttack");
                                State = KnightState.ATTACK_START;
                                PlayAnim(true);
                                attackTarget = p;
                            }
                            else if (_direction == Direction.RIGHT && this.x < p.x && this.x + attackDist > p.x)
                            {
                                FSoundManager.PlaySound("knightAttack");
                                State = KnightState.ATTACK_START;
                                PlayAnim(true);
                                attackTarget = p;
                            }
                        break;
                    case Direction.UP:
                    case Direction.DOWN:
                        if (this.x - attackSideDist < p.x && this.x + attackSideDist > p.x)
                            if (_direction == Direction.DOWN && this.y > p.y && this.y - attackDist < p.y)
                            {
                                FSoundManager.PlaySound("knightAttack");
                                State = KnightState.ATTACK_START;
                                PlayAnim(true);
                                attackTarget = p;
                            }
                            else if (_direction == Direction.UP && this.y < p.y && this.y + attackDist > p.y)
                            {
                                FSoundManager.PlaySound("knightAttack");
                                State = KnightState.ATTACK_START;
                                PlayAnim(true);
                                attackTarget = p;
                            }
                        break;
                }
                break;
            case KnightState.ATTACKING:
                if (RXRandom.Float() < .3f)
                    SpawnTrailParticles(_direction, 1);
                break;
        }
    }
开发者ID:maggardJosh,项目名称:SpiritGuard,代码行数:72,代码来源:Knight.cs

示例5: CheckPlayerCollision

    public void CheckPlayerCollision(Player p)
    {
        if ((this.currentState != State.BOUNCE && this.currentState != State.TAKE_DAMAGE))
        {

            if (p.invulnerableCount <= 0 && p.isColliding(this))
            {

                p.TakeDamage(new Vector2(xVel * 3, yVel * 3));
                TrySpawnWords(victoryWords, p.CurrentState == Player.State.DYING ? .2f : 1);
                maxVel = 3;
                xAcc = 0;
                yAcc = 0;
                this.collidesWithOtherObjects = false;
                this.blocksOtherObjects = false;
                this.xVel *= -2;
                this.yVel *= -2;
                currentState = State.BOUNCE;
            }
            else
            {
                if (p.isColliding(this))
                {
                    maxVel = 3;
                    xAcc = 0;
                    yAcc = 0;
                    this.collidesWithOtherObjects = false;
                    this.blocksOtherObjects = false;
                    Vector2 diff = (p.GetPosition() - this.GetPosition()).normalized;
                    this.xVel = -diff.x * 2;
                    this.yVel = -diff.y * 2;
                    Go.killAllTweensWithTarget(this);
                    shadow.y = 0;
                    Go.to(this, .1f, new TweenConfig().floatProp("isoHeight", 5, true).setEaseType(EaseType.QuadOut).setIterations(2, LoopType.PingPong));
                    currentState = State.BOUNCE;
                }
            }
        }
    }
开发者ID:maggardJosh,项目名称:OGREAT,代码行数:39,代码来源:Enemy.cs

示例6: ShotPlayerHandle

 private void ShotPlayerHandle(Shot shot, Player player)
 {
     player.TakeDamage(shot.Damage);
     shot.IsRemoved = true;
 }
开发者ID:Aspent,项目名称:CourseWork,代码行数:5,代码来源:RoomSupervisor.cs

示例7: HandlePlayerCollision

    public void HandlePlayerCollision(Player p)
    {
        if (this.State != GhostState.INVULNERABLE && p.shouldDamage)
            if (this.isColliding(p.swordCollision))
            {
                this.TakeDamage(p.GetPosition());
                return;
            }
        if (p.invulnCount > 0)
            return;

        if (p.invulnCount > 0 || this.State == GhostState.DYING)
            return;
        if(p.isColliding(this))
        {
            p.TakeDamage(this.GetPosition());
        }
    }
开发者ID:maggardJosh,项目名称:SpiritGuard,代码行数:18,代码来源:Ghost.cs


注:本文中的Player.TakeDamage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。