本文整理汇总了C#中System.Entity.GetBoxes方法的典型用法代码示例。如果您正苦于以下问题:C# Entity.GetBoxes方法的具体用法?C# Entity.GetBoxes怎么用?C# Entity.GetBoxes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Entity
的用法示例。
在下文中一共展示了Entity.GetBoxes方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: TouchBottom
public List<Entity> TouchBottom(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)
{
Rectangle targetBox = target.GetBoxes(CLNS.BoxType.BOUNDS_BOX)[0].GetRect();
if (entity.InBoundsZ(target, target.GetDepth())
&& entityBox.TouchBottom(targetBox))
{
found.Add(target);
}
}
}
return found;
}
示例3: 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);
}
}
}
}
}
示例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();
}
//.........这里部分代码省略.........
示例5: 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;
}