public void DeleteBulletCommand(BulletInfo in_info)
 {
     if (!IsLocalPlayer || !_hasAuthority)
     {
         return;
     }
     DeleteBullet(in_info);
 }
        //[command]
        void CmdSpawnBullet()
        {
            int       id = m_gMan.GetNextBulletID();
            Transform m_bulletSpawnPoint = m_playerPlane.m_bulletSpawnPoint;
            Vector3   m_bulletVelocity   = m_bulletSpawnPoint.forward.normalized;

            m_bulletVelocity *= WeaponController.m_bulletSpeed;
            m_bulletVelocity += m_playerPlane.GetComponent <Rigidbody>().velocity;
            BulletInfo aBulletInfo = new BulletInfo(m_bulletSpawnPoint.position, m_bulletSpawnPoint.forward.normalized, NetId, m_bulletVelocity, id);
            GameObject bullet      = WeaponController.SpawnBullet(aBulletInfo);

            m_gMan.AddBulletInfo(aBulletInfo);

            SendProjectileStart(BombersNetworkManager.BULLET, aBulletInfo.GetDict());
        }
        public void BulletHitPlayerCommand(BulletInfo bulletInfo, Vector3 aHitPoint)
        {
            BombersPlayerController tempController;

            foreach (LobbyMemberInfo member in BombersNetworkManager.LobbyInfo.Members)
            {
                tempController = member.PlayerController;
                if (tempController.NetId == bulletInfo.m_hitId)
                {
                    bulletInfo.m_startPosition = tempController.m_playerPlane.transform.position + aHitPoint;
                    SendProjectileStart(BombersNetworkManager.BULLET_HIT, bulletInfo.GetDict());
                    m_gMan.RpcBulletHitPlayer(bulletInfo);
                    break;
                }
            }
        }
Esempio n. 4
0
        public GameObject SpawnBullet(BulletInfo aBulletInfo)
        {
            GameObject      player = null;
            PlaneController playerPlaneController = null;
            PlaneController tempPlaneController   = null;
            BCLobbyInfo     info = BombersNetworkManager.LobbyInfo;

            foreach (LobbyMemberInfo member in info.Members)
            {
                tempPlaneController = member.PlayerController.m_playerPlane;
                if (tempPlaneController.NetId == aBulletInfo.m_shooter)
                {
                    player = member.PlayerController.gameObject;
                    playerPlaneController = tempPlaneController;
                    break;
                }
            }

            if (playerPlaneController != null && playerPlaneController.PlayerController.m_planeActive)
            {
                playerPlaneController.ResetGunCharge();
                GameObject flare = (GameObject)Instantiate(m_muzzleFlarePrefab, aBulletInfo.m_startPosition, playerPlaneController.m_bulletSpawnPoint.rotation);
                flare.transform.parent = player.transform;
                flare.GetComponent <AudioSource>().pitch = 1 + Random.Range(-2.0f, 3.0f) * 0.2f;
                if (aBulletInfo.m_shooter == playerPlaneController.NetId)
                {
                    flare.GetComponent <AudioSource>().spatialBlend = 0;
                }
            }
            int        team   = player.GetComponent <BombersPlayerController>().m_team;
            GameObject bullet = (GameObject)Instantiate((team == 1) ? m_bullet1Prefab : m_bullet2Prefab, aBulletInfo.m_startPosition, Quaternion.LookRotation(aBulletInfo.m_startDirection, -Vector3.forward));

            bullet.GetComponent <Rigidbody>().velocity = aBulletInfo.m_startVelocity;
            bullet.GetComponent <BulletController>().SetBulletInfo(aBulletInfo);

            return(bullet);
        }
 public void SetBulletInfo(BulletInfo aBulletInfo)
 {
     m_bulletInfo            = aBulletInfo;
     m_bulletInfo.gameObject = this.gameObject;
 }
 void DeleteBullet(BulletInfo in_info)
 {
     m_gMan.DeleteBullet(in_info);
     //SendDestroy(BombersNetworkManager.BULLET, in_info.m_bulletID.ToString(), in_info.GetJson());
     SendProjectileDestroy(BombersNetworkManager.BULLET, in_info.GetDict());
 }