public static ABullet create() { ABullet bullet = Res.createFromPool(MainRes.bulletPool) as ABullet; bullet.addToScene(); return(bullet); }
public static void Update(GameTime time, Map map, List <Character> character) { for (uint i = 0; i < numberofBullets; ++i) { ABullet c = bullets[i]; if (Math.Abs(c.Position.X) > 10000) { swap(i, --numberofBullets); } c.Update(time); c.Collide(map); foreach (Character a in character) { c.Collide(a); } if (c.dead) { swap(i, --numberofBullets); } } }
static void swap(uint a, uint b) { ABullet tmp = bullets[a]; bullets[a] = bullets[b]; bullets[b] = tmp; }
public static void Draw(SpriteBatch batch) { for (uint i = 0; i < numberofBullets; ++i) { ABullet c = bullets[i]; c.Draw(batch); } }
public virtual void Shoot() { if (CurrentEnemy) { ABullet clone = Instantiate(BulletPrefab, transform.position, transform.rotation); clone.Target = CurrentEnemy.gameObject; clone.damage = Damage; clone.targetPos = CurrentEnemy.transform.position; _dpsTimer = 0; } }
void shootBullet(Vector3 direct) { ABullet bullet = ABullet.create(); if (bullet == null) { return; } bullet.addToGroup(Groups.bulletAll); bullet.transform.position = gunRoot.position; bullet.speedVec = direct; Sound.createAndPlay("cannonShootShort", bullet.transform.position, 0.1f); }
public void collideTest(List <SCENE_OBJ> bulletGroup) { if (bulletGroup == null) { return; } for (int i = 0; i < bulletGroup.Count; i++) { ABullet otherObj = bulletGroup[i] as ABullet; calculateGlobalspeedAndRelateVec(this, otherObj); if (!isObjsMatchCondition(otherObj)) { return; } collideTest(collideBoxs, otherObj); } }
void FixedUpdate() { if (Input.GetButton("Fire1") && CanShot && automatic) { CanShot = false; CameraController.ShakeCamera(ScreenShake, 0.1f); player.Knockback = KnockBack; SetDispersion(); if (Gun == Guns.MINE) { Instantiate(BulletPrefabs[(int)Bullet], transform.position, Quaternion.identity); } else if (Gun == Guns.SHOTGUN) { for (int i = 0; i < 6; i++) { Object = Instantiate(BulletPrefabs[(int)Bullet], new Vector2(transform.position.x + GetSpawnPoint() + i * transform.parent.localScale.x / 2, transform.position.y + Random.Range(-0.5f, 0.5f)), Quaternion.identity); aBullet = Object.gameObject.GetComponent <ABullet>(); aBullet.LifeTime = Random.Range(LifeTime, LifeTime * 2); aBullet.Velocity = new Vector2(Random.Range(Velocity.x, Velocity.x * 2), Velocity.y); aBullet.Damage = Damage; aBullet.Flip(transform.parent.localScale); } } else if (Gun == Guns.GRENADELAUNCHER) { Object = Instantiate(BulletPrefabs[(int)Bullet], new Vector2(transform.position.x + GetSpawnPoint(), transform.position.y), Quaternion.identity); aBullet = Object.gameObject.GetComponentInChildren <ABullet>(); aBullet.Velocity = Velocity; aBullet.Flip(transform.parent.localScale); } else { Object = Instantiate(BulletPrefabs[(int)Bullet], new Vector2(transform.position.x + GetSpawnPoint(), transform.position.y), Quaternion.identity); aBullet = Object.gameObject.GetComponent <ABullet>(); aBullet.LifeTime = LifeTime; aBullet.Velocity = Velocity; aBullet.Damage = Damage; aBullet.Flip(transform.parent.localScale); } } else if (Input.GetKeyDown(KeyCode.Space) && !automatic) { CameraController.ShakeCamera(ScreenShake, 0.1f); player.Knockback = KnockBack; if (Gun == Guns.DOUBLEPISTOL) { Object = Instantiate(BulletPrefabs[(int)Bullet], new Vector2(transform.position.x - GetSpawnPoint(), transform.position.y), Quaternion.identity); aBullet = Object.gameObject.GetComponent <ABullet>(); aBullet.LifeTime = LifeTime; aBullet.Velocity = Velocity * -1; aBullet.Damage = Damage; aBullet.Flip(transform.parent.localScale); Object = Instantiate(BulletPrefabs[(int)Bullet], new Vector2(transform.position.x + GetSpawnPoint(), transform.position.y), Quaternion.identity); aBullet = Object.gameObject.GetComponent <ABullet>(); aBullet.LifeTime = LifeTime; aBullet.Velocity = Velocity; aBullet.Damage = Damage; aBullet.Flip(transform.parent.localScale); } else { Object = Instantiate(BulletPrefabs[(int)Bullet], new Vector2(transform.position.x + GetSpawnPoint(), transform.position.y), Quaternion.identity); aBullet = Object.gameObject.GetComponent <ABullet>(); aBullet.LifeTime = LifeTime; aBullet.Velocity = Velocity; aBullet.Damage = Damage; aBullet.Flip(transform.parent.localScale); } } else { player.Knockback = 0; } }