void Awake() { ballDropper = FindObjectOfType <BallDropper>(); song = FindObjectOfType <SongController>(); ballDropper.onBallSpawned += AttachBallListener; }
/*+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= * INITIALIZE *+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=*/ public override void Initialize(Game game, BallData data, BallDropper dropper) { base.Initialize(game, data, dropper); // downcast data to specific type BounceBallData bounceData = (data as BounceBallData); // COMPONENTS rb = GetComponent <Rigidbody>(); animator = GetComponent <Animator>(); // ATTRIBUTES radius = GetComponent <SphereCollider>().bounds.size.y / 2; InitializeRings(); // MOVEMENT fallAxisBounds = dropper.fallAxisBounds; speed = dropper.startSpeed; gravity = dropper.gravity; velocity = speed * axisVector * negative; baseHeight = dropper.bounceHeightBase; // OPTIONS bounceHeight = bounceData.GetOption("Bounce Height"); }
void Awake() { sc = FindObjectOfType <SongController>(); bd = FindObjectOfType <BallDropper>(); input = new InputMaster(); input.NoteListener.MousePos.performed += mov => mousePos = mov.ReadValue <Vector2>(); }
//_____ STATE ______________________ //_____ OTHER _______________________ /*+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= * INITIALIZE *+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=*/ void OnEnable() { game = FindObjectOfType <Game>(); game.onGameRestart += ResetScore; game.onGameEnd += SetFinalScore; ballDropper = GameObject.Find("BallDropper").GetComponent <BallDropper>(); songController = GameObject.Find("SongController").GetComponent <SongController>(); ballDropper.onBallSpawned += AddBallListener; UpdateScoreText(); }
/*+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= * INITIALIZE *+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=*/ public override void Initialize(Game game, BallData data, BallDropper dropper) { base.Initialize(game, data, dropper); // MOTION fallAxisBounds = dropper.fallAxisBounds; speed = dropper.startSpeed; gravity = dropper.gravity; velocity = speed * axisVector * negative; // COMPONENTS rb = GetComponent <Rigidbody>(); animator = GetComponent <Animator>(); }
// Use this for initialization void Start() { cam = gameObject.GetComponentInChildren <Camera> ().camera; player = mainGame.GetComponent <Player>(); playerTimerText = (Transform)Instantiate(TimerTextPrefab); playerTimerText.SetParent(GameObject.FindObjectOfType <Canvas>().transform, false); introText = (Transform)Instantiate(IntroTextPrefab); introText.SetParent(GameObject.FindObjectOfType <Canvas>().transform, false); minigameType = gameObject.GetComponentInChildren <MiniGameMovement>().minigameType; if (player.playerName == "Player1") { playerTimerText.gameObject.GetComponent <RectTransform> ().anchorMin = new Vector2(0.25f, 1f); playerTimerText.gameObject.GetComponent <RectTransform> ().anchorMax = new Vector2(0.25f, 1f); introText.gameObject.GetComponent <RectTransform> ().anchorMin = new Vector2(0.25f, 0.5f); introText.gameObject.GetComponent <RectTransform> ().anchorMax = new Vector2(0.25f, 0.5f); } else { playerTimerText.gameObject.GetComponent <RectTransform> ().anchorMin = new Vector2(0.75f, 1f); playerTimerText.gameObject.GetComponent <RectTransform> ().anchorMax = new Vector2(0.75f, 1f); introText.gameObject.GetComponent <RectTransform> ().anchorMin = new Vector2(0.75f, 0.5f); introText.gameObject.GetComponent <RectTransform> ().anchorMax = new Vector2(0.75f, 0.5f); Color camcolor = new Color(0f / 255f, 220f / 255f, 251f / 255f, 5f / 255f); cam.backgroundColor = camcolor; } if (minigameType == 1) { ballDropper = this.GetComponentInChildren <BallDropper>(); } if (minigameType == 2) { spawner = this.GetComponentInChildren <Spawner>(); } StartCoroutine(DisplayIntroText()); }
/** * Called when the Game starts */ public bool Initialize(SongData song) { ResetGameTime(); //OHCamera ohCam = FindObjectOfType<OHCamera>(); inputMaster = FindObjectOfType <InputHandler>().inputMaster; uIManager = FindObjectOfType <UIManager>(); songController = FindObjectOfType <SongController>(); paddleManager = FindObjectOfType <PaddleManager>(); track = FindObjectOfType <Track>(); ballDropper = FindObjectOfType <BallDropper>(); // ENVIRONMENT track.Initialize(this); //ohCam.Initialize(); // LOAD SONG this.songData = song; songController.Initialize(this, inputMaster); songController.LoadSong(song); songController.onSongEnd += EndGame; // PADDLES paddleManager.Initialize(this, track); // BALLS balls = LoadBallData(song.name); SortBalls(); // BALL DROPPER ballDropper.Initialize(this, songController, track); ballDropper.ballMapName = song.songName; waitTimeBeats = ballDropper.GetTimeToFallBeats(); // UI uIManager.Initialize(); replayButton = FindObjectOfType <ReplayButton>(); replayButton.onReplayButtonClicked += RestartGame; StartGame(); return(true); }
/*+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= * INITIALIZE *+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=*/ public virtual void Initialize(Game game, BallData data, BallDropper dropper) { // REFERENCES this.ballData = data; this.dropper = dropper; this.song = game.songController; // COMPONENTS ball_collider = GetComponent <SphereCollider>(); ball_render = transform.Find("Render").gameObject; // DATA this.type = data.type; this.options = data.options; // APPEARANCE this.id = dropper.currentBallIndex; this.name = id.ToString() + "_" + type.ToString(); gameObject.layer = LayerMask.NameToLayer("Balls"); size = dropper.GetSize(); SetSize(); // NOTES this.notes = data.notes; currentNote = 0; numNotes = notes.Count; catchTimesBeats = new float[numNotes + 1]; // POSITION SetAxisVectors(); transform.position = GetNotePosition(currentNote); // START IN IDLE STATE SetState(new IdleState(this)); // TRIGGER SPAWN EVENT if (onBallSpawn != null) { onBallSpawn(this); } }