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


C# Player.GetPosition方法代码示例

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


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

示例1: 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

示例2: Start

 public override void Start()
 {
     tileMap = new TileMap();
     tileMap.LoadTileMap("Texts/MapBig");
     AddChild(tileMap);
     player = new Player();
     cameraPosition = player.GetPosition();
     tileMap.AddChild(player);
     ListenForUpdate(Update);
     AddChild(hudShadow);
     AddChild(hudStuff);
 }
开发者ID:riktothepast,项目名称:Futile_TileMap_AABB,代码行数:12,代码来源:GamePage.cs

示例3: SpawnPlayer

    public void SpawnPlayer(Player p)
    {
        p.SetPosition(pos-new Vector2(p.hitBox.x, p.hitBox.y));
            p.SetDirection(exitDirection);
            p.PlayAnim(true);
            p.xVel = 0;
            p.yVel = 0;
            Vector2 newPos = p.GetPosition();

            switch(exitDirection)
            {
                case FutileFourDirectionBaseObject.Direction.UP: newPos.y += 20; break;
                case FutileFourDirectionBaseObject.Direction.RIGHT: newPos.x += 16; break;
                case FutileFourDirectionBaseObject.Direction.DOWN: newPos.y -= 16; break;
                case FutileFourDirectionBaseObject.Direction.LEFT: newPos.x -= 16; break;
            }
           Go.to(p, 1.0f, new TweenConfig().floatProp("x", newPos.x).floatProp("y", newPos.y));
    }
开发者ID:maggardJosh,项目名称:SpiritGuard,代码行数:18,代码来源:SpawnPoint.cs

示例4: HandlePlayerCollision

 public void HandlePlayerCollision(Player p)
 {
     if (p.isColliding(this))
     {
         //FSoundManager.PlaySound("powerup");
         isBeingPickedUp = true;
         FSoundManager.TweenVolume(.3f);
         p.isVisible = false;
         Go.killAllTweensWithTarget(p);
         p.State = Player.PlayerState.IDLE;
         p.xVel = 0;
         p.yVel = 0;
         Go.killAllTweensWithTarget(this);
         FSprite playerPickup = new FSprite("player_13");
         C.getCameraInstance().AddChild(playerPickup);
         Vector2 playerRelativePosition = p.GetPosition() + Futile.stage.GetPosition() - Vector2.up * 16f;
         playerPickup.SetPosition(playerRelativePosition);
         this.SetPosition(this.GetPosition() + Futile.stage.GetPosition() - Vector2.up * 16f);
         world.removeObject(this);
         C.getCameraInstance().AddChild(this);
         world.forceWaitLoad = true;
         RXDebug.Log(this.GetPosition(), playerPickup.GetPosition());
         this.MoveToFront();
         FLabel label = new FLabel(C.largeFontName, type.ToString().ToUpper() + " SPIRIT");
         C.getCameraInstance().AddChild(label);
         label.y = Futile.screen.halfHeight - label.textRect.height / 2f - 10;
         label.x = Futile.screen.halfWidth + label.textRect.width / 2f + 10;
         world.ShowLoading(() =>
         {
             Go.to(playerPickup, 2.0f, new TweenConfig().floatProp("x", 0).floatProp("y", -15).setEaseType(EaseType.QuadOut));
             Go.to(this, 2.0f, new TweenConfig().floatProp("x", 0).floatProp("y", 15).setEaseType(EaseType.QuadOut));
             Go.to(label, 1.5f, new TweenConfig().floatProp("x", 0).setEaseType(EaseType.BackOut).setDelay(1.5f).onComplete(() =>
             {
                 Go.to(this, .01f, new TweenConfig().floatProp("x", 1, true).onComplete(() =>
                 {
                     Go.to(this, .01f, new TweenConfig().floatProp("x", -2, true).setIterations(100, LoopType.PingPong).onComplete(() =>
                     {
                         FSoundManager.PlaySound("orbExplosion");
                         FSoundManager.PlaySound("powerup");
                         SpawnParticles(30);
                         this.x -= 1;
                         sprite.SetElementByName(type.ToString().ToLower() + "_soul");
                         Go.to(label, 1.5f, new TweenConfig().floatProp("x", -Futile.screen.halfWidth - label.textRect.width / 2f - 10).setEaseType(EaseType.BackIn).setDelay(2.0f).onStart((AbstractTween t) => { }).onComplete(() =>
                         {
                             label.RemoveFromContainer();
                             Go.to(playerPickup, 1.0f, new TweenConfig().floatProp("x", playerRelativePosition.x).floatProp("y", playerRelativePosition.y).setEaseType(EaseType.QuadInOut).onComplete(() =>
                             {
                                 FSoundManager.TweenVolume(1.0f);
                                 p.PickupSoul(this);
                                 world.HideLoading(() => { p.isVisible = true; playerPickup.RemoveFromContainer(); this.RemoveFromContainer(); });
                             }));
                             Vector2 powerupPos;
                             switch(type)
                             {
                                 case SoulType.JUMP:
                                     powerupPos = world.ui.slotAPos;
                                     break;
                                 default:
                                     powerupPos = world.ui.slotBPos;
                                     break;
                             }
                             Go.to(this, 1.0f, new TweenConfig().floatProp("x", powerupPos.x).floatProp("y", powerupPos.y).setEaseType(EaseType.QuadInOut));
                         }));
                     }));
                 }));
             }));
         });
     }
 }
开发者ID:maggardJosh,项目名称:SpiritGuard,代码行数:69,代码来源:SoulPickup.cs

示例5: 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

示例6: 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

示例7: MakeMove

    public Player MakeMove(Player toMove, Tuple<int, int> direction)
    {
        var previousPosition = toMove.GetPosition();
        var nextPosition = CalculateNewPosition(previousPosition, direction);

        var playerCollided = VerifyMove(nextPosition);

        if (!playerCollided)
        {
            toMove.KillPlayer();
        }
        else
        {
            toMove.SetPosition(nextPosition);
            MarkCoordinates(toMove,previousPosition,nextPosition);
        }

        var playedAlive = VerifyPlayerAlive();
        return playedAlive;
    }
开发者ID:Vicra,项目名称:Tron,代码行数:20,代码来源:GameMotor.cs

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