void Start() { ofb = gameObject.AddComponent <OutOfBounds>(); spriteRenderer = GetComponent <SpriteRenderer>(); timeLeftForNextBlink = blinkRate; speed = (type == FriendlyType.Permanent) ? 0 : speed; GetComponent <Rigidbody2D>().velocity = new Vector2(speed, 0); reloadTimeRemaining = reloadTime; }
void OnTriggerEnter(Collider col) { //Enter OutOfBounds Directly OutOfBounds oob = col.gameObject.GetComponent <OutOfBounds>(); if (oob) { ballState = BallState.OutOfBounds; } }
void Start() { reloadTimeRemaining = reloadTime; timeLeft = timeToLive; ofb = gameObject.AddComponent <OutOfBounds>(); if (hasSpline) { GetComponent <Rigidbody2D>().velocity = new Vector2(0, 0); } }
public virtual void RaiseOutOfBounds(Vector3 pos) { // Make a temporary copy of the event to avoid possibility of // a race condition if the last subscriber unsubscribes // immediately after the null check and before the event is raised. OutOfBounds handler = OnOutOfBounds; if (handler != null) { handler(pos); } }
void Update() { if (outOfBounds == null) { gameController = GameControllerScript.GetInstance(); outOfBounds = gameController.GetComponent <OutOfBounds>(); } if (outOfBounds.IsOutOfBounds(gameObject.transform)) { gameObject.SetActive(false); } }
void OnTriggerEnter2D(Collider2D hitObject) { Enemy obj = hitObject.GetComponent <Enemy>(); if (obj != null) { this.takeDamage(obj.damageWhenHit); } LevelCheckpoint checkpoint = hitObject.GetComponent <LevelCheckpoint>(); if (checkpoint != null) { string nextSceneName = "scene1"; // Change this to the according level/name checkpoint.nextLevel(nextSceneName); } OutOfBounds bound = hitObject.GetComponent <OutOfBounds>(); if (bound != null) { this.Die(); } }
private void CreateBoundaries() { increment = 2; Boundaries.Clear(); for (int i = 0; i < outsideTrack.Lines.Count - increment; i += increment) { Boundaries.Add(new Boundary(outsideTrack.Lines[i].Origin.X, outsideTrack.Lines[i].Origin.Y, outsideTrack.Lines[i + increment].EndPoint.X, outsideTrack.Lines[i + increment].EndPoint.Y)); } for (int i = 0; i < insideTrack.Lines.Count - increment; i += increment) { Boundaries.Add(new Boundary(insideTrack.Lines[i].Origin.X, insideTrack.Lines[i].Origin.Y, insideTrack.Lines[i + increment].EndPoint.X, insideTrack.Lines[i + increment].EndPoint.Y)); } OutOfBounds.Clear(); for (int i = 0; i < outSideOutOfBounds.Lines.Count - increment; i += increment) { OutOfBounds.Add(new Boundary(outSideOutOfBounds.Lines[i].Origin.X, outSideOutOfBounds.Lines[i].Origin.Y, outSideOutOfBounds.Lines[i + increment].EndPoint.X, outSideOutOfBounds.Lines[i + increment].EndPoint.Y)); } for (int i = 0; i < insideOutOfBounds.Lines.Count - increment; i += increment) { OutOfBounds.Add(new Boundary(insideOutOfBounds.Lines[i].Origin.X, insideOutOfBounds.Lines[i].Origin.Y, insideOutOfBounds.Lines[i + increment].EndPoint.X, insideOutOfBounds.Lines[i + increment].EndPoint.Y)); } }
void DetectBounds() { if (ballState == BallState.Rolling) { Color rayColor; Ray boundsRay = new Ray(transform.position, Vector3.down); RaycastHit boundsHit; if (Physics.Raycast(boundsRay, out boundsHit)) { OutOfBounds oob = boundsHit.collider.gameObject.GetComponent <OutOfBounds>(); if (oob) { rayColor = Color.red; timeSinceOutOfBounds += Time.deltaTime; } else { rayColor = Color.green; timeSinceOutOfBounds = 0; } if (debugBall.ShowBoundsNormalRay) { Debug.DrawRay(transform.position, boundsHit.normal, rayColor); } } if (timeSinceOutOfBounds > MaxOutOfBoundsTime) { ballState = BallState.OutOfBounds; } } }
void Awake() { SpawnManager = FindObjectOfType <OutOfBounds>(); checkpointNoise = hologram.GetComponent <AudioSource>(); }
void Start() { gameController = GameControllerScript.GetInstance(); outOfBounds = gameController.GetComponent <OutOfBounds>(); }
public void IsOutOfBounds() { OutOfBounds.Invoke(); GameManager.instance.PitFall(1); }
// Update is called once per frame void Update() { if (!IsPlaying) { return; } if (Spin) { Camera.main.transform.RotateAround(Vector3.zero, Vector3.up, 20.0f * Time.deltaTime); } //Input (Could be put in their own update functions as well) foreach (var player in Players) { player.HandleInput(); } Ball.MovementUpdate(GlobalSpeedMultiplier); //Movement (Could be put in their own update functions as well) //Do AI calculations after ball has moved foreach (var player in Players) { player.MovementUpdate(GlobalSpeedMultiplier); } //Collisions //Don't go off screen foreach (var player in Players) { player.CheckMapEdgeCollision(Map); } Vector2 hit = new Vector2(); //Check direction if (Ball.GetDirection().x < 0) { //Check player 1 collision //Debug.Log("p1 check"); Ball.CheckPlayerCollison(Players[0], ref hit); } else { //Check player 2 collision //Debug.Log("p2 check"); Ball.CheckPlayerCollison(Players[1], ref hit); } //Don't go off screen Ball.CheckMapEdgeCollision(Map); OutOfBounds ballOutOfBounds = Map.CheckOutOfBounds(Ball.Bounds); if (ballOutOfBounds == OutOfBounds.Left) { //Player 2 wins Debug.Log("Player 2 wins"); EndGame("Player 2 Wins"); } else if (ballOutOfBounds == OutOfBounds.Right) { //Player 1 wins Debug.Log("Player 1 wins"); EndGame("Player 1 Wins"); } }
void Start() { ofb = gameObject.AddComponent <OutOfBounds>(); timeLeft = timeToLive; }
void Start() { outOfBounds = gameController.GetComponent <OutOfBounds>(); }