// Use this for initialization void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } }
public override void OnInspectorGUI() { DrawDefaultInspector(); BallShooter shootTarget = (BallShooter)target; if (GUILayout.Button("shoot")) { BallShooter shooter; shootTarget.Shoot(); } }
void Start() { shooter = GetComponentInChildren <BallShooter>(); steering = 0.0f; motor = 0.0f; previousHit = false; currentHit = false; locked = false; timeOfLockLost = Time.fixedTime; timeOfLockAcquired = Time.fixedTime; events = new bool[4]; state = State.MovingForward; MoveForward(); }
private void InitializeBallShooter(BallSpawner ballSpawner) { int widthIndex = MAX_GRID_WIDTH / 2; Vector3 currentBallPosition = _ballSpawner.GeneratePosition(widthIndex, MAX_GRID_HEIGHT) + new Vector3(-_ballSpawner.GetBallRadius() / 2, 0, 0); Vector3 nextBallPosition = _ballSpawner.GeneratePosition(widthIndex - 2, MAX_GRID_HEIGHT + 1); _ballShooterGo = new GameObject(); _ballShooterGo.name = "BallShooter"; _ballShooterGo.transform.parent = transform; _ballShooter = _ballShooterGo.AddComponent <BallShooter>(); _ballShooter.Initialize(ballSpawner, currentBallPosition, nextBallPosition); }
void OnTriggerStay(Collider collider) { // Used to grip the gat for the first time. Subsequent grip presses will restart the game if the game is over. if (collider.name == "Gat") { if (device.GetPressDown(SteamVR_Controller.ButtonMask.Grip)) { if (notHoldingSomething()) { gunAttached = true; RumbleController(0.03f, 700f); collider.gameObject.transform.SetParent(gameObject.transform); collider.gameObject.transform.localPosition = localGatPosition; collider.gameObject.transform.localEulerAngles = localGatEulerRotation; collider.attachedRigidbody.isKinematic = true; ballShooter = GetComponentInChildren <BallShooter>(); } if (mgc.gamePhase == 2) { mgc.ResetMiniGame(); } } } else if (collider.name == "PodCollider") { //RumbleController(0.03f, 700f); if (device.GetPressDown(SteamVR_Controller.ButtonMask.Grip)) { if (notHoldingSomething()) { podAttached = true; RumbleController(0.03f, 700f); GameObject pod = Instantiate(Pod); pod.transform.SetParent(gameObject.transform); pod.transform.localPosition = localPodPosition; pod.transform.localEulerAngles = localPodEulerRotation; pod.GetComponent <Rigidbody>().isKinematic = true; podController = GetComponentInChildren <PodController>(); } } } }
void Awake() { coroutineRunning = false; ballShooter = GetComponentInChildren <BallShooter> (); nav = GetComponent <UnityEngine.AI.NavMeshAgent> (); //col = GetComponent<SphereCollider> (); anim = GetComponent <Animator>(); globalLastPlayerSighting = GameObject.FindWithTag("GameController").GetComponent <GlobalLastPlayerSighting>(); playerHead = GameObject.FindWithTag("MainCamera"); // TODO might need to make more robust when doing multiplayer //playerAnim = player.GetComponent<Animator> (); //playerHealth = player.GetComponent <PlayerHealth> (); hash = GameObject.FindWithTag("GameController").GetComponent <HashIDs> (); //personalLastSighting = globalLastPlayerSighting.resetPosition; // reset the position so they don't start the game chasing the player //previousSighting = globalLastPlayerSighting.resetPosition; }
void Update() { int recHostId; int recConnectionId; int recChannelId; byte[] recBuffer = new byte[1024]; int bufferSize = 1024; int dataSize; byte error; NetworkEventType recNetworkEvent = NetworkTransport.Receive(out recHostId, out recConnectionId, out recChannelId, recBuffer, bufferSize, out dataSize, out error); switch (recNetworkEvent) { case NetworkEventType.Nothing: break; case NetworkEventType.ConnectEvent: Debug.Log("remote client connected"); connectionId = recConnectionId; remotePlayer = Instantiate <PlayerController>(playerPrefab); remoteShooter = remotePlayer.GetComponent <BallShooter>(); break; case NetworkEventType.DataEvent: ParseData(recBuffer); break; case NetworkEventType.DisconnectEvent: Debug.Log("remote client disconnected"); connectionId = -1; Destroy(remotePlayer.gameObject); remotePlayer = null; remoteShooter = null; break; } }
// Use this for initialization void Start() { shooter = BallShooter.instance; }
public void Start() { ballShooter = GameObject.Find("BallShooter").GetComponent <BallShooter>(); }
// Use this for initialization void Start() { ballShooter = ball.GetComponent <BallShooter>(); StartCoroutine(LaunchCoroutine()); }
void Start() { ballShooter = GameObject.Find("BallShooter").GetComponent <BallShooter>(); //ballShooter.fireSingleBall(); }
private void Start() { actionBar = PlayerUI.Instance.GetActionBar(); ballShooter = GetComponentInChildren <BallShooter>(); earthquakeSpawner = GetComponentInChildren <EarthquakeSpawner>(); }