本文整理汇总了C#中Bullet.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Bullet.GetType方法的具体用法?C# Bullet.GetType怎么用?C# Bullet.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bullet
的用法示例。
在下文中一共展示了Bullet.GetType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Hit
public override void Hit(RaycastHit rayHit, Bullet bullet)
{
if (TryBreak(rayHit, bullet))
return;
// check if a vector is valid
Func<Vector3, bool> isValid = (vec)=> {
return Vector3.Angle(BulletNormal(rayHit), vec)<90;
};
// find the first direction
Vector3[] directions = new Vector3[numBullets];
directions[0] = BulletVelocity(rayHit, bullet);
if (numBullets%2==0)
directions[0] = Quaternion.AngleAxis(angle/2, Vector3.forward)*directions[0];
if (!isValid(directions[0]))
directions[0] = Quaternion.AngleAxis(-angle/2, Vector3.forward)*directions[0];
// find the first side of directions
Vector3 prev = directions[0];
int i;
for (i=1; i<1+numBullets/2; ++i) {
prev = Quaternion.AngleAxis(angle, Vector3.forward)*prev;
if (!isValid(prev))
break;
directions[i] = prev;
}
// find the second side of directions
prev = directions[0];
for (; i<numBullets; ++i) {
prev = Quaternion.AngleAxis(-angle, Vector3.forward)*prev;
if (!isValid(prev))
break;
directions[i] = prev;
}
// finish the first side, if necessary
prev = directions[numBullets/2];
for (; i<numBullets; ++i) {
prev = Quaternion.AngleAxis(angle, Vector3.forward)*prev;
if (!isValid(prev))
throw new Exception("Invalid combination of bullets and angles");
directions[i] = prev;
}
// create the bullets
CreateBullet(rayHit, bullet.GetType(), BulletRemainVel(rayHit, bullet, directions[0]), directions[0], false, bullet.numHits);
if (bullet.canSplit && (bullet.GetType()==typeof(PlayerBullet) || bullet.GetType()==typeof(EnemyBullet)))
{
for (i = 1; i < directions.Length; ++i)
{
//rayHit.point += BulletNormal(rayHit);
CreateBullet(rayHit, bullet.GetType(), BulletRemainVel(rayHit, bullet, directions[i]), directions[i], false, bullet.numHits);
}
}
}
示例2: TryBreak
protected virtual bool TryBreak(RaycastHit rayHit, Bullet bullet)
{
if (--health<=0) {
CreateBullet(rayHit, bullet.GetType(), Vector3.zero, bullet.vel, bullet.canSplit, bullet.numHits);
Destroy(gameObject);
return true;
}
return false;
}
示例3: Hit
public override void Hit(RaycastHit rayHit, Bullet bullet)
{
if (bullet is PlayerBullet)
{
meter -= bullet.vel.magnitude / 12;
if (meter <= 0)
{
switchOn = true;
GetComponent<Animator>().SetBool("turnOn", true);
}
}
else
CreateBullet(rayHit, bullet.GetType(), BulletRemainVel(rayHit, bullet), BulletVelocity(rayHit, bullet), bullet.canSplit, bullet.numHits);
}
示例4: Hit
public virtual void Hit(RaycastHit rayHit, Bullet bullet)
{
if (TryBreak(rayHit, bullet))
return;
CreateBullet(rayHit, bullet.GetType(), BulletRemainVel(rayHit, bullet), BulletVelocity(rayHit, bullet), bullet.canSplit, bullet.numHits);
}
示例5: RemoveBullet
public void RemoveBullet(Bullet bullet)
{
pool[bullet.GetType().ToString()].Remove(bullet);
}
示例6: PutBullet
public void PutBullet(Bullet bullet)
{
if (!pool.ContainsKey(bullet.GetType().ToString())) {
pool.Add(bullet.GetType().ToString(), new List<Bullet>());
}
bullet.Init();
pool[bullet.GetType().ToString()].Add(bullet);
}