void RpcHitShipTargetPoint(int aShipID, int aTargetIndex, int aShooter) { ShipController.ShipTarget shipTarget = null; GameObject ship = null; ShipController.ShipTarget aShipTarget = new ShipController.ShipTarget(aShipID, aTargetIndex); for (int i = 0; i < m_gMan.m_spawnedShips.Count; i++) { if (m_gMan.m_spawnedShips[i].ContainsShipTarget(aShipTarget)) { shipTarget = m_gMan.m_spawnedShips[i].GetShipTarget(aShipTarget); ship = m_gMan.m_spawnedShips[i].gameObject; break; } } if (aShooter == BombersNetworkManager.m_localPlayer.m_playerID) { m_gMan.m_bombsHit++; BombersNetworkManager.m_localPlayer.m_score += GameObject.Find("BrainCloudStats").GetComponent<BrainCloudStats>().m_pointsForWeakpointDestruction; } Plane[] frustrum = GeometryUtility.CalculateFrustumPlanes(Camera.main); if (GeometryUtility.TestPlanesAABB(frustrum, ship.transform.GetChild(0).GetChild(0).GetChild(0).GetComponent<Collider>().bounds)) { BombersNetworkManager.m_localPlayer.ShakeCamera(GameObject.Find("BrainCloudStats").GetComponent<BrainCloudStats>().m_weakpointIntensity, GameObject.Find("BrainCloudStats").GetComponent<BrainCloudStats>().m_shakeTime); } if (shipTarget == null) return; GameObject explosion = (GameObject)Instantiate((GameObject)Resources.Load("WeakpointExplosion"), shipTarget.m_position.position, shipTarget.m_position.rotation); explosion.transform.parent = ship.transform; explosion.GetComponent<AudioSource>().Play(); foreach (Transform child in shipTarget.gameObject.transform) { Destroy(child.gameObject); } }
public void HitShipTargetPointCommand(int aID, int aIndex, string aJson) { BombController.BombInfo aBombInfo = BombController.BombInfo.GetBombInfo(aJson); if (BombersPlayerController.GetPlayer(aBombInfo.m_shooter).m_team == 1) { m_gMan.m_gameInfo.SetTeamScore(1, m_gMan.m_gameInfo.GetTeamScore(1) + GameObject.Find("BrainCloudStats").GetComponent<BrainCloudStats>().m_pointsForWeakpointDestruction); } else if (BombersPlayerController.GetPlayer(aBombInfo.m_shooter).m_team == 2) { m_gMan.m_gameInfo.SetTeamScore(2, m_gMan.m_gameInfo.GetTeamScore(2) + GameObject.Find("BrainCloudStats").GetComponent<BrainCloudStats>().m_pointsForWeakpointDestruction); } ShipController.ShipTarget shipTarget = null; GameObject ship = null; ShipController.ShipTarget aShipTarget = new ShipController.ShipTarget(aID, aIndex); for (int i = 0; i < m_gMan.m_spawnedShips.Count; i++) { if (m_gMan.m_spawnedShips[i].ContainsShipTarget(aShipTarget)) { shipTarget = m_gMan.m_spawnedShips[i].GetShipTarget(aShipTarget); ship = m_gMan.m_spawnedShips[i].gameObject; break; } } Plane[] frustrum = GeometryUtility.CalculateFrustumPlanes(Camera.main); if (GeometryUtility.TestPlanesAABB(frustrum, ship.transform.GetChild(0).GetChild(0).GetChild(0).GetComponent<Collider>().bounds)) { BombersNetworkManager.m_localPlayer.ShakeCamera(GameObject.Find("BrainCloudStats").GetComponent<BrainCloudStats>().m_weakpointIntensity, GameObject.Find("BrainCloudStats").GetComponent<BrainCloudStats>().m_shakeTime); } if (shipTarget != null) { GameObject explosion = (GameObject)Instantiate((GameObject)Resources.Load("WeakpointExplosion"), shipTarget.m_position.position, shipTarget.m_position.rotation); explosion.transform.parent = ship.transform; explosion.GetComponent<AudioSource>().Play(); foreach (Transform child in shipTarget.gameObject.transform) { Destroy(child.gameObject); } } RpcHitShipTargetPoint(aID, aIndex, aBombInfo.m_shooter); /*if (!isLocalPlayer || !hasAuthority) { return; } CmdHitShipTargetPoint(aID, aIndex, aJson);*/ }