本文整理汇总了C#中CollisionType类的典型用法代码示例。如果您正苦于以下问题:C# CollisionType类的具体用法?C# CollisionType怎么用?C# CollisionType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CollisionType类属于命名空间,在下文中一共展示了CollisionType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckBuildingCollision
public CollisionType CheckBuildingCollision(Base3DObject bob)
{
//3 types of collision: no collision, crash and landing
ct = CollisionType.None;
for (int c = 0; c < blocks.Length; c++)
{
if (blocks[c].Collided(bob))
{
blocks[c].HitTest = true;
bob.HitTest = true;
ct = CollisionType.Building;
if (bob.Bounds.Min.Y > (blocks[c].Bounds.Max.Y - playerSafeZones.Y) && (bob.Bounds.Min.X > blocks[c].Bounds.Min.X + playerSafeZones.X && bob.Bounds.Max.X < blocks[c].Bounds.Max.X - playerSafeZones.X && bob.Bounds.Min.Z > blocks[c].Bounds.Min.Z + playerSafeZones.Z && bob.Bounds.Max.Z < blocks[c].Bounds.Max.Z - playerSafeZones.Z))
{
ct = CollisionType.Roof;
}
break;
}
else
{
blocks[c].HitTest = false;
bob.HitTest = false;
}
}
return ct;
}
示例2: Collision
public Collision(Rectangle S,Rectangle D,CollisionType T,CollisionDirection Di)
{
Src = S;
Dest = D;
Type = T;
Dir = Di;
}
示例3: SimpleButton
private float ReleaseTime; //tmp ?
public SimpleButton(Vector2 position, Vector2 size, float reltime = 0.3f, CollisionType ctype = CollisionType.Rectangle, Texture2D textureoff = null, Texture2D textureon = null)
{
Position = position;
Size = size;
ReleasedTexture = textureoff;
PressedTexture = textureon;
// button area is set whatever collision type because it is also use for drawing
if (ctype == CollisionType.Rectangle)
{
ButtonArea = new Rectangle((int)position.X, (int)position.Y, (int)Size.X, (int)size.Y);
collisionType = CollisionType.Rectangle;
}
else
{
ButtonAreaCircle = new Circle(Size.X /2.0f, new Vector2(position.X, position.Y));
// a bit complicated this way
ButtonArea = new Rectangle((int)position.X - (int)Size.X / 2, (int)position.Y - (int)Size.Y / 2, (int)Size.X, (int)size.Y);
collisionType = CollisionType.Circle;
}
buttonState = buttonState.Released;
currentTexture = ReleasedTexture;
Enabled = true;
EnableTint = false;
tintColour = Color.White;
pressedTime = 0;
ReleaseTime = reltime;
}
示例4: Missile
public Missile(Game game, Model m, CollisionType type, Vector3 start, Entity target, float speed)
: base(game,m,type,start,Vector3.Zero,speed,50)
{
var exhaust = new MissileExhaustParticleSystem(game, ((Game1)Game).Content);
ParticleEmitterManager.addParticleEmitter(new ParticleEmitter(Game, exhaust, 1000, lifeTime, getExhaustPosition));
addComponent(new PathingChase(game, this, target, speed, true));
}
示例5: CollisionComponent
//List<Polygon> polygons
public CollisionComponent(GameObject gameObject, List<Polygon> polygons, List<AABB> axisAlignedBoxes)
: base(gameObject)
{
Name = "CollisionComponent";
this.axisAlignedBoxes = axisAlignedBoxes;
this.polygons = polygons;
hasCollided = false;
if (polygons != null && axisAlignedBoxes != null)
{
collisionType = CollisionType.POLYGON_AND_AABB;
ParentObject.Properties.updateProperty<List<AABB>>("AABB", axisAlignedBoxes);
ParentObject.Properties.updateProperty<List<Polygon>>("Polygon", polygons);
}
else if (polygons != null)
{
collisionType = CollisionType.POLYGON;
ParentObject.Properties.updateProperty<List<Polygon>>("Polygon", polygons);
}
else if (axisAlignedBoxes != null)
{
collisionType = CollisionType.AABB;
ParentObject.Properties.updateProperty<List<AABB>>("AABB", axisAlignedBoxes);
}
else
{
collisionType = CollisionType.NO_TYPE;
}
ParentObject.Properties.updateProperty<CollisionType>("CollisionType", collisionType);
ParentObject.Properties.updateProperty<bool>("HasCollided", hasCollided);
ParentObject.Properties.updateProperty<bool>("IsCollisionActive", true);
}
示例6: Awake
void Awake()
{
// initialization
collisionType = CollisionType.Box;
setCollisionType(collisionType);
}
示例7: setCollisionType
//This toggles if the world bounds are a sphere or a rectangle.
void setCollisionType(CollisionType ct)
{
// mutate dat shit
collisionType = ct;
// remove any collider currently on the worldbounds.
Destroy (gameObject.GetComponent<BoxCollider>());
Destroy (gameObject.GetComponent<SphereCollider>());
// based on the collisionType variable, add a new collider with some default
// parameters.
switch(collisionType)
{
case CollisionType.Sphere:
collScript = this.gameObject.AddComponent<SphereCollider>();
collScript.isTrigger = true;
setScale(500, 0, 0);
break;
case CollisionType.Box:
collScript = this.gameObject.AddComponent<BoxCollider>();
collScript.isTrigger = true;
setScale (1000,1000, 1000);
break;
}
}
示例8: Collision
public Collision(CollisionType type = CollisionType.CourseCollision)
{
Result = 0;
TeacherId = -1;
SlotId = -1;
Type = type;
CrashingCourses = new List<Course>();
}
示例9: Reset
public override void Reset()
{
collision = CollisionType.OnCollisionEnter;
collideTag = "Untagged";
sendEvent = null;
storeCollider = null;
storeForce = null;
}
示例10: CollisionUnit
/// <summary>
/// Instantiate a new CollisionUnit. This constructor is for circle based collisions.
/// </summary>
/// <param name="owner">The "owner" Entity that this CollisionUnit will be for.</param>
/// <param name="center">The location of the circle center.</param>
/// <param name="radius">The radius of the circle.</param>
/// <param name="collisionMask">Collision mask for the object.</param>
/// <param name="bUsePixelCollision">Is pixel-perfect collisions should be used.</param>
public CollisionUnit(Entity owner, Vector2 center, int radius, Texture2D collisionMask, bool bUsePixelCollision)
{
InitializeCommonStuff(owner, collisionMask, bUsePixelCollision);
mCircleCenter = center;
mCircleRadius = radius;
mOrigRadius = radius;
mCollisionType = CollisionType.COLLISION_CIRCLE;
}
示例11: AddNewData
protected override int AddNewData()
{
m_collisionType = DataManager.Generate<CollisionType>();
m_collisionType.Name = m_textBox_name.Text;
DataManager.CollisionTypes.Add(m_collisionType);
return m_collisionType.Id;
}
示例12: Start
void Start()
{
// Set collision
// toggle ON/OFF your choice of raycast
//collisionType = CollisionType.CLICKHITONE; // hit just one object
collisionType = CollisionType.CLICKHITALL; // hit multiple objects overlapping
//collisionType = CollisionType.MOUSEPOSITION; // continuous mouse position detection
}
示例13: CanTraverse
/// <summary>
/// Indicates whether the class can traverse this CollisionType or not.
/// </summary>
/// <param name="toTraverse">
/// The CollisionType to traverse.
/// </param>
/// <returns>
/// True if the unit can traverse it.
/// False if the unit cannot.
/// </returns>
public override bool CanTraverse(CollisionType toTraverse)
{
if (toTraverse == CollisionType.None)
{
return true;
}
return false;
}
示例14: Trile
public Trile(CollisionType faceType)
: this()
{
this.Faces.Add(FaceOrientation.Back, faceType);
this.Faces.Add(FaceOrientation.Front, faceType);
this.Faces.Add(FaceOrientation.Left, faceType);
this.Faces.Add(FaceOrientation.Right, faceType);
this.MissingTrixels.OnDeserialization();
}
示例15: Collidable
public Collidable(Game game, Entity.Entity parent, CollisionType type, CollisionEvent e, int health, int damage, Collidable parentCollidable, BoundingBox boundingBox)
: base(game, parent)
{
this.onCollision = e;
this.type = type;
this.health = health;
this.damage = damage;
children = new List<Collidable>();
parentCollidable.addChild(this);
this.boundingBox = boundingBox;
}