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


C# Entity.GetPosY方法代码示例

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


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

示例1: FindBelow

        public List<Entity> FindBelow(Entity entity)
        {
            List<Entity> found = new List<Entity>();
            Rectangle entityBox = entity.GetBoxes(CLNS.BoxType.BOUNDS_BOX)[0].GetRect();
            float ePosY = Math.Abs(entity.GetPosY());

            foreach (Entity target in entities)
            {
                if (entity != target && target.IsEntity(Entity.EntityType.OBSTACLE))
                {
                    Rectangle targetBox = target.GetBoxes(CLNS.BoxType.BOUNDS_BOX)[0].GetRect();
                    Rectangle heightBox = target.GetBoxes(CLNS.BoxType.BOUNDS_BOX)[0].GetRect();
                    float tPosY = Math.Abs(target.GetPosY());

                    if (entity.InBoundsZ(target, target.GetDepth())
                            && entityBox.Intersects(targetBox)
                            && Math.Abs(entity.GetPosY()) + 50 >= Math.Abs(target.GetPosY()) + target.GetHeight())
                    {
                        found.Add(target);
                    }
                }
            }

            return found;
        }
开发者ID:lodossDev,项目名称:gameengine,代码行数:25,代码来源:CollisionManager.cs

示例2: TargetBodyY

 private float TargetBodyY(Entity target, Entity entity, CLNS.AttackBox attack)
 {
     float y1 = entity.GetPosY();
     return (y1) - (attack.GetRect().Height / 1.5f) + (attack.GetOffset().Y);
 }
开发者ID:lodossDev,项目名称:gameengine,代码行数:5,代码来源:CollisionManager.cs

示例3: CheckBounds

        private void CheckBounds(Entity entity)
        {
            List<CLNS.BoundsBox> bboxes = entity.GetBoxes(CLNS.BoxType.BOUNDS_BOX).Cast<CLNS.BoundsBox>().ToList();
            bboxes.AddRange(entity.GetCurrentBoxes(CLNS.BoxType.BOUNDS_BOX).Cast<CLNS.BoundsBox>().ToList());
            CLNS.BoundsBox entityBox = null;
           
            int ePosY = (int)Math.Abs(entity.GetPosY());
            int eGround = (int)Math.Abs(entity.GetGround());
            bool onTop = false;
            
            foreach (Entity target in entities)
            {
                if (entity != target && target.IsEntity(Entity.EntityType.OBSTACLE))
                {
                    List<CLNS.BoundsBox> tboxes = target.GetBoxes(CLNS.BoxType.BOUNDS_BOX).Cast<CLNS.BoundsBox>().ToList();
                    tboxes.AddRange(target.GetCurrentBoxes(CLNS.BoxType.BOUNDS_BOX).Cast<CLNS.BoundsBox>().ToList());
                    CLNS.BoundsBox targetBox = null;
                    bool hasCollided = false;

                    int tPosY = (int)Math.Abs(target.GetPosY());
                    int tGround = (int)Math.Abs(target.GetGround());
                    
                    foreach (CLNS.BoundsBox bb1 in bboxes)
                    {
                        foreach (CLNS.BoundsBox bb2 in tboxes)
                        {
                            if (entity.InBoundsZ(target, bb2.GetZdepth()) 
                                    && bb1.GetRect().Intersects(bb2.GetRect()))
                            {
                                entityBox = bb1;
                                targetBox = bb2;
                                hasCollided = true;
                                break;
                            }
                        }
                    }

                    if (hasCollided && entityBox != null && targetBox != null)
                    {
                        //Debug.WriteLine("TT tPosY: " + target.GetName() + ": " + tPosY);
                        //Debug.WriteLine("E: " + entity.GetName() + " : " + (ePosY + entity.GetHeight()));

                        //Problem with tposy not updating in time for comparison
                        if (entityBox.GetRect().Intersects(targetBox.GetRect()))
                        {
                            int eHeight = (int)(entityBox.GetHeight() + eGround);
                            int tHeight = (int)(targetBox.GetHeight() + tGround);
                            Debug.WriteLine("tHeight: " + tHeight);

                            if (entityBox.GetRect().InBoundsX(targetBox.GetRect(), 60)
                                   && entity.InBoundsZ(target, targetBox.GetZdepth() - 5)
                                   && entityBox.GetRect().TouchTop(targetBox.GetRect(), 10))
                            {
                                onTop = true;
                            }

                            if (entityBox.GetRect().InBoundsX(targetBox.GetRect(), 60) 
                                    && entity.InBoundsZ(target, targetBox.GetZdepth() - 5) 
                                    && entityBox.GetRect().TouchTop(targetBox.GetRect(), 10)
                                    && entity.GetVelocity().Y > 1)
                            {
                                entity.SetGround(-(tHeight + 1));
                            }

                            bool over = false;

                            if (targetBox.GetRect().TouchTop(entityBox.GetRect(), 10)
                                    && tGround >= eGround)
                            {
                                over = true;
                            }

                            if (ePosY < tHeight - 10)
                            {
                                if (entity.InBoundsZ(target, targetBox.GetZdepth() - 5) && over == false)
                                {
                                    float depth = entityBox.GetRect().GetHorizontalIntersectionDepth(targetBox.GetRect());

                                    if (depth != 0)
                                    {
                                        if (!entity.IsLeft() && entityBox.GetRect().TouchLeft(targetBox.GetRect()))
                                        {
                                            entity.MoveX(depth + 5);
                                            entity.GetCollisionInfo().Right();
                                            entity.VelX(0f);
                                        }
                                        else if (entity.IsLeft() && entityBox.GetRect().TouchRight(targetBox.GetRect()))
                                        {
                                            entity.MoveX(depth - 5);
                                            entity.GetCollisionInfo().Left();
                                            entity.VelX(0f);
                                        }
                                    }
                                }

                                if (entity.GetDirZ() > 0 && entity.GetPosZ() <= target.GetPosZ())
                                {
                                    entity.VelZ(0f);
                                    entity.GetCollisionInfo().Top();
                                }
//.........这里部分代码省略.........
开发者ID:lodossDev,项目名称:gameengine,代码行数:101,代码来源:CollisionManager.cs

示例4: CheckLand

        private void CheckLand(Entity entity)
        {
            Rectangle entityBox = entity.GetBoxes(CLNS.BoxType.BOUNDS_BOX)[0].GetRect();
            
            foreach (Entity target in entities)
            {
                if (entity != target && target.IsEntity(Entity.EntityType.OBSTACLE))
                {
                    Rectangle targetBox = target.GetBoxes(CLNS.BoxType.BOUNDS_BOX)[0].GetRect();

                    if (entity.InBoundsZ(target, target.GetDepth())
                           && entityBox.Intersects(targetBox)
                           && entityBox.TouchBottom(targetBox)
                           && !entityBox.TouchTop(targetBox)
                           && entity.InAir())
                    {
                        float depth = entityBox.GetVerticalIntersectionDepth(targetBox);

                        if (!target.IsToss())
                        {
                            entity.MoveY(depth + 5);
                        }

                        entity.GetTossInfo().velocity.Y = 5;
                    }
                }
            }

            foreach (Entity target in entities)
            {
                if (entity != target && target.IsEntity(Entity.EntityType.OBSTACLE))
                {
                    Rectangle targetBox = target.GetBoxes(CLNS.BoxType.BOUNDS_BOX)[0].GetRect();
                    float posy = (Math.Abs(target.GetPosY()) + target.GetHeight());

                    if (entity.InBoundsZ(target, target.GetDepth())
                            && entityBox.Intersects(targetBox)
                            && entityBox.InBoundsX(targetBox, 20))
                    {
                        List<Entity> above = FindAbove(target);
                        int totalHeight = (int)Math.Abs(target.GetPosY()) + target.GetHeight() + above.Sum(e => e.GetHeight());
                        totalHeight = (above.Count == 0 ? (int)Math.Abs(target.GetPosY()) + totalHeight : totalHeight);
    
                        if (entity.GetVelocity().Y > 2 && Math.Abs(entity.GetPosY() + 20) > totalHeight)
                        {
                            entity.SetGround(-posy);
                        }

                        if (entity.GetVelocity().Y > 2 && Math.Abs(entity.GetPosY()) + 20 > Math.Abs(target.GetPosY()) + target.GetHeight())
                        {
                            entity.SetGround(-posy);
                        }

                        if (target.IsToss() && Math.Abs(entity.GetPosY()) + 50 > Math.Abs(target.GetPosY()) + target.GetHeight())
                        {
                            entity.SetPosY(-posy);
                            entity.SetGround(-posy);
                        }
                    }
                }
            }
        }
开发者ID:lodossDev,项目名称:gameengine,代码行数:62,代码来源:CollisionManager.cs

示例5: CheckFall

        private void CheckFall(Entity entity)
        {
            List<Entity> belowEntities = FindBelow(entity);

            if ((belowEntities.Count == 0 && entity.GetGround() != entity.GetGroundBase()
                    && entity.HasLanded()) || (belowEntities.Count == 0 
                                                    && Math.Abs(entity.GetPosY()) != entity.GetGround()
                                                    && !entity.IsToss()))
            {
                entity.SetGround(entity.GetGroundBase());

                if (!entity.IsToss())
                {
                    entity.SetAnimationState(Animation.State.FALL1);
                    entity.Toss(5);
                }
            }
        }
开发者ID:lodossDev,项目名称:gameengine,代码行数:18,代码来源:CollisionManager.cs

示例6: FindAbove

        public List<Entity> FindAbove(Entity entity)
        {
            List<Entity> found = new List<Entity>();
            Rectangle entityBox = entity.GetBoxes(CLNS.BoxType.BOUNDS_BOX)[0].GetRect();

            foreach (Entity target in entities)
            {
                if (entity != target && target.IsEntity(Entity.EntityType.OBSTACLE))
                {
                    Rectangle targetBox = target.GetBoxes(CLNS.BoxType.BOUNDS_BOX)[0].GetRect();

                    if (entity.InRangeZ(target, target.GetDepth())
                            && entityBox.InBoundsX(targetBox, 20)
                            && entityBox.Intersects(targetBox)
                            && (Math.Abs(target.GetPosY()) + Math.Abs(target.GetHeight()) + 1) > Math.Abs(entity.GetPosY())
                            && !(Math.Abs(entity.GetPosY()) + 20 >= (Math.Abs(target.GetPosY()) + Math.Abs(target.GetHeight())))
                            && Math.Abs(entity.GetPosY()) < Math.Abs(target.GetPosY()))
                    {
                        found.Add(target);
                    }
                }
            }

            return found;
        }
开发者ID:lodossDev,项目名称:gameengine,代码行数:25,代码来源:CollisionManager.cs


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