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


C# Entity.GetPosZ方法代码示例

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


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

示例1: FollowTarget

        public virtual void FollowTarget(Entity target)
        {
            float maxDistance = 240f;
            float distance = Vector2.Distance(GetConvertedPosition(), target.GetConvertedPosition());

            followPosition.X = target.GetPosX() - GetPosX();
            followPosition.Y = (target.GetPosZ() - GetPosZ()) + 91;
            followPosition.Normalize();

            if (distance < maxDistance)
            {
                followPosition.X = 0;
                followPosition.Y = 0;

                if (this.InRangeZ(target, 130))
                {
                    SetAnimationState(Animation.State.ATTACK1);
                }
                else
                {
                    SetAnimationState(Animation.State.STANCE);
                }
            }
            else
            {
                SetAnimationState(Animation.State.WALK_TOWARDS);
            }

            VelX(followPosition.X * 1.6f);
            VelZ(followPosition.Y * 2.1f);
        }
开发者ID:lodossDev,项目名称:gameengine,代码行数:31,代码来源:Character.cs

示例2: InBoundsZ

 public static bool InBoundsZ(this Entity e1, Entity e2, float range)
 {
     return InRangeZ(e1, e2, range)
                 && !(e1.GetPosZ() <= e2.GetPosZ() - range)
                 && !(e1.GetPosZ() >= e2.GetPosZ() + range);
 }
开发者ID:lodossDev,项目名称:gameengine,代码行数:6,代码来源:CollisionHelper.cs

示例3: InRangeZ

 public static bool InRangeZ(this Entity e1, Entity e2, float range)
 {
     return (GetDiff(e1.GetPosZ(), e2.GetPosZ()) <= range);
 }
开发者ID:lodossDev,项目名称:gameengine,代码行数:4,代码来源:CollisionHelper.cs

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


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