private void Start() { BallSpawner spawner = FindObjectOfType <BallSpawner>(); spawner.BallSpawnedEvent += OnBallSpawned; OnBallSpawned(spawner.RemainingBallCount); }
// Start is called before the first frame update void Start() { updateBallsLeftEvent = new UpdateBallsLeftEvent(); ballDiesEvent = new BallDiesEvent(); rb2d = GetComponent <Rigidbody2D>(); ballSpawner = Camera.main.GetComponent <BallSpawner>(); ballDeathTimer = gameObject.AddComponent <Timer>(); ballDeathTimer.Duration = ConfigurationUtils.BallLifeTime; ballDeathTimer.Run(); addForceTimer = gameObject.AddComponent <Timer>(); addForceTimer.Duration = 1f; addForceTimer.Run(); speedUpTimer = gameObject.AddComponent <Timer>(); EventManager.AddSpeedUpListener(SpeedUpTheBall); EventManager.AddUpdateBallsLeftInvoker(this); EventManager.AddBallDiesInvoker(this); addForceTimer.AddTimerFinishedEventListener(AddForceToBall); addForceTimer.AddTimerFinishedEventListener(RestoreForceTimer); ballDeathTimer.AddTimerFinishedEventListener(KillTheBallAndSpawn); speedUpTimer.AddTimerFinishedEventListener(SpeedModeIsFinished); }
private void Start() { this.ballspawner = Camera.main.GetComponent <BallSpawner>(); this.GetComponent <Rigidbody2D>().AddForce(new Vector2(0, -5f), ForceMode2D.Impulse); this.InitializeDeathTimer(); }
private void InitBallController() { BallSpawner ballSpawnerComponent = GetComponent <BallSpawner>(); ballController = new BallController(ballSpawnerComponent); ballController.OnBallSpawned += OnBallSpawned; }
void ApplyEffect() { BallSpawner ballSpawner = GameObject.FindGameObjectWithTag("GameController").GetComponent <BallSpawner>(); Vector3 force = new Vector3(Mathf.Abs(Random.Range(-100, 100)) + 1, Mathf.Abs(Random.Range(-100, 100)) + 1, Mathf.Abs(Random.Range(-200, 200)) + 1); ballSpawner.SpawnBall(force); }
// Use this for initialization /*void Start () { * * }*/ public void Init(BallSpawner bS, float maxHeight) { lvMgr = LevelManager.instance; bSpawn = bS; cam = Camera.main; _maxH = maxHeight; }
void SpawnBall() { GameObject ball = balls; ball.GetComponent <AudioSource>().clip = Resources.Load <AudioClip>("wallHit"); ball.GetComponent <AudioSource>().playOnAwake = false; Vector3 spawnPosition; if (player1turn) { spawnPosition = new Vector3(0.0f, 50.0f, 0.0f); } else { spawnPosition = new Vector3(0.0f, 50.0f, -8000.0f); } Quaternion spawnRotation = Quaternion.identity; if (isOnlineMode && isHost) { ballSpawner = GameObject.FindObjectOfType <BallSpawner>(); ballSpawner.SpawnBall(); ballCount += 2; } else if (isOnlineMode && !isHost) { } else { Instantiate(ball, spawnPosition, spawnRotation); ballCount += 1; } }
/// <summary> /// Skill Name: Majakuma Wish /// Effect: Erase All current stage shots in play, heal all chars 10 hp for each stage shot removed. /// /// *Note: /// </summary> /// <param name="isCastWhenAdjustTime"></param> private void SkillCasting_MajakumaWish(bool isCastWhenAdjustTime) { if (!isCastWhenAdjustTime) { GameObject[] stageShots = GameObject.FindGameObjectsWithTag("Stage Shot"); int numOfShots = 0; if (stageShots[0] != null) { BallSpawner ballSpawner = stageShots[0].GetComponent <ProjectileBall>().GetStageBallSpawner(); ballSpawner.ResetBallByEffect(); numOfShots = stageShots.Length; } for (int i = 0; i < stageShots.Length; i++) { stageShots[i].GetComponent <ProjectileBall>().RemoveFromPlay(); } Prisoner[] AllChar = GetComponent <Prisoner>().GetPrisonerArray(); if (numOfShots <= 0) { numOfShots = 1; } for (int i = 0; i < AllChar.Length; i++) { int healAmount = numOfShots * shotPower / 7; AllChar[i].GetComponent <Health>().AddHealth(numOfShots * shotPower / 7); print(" healAmount " + healAmount); } } }
public void StartGame() { BallSpawner.SetActive(true); InputManager.SetActive(true); startScreen.SetActive(false); layout.SetActive(true); }
private void Pause() { //player movement playerMovement = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerMovement>(); //enemy movement try { enemyMovement = GameObject.FindGameObjectWithTag("Enemy").GetComponent <EnemyMovement>(); foundEnemy = true; } catch { Debug.Log("Unable to find enemyroomba"); foundEnemy = false; } //ballspawner ballSpawner = GameObject.Find("Floor").GetComponent <BallSpawner>(); //disable those components playerMovement.canMove = false; if (foundEnemy) { enemyMovement.canMove = false; } ballSpawner.canSpawnBalls = false; //show the pause screen pauseScreen.SetActive(true); hasPaused = true; }
private void Start() { this.ballspawner = Camera.main.GetComponent <BallSpawner>(); this.MoveDirection(1); this.InitializeKingAudioTimer(); }
public static void AddRemainInvoker(BallSpawner script) { remainInvoker = script; if (remainListener != null) { remainInvoker.BallRemainingEventListener(remainListener); } }
public void Lose() { BallSpawner.SetActive(false); InputManager.SetActive(false); loseScoreText.text = scoreText.text; layout.SetActive(false); loseScreen.SetActive(true); }
public BallController(BallSpawner ballSpawner) { this.ballSpawner = ballSpawner; ballSpawner.OnBallSpawnDone += OnBallSpawnDone; paddles = new Dictionary <Collision2D, BasePaddle>(); regularCollisions = new List <Collision2D>(); }
public override void _Ready() { singleton = this; amountOfBalls = 1; spawnPosition = GetNode(spawnPositionPath); InterfaceController.singleton.Update(); GameManager.singleton.SetBallRecord(amountOfBalls); }
private void OnTriggerEnter(Collider other) { if (other.tag == "Ball") { other.GetComponent <Ball>().status = Ball.Status.Destroyed; BallSpawner.DestroyBall(); } }
/// <summary> /// Create a new ball /// </summary> private void CreateNewBall(Vector3 newPosition) { BallSpawner ballSpawner = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <BallSpawner>(); GameObject newBall = ballSpawner.SpawnBall(newPosition); newBall.transform.position = newPosition; Debug.Log(ballSpawner.gameObject.name); }
public static void AddReduceBallsEventInvoker(BallSpawner invoker) { reduceBallsEventInvokers.Add(invoker); foreach (UnityAction reduceBallsListener in reduceBallsEventListeners) { invoker.AddReduceBallsEventListener(reduceBallsListener); } }
public static void AddBallDecrementInvoker(BallSpawner fzb) { Ballinvoker = fzb; if (Balllistener != null) { Ballinvoker.AddBallDecrementListener(Balllistener); } }
private void Start() { ballSpawner = Camera.main.GetComponent <BallSpawner>(); lifeTimeTimer = gameObject.AddComponent <Timer>(); rb = GetComponent <Rigidbody2D>(); StartCoroutine(StartMoving()); }
private void InitializeBallSpawner(GameObject ballPrefab, float ballScale) { _ballSpawnerGo = new GameObject(); _ballSpawnerGo.name = "BallSpawner"; _ballSpawnerGo.transform.parent = transform; _ballSpawner = _ballSpawnerGo.AddComponent <BallSpawner>(); _ballSpawner.Initialize(ballPrefab, ballScale); }
public static void AddReduceBallsLEftInvoker(BallSpawner invoker) { // add invoker to list and add all listeners to invoker reduceBallsLeftInvokers.Add(invoker); foreach (UnityAction listener in reduceBallsLeftListeners) { invoker.AddReduceBallsLeftListener(listener); } }
// Use this for initialization void Start() { spawner = GameObject.Find("BallSpawner"); bs = spawner.GetComponent <BallSpawner>(); rb = gameObject.GetComponent <Rigidbody>(); lifeTime = bs.lifeTime; rb.AddForce(spawner.transform.forward, ForceMode.Impulse); rend = GetComponent <Renderer>(); }
void Start() { rigidbody2d = GetComponent <Rigidbody2D>(); spriteRenderer = GetComponent <SpriteRenderer>(); GameObject gameController = GameObject.Find("GameController"); ballSpawner = gameController.GetComponent <BallSpawner>(); currentHealth = maxHealth; }
// Update is called once per frame void Update() { // transform.Translate(dir * speed * Time.deltaTime, Space.World); if (transform.localPosition.y < -2) { BallSpawner.DecreaseNumbBall(); // Debug.Log("ball " + ballNumb + " died"); Destroy(gameObject); return; } }
private void Awake() { if (bs == null) { bs = this; } else if (bs != this) { Destroy(gameObject); } }
//[SerializeField] //bool ballsFinished = false; #endregion #region Methods // Start is called before the first frame update void Start() { //place the ball at 1/3 of the screen (remember that 0 is in the middle) transform.position = new Vector3(0, -(ScreenUtils.ScreenTop / 3), 0); //get the RigidBody2D component rb2d = GetComponent <Rigidbody2D>(); //get the Collider radius colliderRadius = gameObject.GetComponent <CircleCollider2D>().radius; //get the Ball Spawner Script ballSpawner = GameObject.FindWithTag("MainCamera").GetComponent <BallSpawner>(); //get the HUD Script hud = GameObject.FindWithTag("HUD").GetComponent <HUD>(); //start the Get-ready timer getReadyTimer = gameObject.AddComponent <Timer>(); getReadyTimer.Duration = ConfigurationUtils.BallGetReadyTimerDuration; getReadyTimer.Run(); //add the StartMoving method as a listener for the getReadyTimer's TimerFinished Event getReadyTimer.AddTimerFinishedEventListener(StartMoving); //start the self-distruction timer deathTimer = gameObject.AddComponent <Timer>(); deathTimer.Duration = ConfigurationUtils.BallDeathTimerDuration; deathTimer.Run(); //add the DestroyBall method as a listener for the deathTimer's TimerFinished Event deathTimer.AddTimerFinishedEventListener(DestroyBall); //add this ball as invoker for the freezer event events.Add(EventName.FreezerEvent, new FreezerEvent()); EventManager.AddEventInvoker(EventName.FreezerEvent, this); //add this ball as an invoker for the speedup event events.Add(EventName.SpeedupEvent, new SpeedupEvent()); EventManager.AddEventInvoker(EventName.SpeedupEvent, this); //add this ball as an invoker for the SpawnBall Event events.Add(EventName.SpawnBallEvent, new SpawnBallEvent()); EventManager.AddEventInvoker(EventName.SpawnBallEvent, this); //add this ball as an invoker for the HUD's AddPoints event events.Add(EventName.AddPointsEvent, new AddPointsEvent()); EventManager.AddEventInvoker(EventName.AddPointsEvent, this); ////add the BallsFinished method as a listener for the BallsFinished Event //EventManager.AddEventListener(EventName.BallsFinishedEvent, BallsFinished); //add this ball as an invoker for the GameOver Event events.Add(EventName.GameOverEvent, new GameOverEvent()); EventManager.AddEventInvoker(EventName.GameOverEvent, this); }
private void InitialiseGame() { gameEndTime = Time.time + gameDuration; GearSystem = GearSystemObject.GetComponent <GearSystemsAPI>(); InitialisePlayers(); PrefabManager.InitialiseBlockSprites(); SpriteManager.InitialiseSprites(); SoundManager.InitialiseAudio(); ballSpawner = Instantiate(PrefabManager.InitialiseBallSpawner()).GetComponent <BallSpawner>(); UnpauseGame(); }
private void Awake() { if (instance == null) { instance = this; } else { Destroy(this); } }
private void Start() { //initialze variables playerRb = GetComponent <Rigidbody>(); bs = GameObject.Find("Floor").GetComponent <BallSpawner>(); ballCollection = GetComponent <BallCollection>(); audioClips = GetComponent <AudioClips>(); audioSource = GetComponent <AudioSource>(); scene = SceneManager.GetActiveScene(); jumpForce = 10; }
void Start() { state = GameState.PLAYING; inputManager = gameObject.AddComponent<InputManager>(); spawner = gameObject.AddComponent<PlayerSpawner>(); player = spawner.Spawn(); cameraManager = new CameraManager(); inkBucket = new InkBucket(); lineCreator = LineCreator.Create(inkBucket); ballSpawner = new BallSpawner(); ballSpawner.Initialize(); CreateBackground(); }
void Start() { _rightFlipper = _righty.GetComponent<Flipper>(); _leftFlipper = _lefty.GetComponent<Flipper>(); _spawner = _ballSpawner.GetComponent<BallSpawner> (); }