virtual protected void onCollisionStay(Collider aCollision, PlaneController in_controller)
 {
     if (in_controller == _currentTarget)
     {
         _lastCollider = aCollision;
     }
 }
Пример #2
0
        /*
         * public void FireFlare(Vector3 aPosition, Vector3 aVelocity)
         * {
         *  float flareDelay = BrainCloudStats.Instance.m_flareCooldown;
         *  if ((Time.time - m_lastFlare) > flareDelay)
         *  {
         *      m_lastFlare = Time.time;
         *      GetComponent<BombersPlayerController>().FireFlareCommand(aPosition, aVelocity);
         *  }
         * }
         */

        public GameObject SpawnBomb(BombInfo aBombInfo)
        {
            m_bombs--;
            GameObject      player = null;
            PlaneController playerPlaneController = null;
            PlaneController tempPlaneController   = null;

            foreach (LobbyMemberInfo member in BombersNetworkManager.LobbyInfo.Members)
            {
                tempPlaneController = member.PlayerController.m_playerPlane;
                if (tempPlaneController.NetId == aBombInfo.m_shooter)
                {
                    player = member.PlayerController.gameObject;
                    playerPlaneController = tempPlaneController;
                    break;
                }
            }
            if (playerPlaneController != null)
            {
                GameObject flare = (GameObject)Instantiate(m_bombDropPrefab, player.transform.position, playerPlaneController.m_bulletSpawnPoint.rotation);
                flare.transform.parent = player.transform;
                if (aBombInfo.m_shooter == GetComponent <BombersPlayerController>().NetId)
                {
                    flare.GetComponent <AudioSource>().spatialBlend = 0;
                }
                flare.GetComponent <AudioSource>().Play();
            }

            GameObject bomb = (GameObject)Instantiate((BombersPlayerController.GetPlayer(aBombInfo.m_shooter).m_team == 1) ? m_bombPrefab1 : m_bombPrefab2, aBombInfo.m_startPosition, Quaternion.LookRotation(aBombInfo.m_startDirection, -Vector3.forward));

            bomb.GetComponent <Rigidbody>().velocity      = aBombInfo.m_startVelocity;
            bomb.GetComponent <BombController>().BombInfo = aBombInfo;
            return(bomb);
        }
Пример #3
0
        protected override void onCollisionStay(Collider aCollision, PlaneController in_controller)
        {
            if (ignoreDetectedCollision(in_controller))
            {
                return;
            }
            base.onCollisionStay(aCollision, in_controller);
            switch (_fsm.State)

            {
            case ePlayerControllerAIStates.ACQUIREDBOMB:
            {
                onAcquiredBombCollision(in_controller);
            }
            break;

            case ePlayerControllerAIStates.FOLLOW:
            {
                onFollowStateCollision(in_controller);
            }
            break;

            default: break;
            }
        }
        protected bool planeControllerCloserThenCurrentTarget(PlaneController in_controller)
        {
            float currentTargetMag  = _currentTarget != null ? (_currentTarget.m_playerPlane.transform.position - _playerController.m_playerPlane.transform.position).sqrMagnitude : float.MaxValue;
            float incomingTargetMag = (in_controller.transform.position - _playerController.m_playerPlane.transform.position).sqrMagnitude;

            return(incomingTargetMag <= currentTargetMag);
        }
Пример #5
0
 private void onAcquiredBombCollision(PlaneController in_controller)
 {
     if (_currentTarget != null &&
         in_controller.PlayerController.m_team != _playerController.m_team &&           // not on the same team
         _currentTarget.m_displayName == in_controller.PlayerController.m_displayName)  // same target
     {
         _fsm.ChangeState(ePlayerControllerAIStates.ATTACKING);
     }
 }
 public void SetPlayerPlane(PlaneController playerPlane)
 {
     m_playerPlane.m_health = m_baseHealth;
     m_planeActive          = true;
     ActivatePlane();
     m_leftBoundsTimer = 4;
     StopCoroutine("PulseMissionText");
     StartCoroutine("PulseMissionText");
     m_leftBounds      = false;
     m_currentRotation = m_playerPlane.gameObject.transform.rotation.eulerAngles.z;
     m_isActive        = true;
     WeaponController.SetPlayerPlane(m_playerPlane);
 }
Пример #7
0
        void onCollision(Collider aOther)
        {
            if (!m_isActive)
            {
                return;
            }
            PlaneController pController = aOther.GetComponent <PlaneController>();

            if (pController != null)
            {
                pController.PlayerController.BombPickedUpCommand(pController.PlayerController.NetId, m_pickupID);
                m_isActive = false;
                Destroy(gameObject);
            }
        }
Пример #8
0
 private void onFollowStateCollision(PlaneController in_controller)
 {
     if (_currentTarget != null &&
         in_controller.PlayerController.m_team != _playerController.m_team &&           // not on the same team
         _currentTarget.m_displayName == in_controller.PlayerController.m_displayName)  // same target
     {
         _fsm.ChangeState(ePlayerControllerAIStates.ATTACKING);
     }
     else if (allowedToTarget(in_controller))
     {
         // change the current target, we are still just going to follow
         if (planeControllerCloserThenCurrentTarget(in_controller))
         {
             _currentTarget = in_controller.PlayerController;
         }
     }
 }
Пример #9
0
 void OnCollisionEnter(Collision aCollision)
 {
     if (IsServer)
     {
         PlaneController planeController = aCollision.gameObject.GetComponent <PlaneController>();
         if (planeController != null)
         {
             m_bulletInfo.gameObject.transform.parent = aCollision.gameObject.transform;
             Vector3 relativeHitPoint = m_bulletInfo.gameObject.transform.localPosition;
             m_bulletInfo.gameObject.transform.parent = null;
             m_bulletInfo.m_hitId = planeController.NetId;
             planeController.transform.parent.GetComponent <BombersPlayerController>().BulletHitPlayerCommand(m_bulletInfo, relativeHitPoint);
         }
         BombersNetworkManager.LocalPlayer.DeleteBulletCommand(m_bulletInfo);
     }
     else
     {
         gameObject.SetActive(false);
     }
 }
Пример #10
0
        protected override void onCollisionEntered(Collider aCollision, PlaneController in_controller)
        {
            if (ignoreDetectedCollision(in_controller))
            {
                return;
            }
            base.onCollisionEntered(aCollision, in_controller);

            switch (_fsm.State)
            {
            // do nothing if we left bounds, we need to get back inbounds
            case ePlayerControllerAIStates.LEFTBOUNDS:
            { } break;

            case ePlayerControllerAIStates.ACQUIREDBOMB:
            {
                onAcquiredBombCollision(in_controller);
            }
            break;


            case ePlayerControllerAIStates.FOLLOW:
            {
                onFollowStateCollision(in_controller);
            }
            break;

            case ePlayerControllerAIStates.IDLE:
            default:
            {
                // new non enemy
                if (_currentTarget == null || allowedToTarget(in_controller))
                {
                    _currentTarget = in_controller.PlayerController;
                    _fsm.ChangeState(ePlayerControllerAIStates.FOLLOW);
                }
            }
            break;
            }
        }
        void LateUpdate()
        {
            PlaneController planeTarget = m_target != null?m_target.GetComponent <PlaneController>() : null;

            ShipController shipTarget = m_target != null?m_target.GetComponent <ShipController>() : null;

            if (m_target == null ||
                (planeTarget != null &&
                 (!planeTarget.PlayerController.m_planeActive ||
                  !planeTarget.PlayerController.WeaponController.HasBombs())) ||
                (shipTarget != null &&
                 (shipTarget.GetActiveShipTarget() == null || !m_parentController.WeaponController.HasBombs()))
                )
            {
                Destroy(gameObject);
                return;
            }

            Vector3 targetPos = m_target.position;

            targetPos.z       = transform.position.z; // make same linear plane as myself, so it doesn't rotate strangely
            m_rotatePtr.right = targetPos - transform.position;

            // Hide the reticle when the target is a ship and its distance is closer than LOW_TARGET_DISTANCE_SQR
            bool isWithinDistance = (targetPos - transform.position).sqrMagnitude < LOW_TARGET_DISTANCE_SQR;

            m_reticle.SetActive(!isWithinDistance);

            Vector3 eulerAngles = m_rotatePtr.eulerAngles;

            eulerAngles.z          += 90.0f;
            m_rotatePtr.eulerAngles = eulerAngles;

            if (m_staticTransform)
            {
                m_staticTransform.up = Vector3.up;
            }
        }
Пример #12
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);
        }
Пример #13
0
 private bool allowedToTarget(PlaneController in_controller)
 {
     return(planeControllerCloserThenCurrentTarget(in_controller) &&
            (in_controller.PlayerController.m_team != _playerController.m_team ||    // not on the same team
             in_controller.PlayerController.m_team == _playerController.m_team && (_currentTarget == null || _currentTarget.m_team == _playerController.m_team)));
 }
Пример #14
0
 public void DestroyPlayerPlane()
 {
     m_bombs            = 0;
     m_playerPlane      = null;
     m_bulletSpawnPoint = null;
 }
Пример #15
0
 public void SetPlayerPlane(PlaneController aPlane)
 {
     m_bombs            = 0;
     m_playerPlane      = aPlane;
     m_bulletSpawnPoint = aPlane.m_bulletSpawnPoint;
 }
 virtual protected void onCollisionExit(Collider aCollision, PlaneController in_controller)
 {
 }
 protected bool ignoreDetectedCollision(PlaneController in_controller)
 {
     return(!in_controller.PlayerController.m_planeActive ||                                                    // non active plane
            in_controller.IsServerBot && in_controller.PlayerController.m_team == _playerController.m_team);
 }