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


C# Entity.getPosition方法代码示例

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


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

示例1: updateCollisionWith

        internal override void updateCollisionWith(Entity a_collider)
        {
            if (a_collider is Player)
            {
                Player t_player = (Player) a_collider;

                if (Game.keyClicked(GameState.getActionKey()) && !t_player.isChase()
                    && t_player.getLastState() != Player.State.Hiding && t_player.getCurrentState() != Player.State.Jumping
                    && t_player.getCurrentState() != Player.State.Slide && t_player.getCurrentState() != Player.State.Climbing)
                {

                    Vector2 t_playerGlobal = a_collider.getPosition().getGlobalCartesianCoordinates();
                    float t_myPositionX = m_position.getGlobalCartesianCoordinates().X;

                    if (t_playerGlobal.X < t_myPositionX)
                    {

                        t_player.setNextPositionX(t_myPositionX - a_collider.getHitBox().getOutBox().Width);
                        t_player.setFacingRight(true);
                    }
                    else
                    {
                        t_player.setNextPositionX(t_myPositionX + m_img.getSize().X);
                        t_player.setFacingRight(false);
                    }

                    t_player.setState(Player.State.Hiding);
                    t_player.setHidingImage(Player.STANDHIDINGIMAGE);
                    t_player.setSpeedX(0);
                }
            }
        }
开发者ID:Yuma-Shi,项目名称:GLhf,代码行数:32,代码来源:StandHideObject.cs

示例2: updateCollisionWith

 internal override void updateCollisionWith(Entity a_collider)
 {
     if (a_collider is Player)
     {
         Player t_player = (Player)a_collider;
         Vector2 t_playerGlobalPosition = a_collider.getPosition().getGlobalCartesian();
         Rectangle t_playerOutBox = a_collider.getHitBox().getOutBox();
         if (CollisionManager.Contains(this.getHitBox(),
             new Vector2(t_playerGlobalPosition.X + t_playerOutBox.Width / 2, t_playerGlobalPosition.Y + t_playerOutBox.Height / 2))
             && !t_player.isChase()
             && t_player.getLastState() != Player.State.Hiding
             && t_player.getCurrentState() != Player.State.Rolling
             )
         {
             if (KeyboardHandler.keyClicked(GameState.getActionKey()))
             {
                 t_player.setState(Player.State.Hiding);
                 t_player.setHidingImage(Player.DUCKHIDINGIMAGE);
                 t_player.setSpeedX(0);
                 t_player.setInteractionVisibility(false);
                 t_player.getHideSound().play();
             }
             else if (t_player.getCurrentState() != Player.State.Hiding)
             {
                 t_player.setInteractionVisibility(true);
             }
         }
     }
 }
开发者ID:melburn,项目名称:GLhf,代码行数:29,代码来源:DuckHideObject.cs

示例3: changeMode

 public void changeMode(Entity a_collider)
 {
     float t_startX = m_line.getStartPoint().getGlobalX();
     float t_startY = m_line.getStartPoint().getGlobalY();
     float t_endX = m_line.getEndPoint().getGlobalX();
     float t_endY = m_line.getEndPoint().getGlobalY();
     float t_colliderY = a_collider.getPosition().getGlobalY() + a_collider.getHitBox().getOutBox().Height;
     m_isReady = true;
     setStartPoint(new Vector2(((-t_startX * t_endY)	+ (t_startX	* t_colliderY) + (t_startY * t_endX) - (t_endX * t_colliderY)) / (t_startY -t_endY), t_colliderY - 1));
     setEndPoint(m_player.getPosition().getGlobalCartesian() + new Vector2(m_player.getHitBox().getOutBox().Width / 2, m_player.getHitBox().getOutBox().Height / 2));
     m_rotate = m_startPosition.getAngleTo(m_endPosition.getGlobalCartesian());
     LinkedList<GameObject> t_gameObjects = Game.getInstance().getState().getCurrentList();
     bool t_isStartAtPlatform = false;
     foreach (GameObject t_go in t_gameObjects)
     {
         if (t_go is Platform)
             if (((Platform)t_go).getBox().Contains((int)m_startPosition.getGlobalX(), (int)m_startPosition.getGlobalY()))
             {
                 t_isStartAtPlatform = true;
                 break;
             }
     }
     if (t_isStartAtPlatform)
     {
         m_player.setState(Player.State.Swinging);
         if (!(Vector2.Distance(m_player.getPosition().getGlobalCartesian(), m_line.getStartPoint().getGlobalCartesian())
             < Math.Min(Vector2.Distance(new Vector2(m_player.getPosition().getGlobalCartesian().X + m_player.getHitBox().getOutBox().Width, m_player.getPosition().getGlobalCartesian().Y), m_line.getStartPoint().getGlobalCartesian()),
             Vector2.Distance(new Vector2(m_player.getPosition().getGlobalCartesian().X + m_player.getHitBox().getOutBox().Width / 2, m_player.getPosition().getGlobalCartesian().Y), m_line.getStartPoint().getGlobalCartesian()))))
         {
             if (Vector2.Distance(new Vector2(m_player.getPosition().getGlobalCartesian().X + m_player.getHitBox().getOutBox().Width, m_player.getPosition().getGlobalCartesian().Y), m_line.getStartPoint().getGlobalCartesian())
                 < Vector2.Distance(new Vector2(m_player.getPosition().getGlobalCartesian().X + m_player.getHitBox().getOutBox().Width / 2, m_player.getPosition().getGlobalCartesian().Y), m_line.getStartPoint().getGlobalCartesian()))
             {
                 m_player.addPositionXAfterDraw(m_player.getHitBox().getOutBox().Width);
             }
             else
             {
                 m_player.addPositionXAfterDraw(m_player.getHitBox().getOutBox().Width / 2);
             }
         }
         m_player.setRope(this);
         m_player.changePositionToPolar();
         m_player.getPosition().setParentPositionWithoutMoving(m_line.getStartPoint());
         m_player.setState(Player.State.Swinging);
         if (m_player.getPosition().getLength() < 50)
         {
             m_player.getPosition().setLength(50);
         }
         m_moveToStart = false;
     }
     else
     {
         m_moveToStart = true;
     }
 }
开发者ID:theKyuu,项目名称:GLhf,代码行数:54,代码来源:Hookshot.cs

示例4: updateCollisionWith

        internal override void updateCollisionWith(Entity a_collider)
        {
            if (a_collider is Player)
            {
                Player t_player = (Player) a_collider;
                if (!t_player.isChase()
                    && t_player.getLastState() != Player.State.Hiding && t_player.getCurrentState() != Player.State.Jumping
                    && t_player.getCurrentState() != Player.State.Slide && t_player.getCurrentState() != Player.State.Climbing)
                {
                    if (!t_player.isStunned())
                    {
                        if (KeyboardHandler.keyClicked(GameState.getActionKey()))
                        {

                            Vector2 t_playerGlobal = a_collider.getPosition().getGlobalCartesian();
                            float t_myPositionX = m_position.getGlobalCartesian().X;

                            float t_newPos;
                            if (t_playerGlobal.X < t_myPositionX)
                            {
                                t_newPos = t_myPositionX - a_collider.getHitBox().getOutBox().Width;
                                t_player.setFacingRight(true);
                            }
                            else
                            {
                                t_newPos = t_myPositionX + m_img.getSize().X;
                                t_player.setFacingRight(false);
                            }

                            Game.getInstance().m_camera.getPosition().plusXWith(t_player.getPosition().getGlobalX() - t_newPos);

                            t_player.setNextPositionX(t_newPos);

                            t_player.setState(Player.State.Hiding);
                            t_player.setHidingImage(Player.STANDHIDINGIMAGE);
                            t_player.setSpeedX(0);
                            t_player.getHideSound().play();
                            t_player.getImg().setSprite("Images//Sprite//Hero//hero_wallhide");
                            t_player.updateFlip();
                        }
                        else if (t_player.getCurrentState() != Player.State.Hiding)
                        {
                            t_player.setInteractionVisibility(true);
                        }
                    }
                }
            }
        }
开发者ID:melburn,项目名称:GLhf,代码行数:48,代码来源:StandHideObject.cs

示例5: updateCollisionWith

 internal override void updateCollisionWith(Entity a_collider)
 {
     if (a_collider is Player)
     {
         Player t_player = (Player)a_collider;
         Vector2 t_playerGlobalPosition = a_collider.getPosition().getGlobalCartesianCoordinates();
         Rectangle t_playerOutBox = a_collider.getHitBox().getOutBox();
         if (CollisionManager.Contains(this.getHitBox(),
             new Vector2(t_playerGlobalPosition.X + t_playerOutBox.Width/2, t_playerGlobalPosition.Y + t_playerOutBox.Height/2)))
         {
             if (Game.keyClicked(GameState.getActionKey()) && !t_player.isChase()
                 && t_player.getLastState() != Player.State.Hiding)
             {
                 t_player.setState(Player.State.Hiding);
                 t_player.setHidingImage(Player.DUCKHIDINGIMAGE);
                 t_player.setSpeedX(0);
             }
         }
     }
 }
开发者ID:Yuma-Shi,项目名称:GLhf,代码行数:20,代码来源:DuckHideObject.cs

示例6: updateCollisionWith

 internal override void updateCollisionWith(Entity a_collid)
 {
     if (a_collid is Player)
     {
         Vector2 t_playerGlobalCoordinate = a_collid.getPosition().getGlobalCartesianCoordinates();
         if (CollisionManager.Contains(this.getHitBox(), t_playerGlobalCoordinate))
         {
             Player t_player = (Player)a_collid;
             if (
                 (Game.keyClicked(GameState.getUpKey()) && (t_player.getCurrentState() == Player.State.Walking || t_player.getCurrentState() == Player.State.Stop))
                 || (t_player.getCurrentState() != Player.State.Walking && t_player.getCurrentState() != Player.State.Stop)
             )
             {
                 if (this.m_spriteEffects == SpriteEffects.FlipHorizontally)
                     t_player.setIsOnLadderWithDirection(Player.Direction.Left);
                 else
                     t_player.setIsOnLadderWithDirection(Player.Direction.Right);
             }
         }
     }
 }
开发者ID:Yuma-Shi,项目名称:GLhf,代码行数:21,代码来源:Ladder.cs

示例7: hang

 public void hang(Entity a_collider)
 {
     if (!m_stunned)
     {
         Rectangle t_colliderBox = a_collider.getHitBox().getOutBox();
         Rectangle t_playerBox = getHitBox().getOutBox();
         if (!t_colliderBox.Contains((int)m_lastPosition.X + t_playerBox.Width + 4, (int)m_lastPosition.Y)
             && t_colliderBox.Contains((int)m_position.getGlobalX() + t_playerBox.Width + 4, (int)m_position.getGlobalY())
             && m_lastPosition.Y < t_colliderBox.Y
             && m_speed.Y >= 0
             && (m_currentState == State.Jumping || m_currentState == State.Slide))
         {
             m_position.setLocalY(a_collider.getPosition().getGlobalY());
             m_nextPosition.Y = m_position.getGlobalY();
             m_speed.Y = 0;
             m_speed.X = 0;
             m_currentState = State.Hanging;
             m_facingRight = true;
             m_hangSound.play();
         }
         else if (!t_colliderBox.Contains((int)m_lastPosition.X - 4, (int)m_lastPosition.Y)
             && t_colliderBox.Contains((int)m_position.getGlobalX() - 4, (int)m_position.getGlobalY())
             && m_lastPosition.Y < t_colliderBox.Y
             && m_speed.Y >= 0
             && (m_currentState == State.Jumping || m_currentState == State.Slide))
         {
             m_position.setLocalY(a_collider.getPosition().getGlobalY());
             m_nextPosition.Y = m_position.getGlobalY();
             m_speed.Y = 0;
             m_speed.X = 0;
             m_currentState = State.Hanging;
             m_facingRight = false;
             m_hangSound.play();
         }
     }
 }
开发者ID:melburn,项目名称:GLhf,代码行数:36,代码来源:Player.cs


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