void InstantiateBullet(GameObject hitObj) { GameObject bullet_obj = Instantiate(_bulletPrefab); // Set it's position and rotation based on the gun positon. bullet_obj.transform.position = _gunPos.position; bullet_obj.transform.rotation = _gunPos.rotation; ProjectileBullet bullet = bullet_obj.GetComponent <ProjectileBullet>(); bullet.SetTarget(hitObj); bullet.playerNum = _playerNum; }
public override void MouseDown(Point Target)//Vector2 MouseDir) { if (m_CanShoot) { m_CanShoot = false; m_WeaponTimer.Start(); //m_MouseDir = MouseDir; NBulletInCharger--; double Radians = Math.Atan2(Target.Y - Owner.Y, Target.X - Owner.X) + ((m_RNG.NextDouble() * m_SpreadAngle) - m_SpreadAngle / 2.0) * (Math.PI / 180.0); Vector2 MouseDir = new Vector2((float)Math.Cos(Radians), (float)Math.Sin(Radians)); ProjectileBullet bullet = new ProjectileBullet(TextureManager.TextureBullet, new Vector2(Owner.X, Owner.Y), new Vector2(8, 8), MouseDir * m_BulletSpeed, 10); bullet.Friendly = true; EntityManager.Instance.ProjectilesListFriendly.Add(bullet); JouerSonTir(); } else { JouerSonVide(); } }