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


C# Bullet.GetType方法代码示例

本文整理汇总了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);
            }
        }
    }
开发者ID:MaouDragon,项目名称:Biodrone,代码行数:57,代码来源:MultiWall.cs

示例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;
 }
开发者ID:MaouDragon,项目名称:Biodrone,代码行数:9,代码来源:Wall.cs

示例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);
 }
开发者ID:MaouDragon,项目名称:Biodrone,代码行数:14,代码来源:SwitchWall.cs

示例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);
 }
开发者ID:MaouDragon,项目名称:Biodrone,代码行数:6,代码来源:Wall.cs

示例5: RemoveBullet

 public void RemoveBullet(Bullet bullet)
 {
     pool[bullet.GetType().ToString()].Remove(bullet);
 }
开发者ID:Nayael,项目名称:VeryOriginalFPS,代码行数:4,代码来源:BulletsManager.cs

示例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);
 }
开发者ID:Nayael,项目名称:VeryOriginalFPS,代码行数:8,代码来源:BulletsManager.cs


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