예제 #1
0
    // Use this for initialization
    void Start()
    {
        // set the min/max spawn times for random balls
        minBallSpawnTime = ConfigurationUtils.MinRandomSpawnTime;
        maxBallSpawnTime = ConfigurationUtils.MaxRandomSpawnTime;

        // get the boundaries of the spawn location
        Ball          tempBall = Instantiate <Ball>(prefabBall);
        BoxCollider2D collider = tempBall.GetComponent <BoxCollider2D>();
        float         ballColliderHalfWidth  = collider.size.x / 2;
        float         ballColliderHalfHeight = collider.size.y / 2;

        spawnLocationMin = new Vector2(
            tempBall.transform.position.x - ballColliderHalfWidth,
            tempBall.transform.position.y - ballColliderHalfHeight);
        spawnLocationMax = new Vector2(
            tempBall.transform.position.x + ballColliderHalfWidth,
            tempBall.transform.position.y + ballColliderHalfHeight);
        Destroy(tempBall.gameObject);

        // create a time to spawn a ball at random intervals
        timerRandomBallSpawn = gameObject.AddComponent <Timer>();

        retrySpawn = true;

        // Add listeners for events
        IntEventManager.AddListener(EventName.SubtractBallsEvent, SpawnBalls);
        IntEventManager.AddListener(EventName.BallsDiedEvent, SpawnBalls);
        IntEventManager.AddListener(EventName.GameOverEvent, GameOver);
    }
예제 #2
0
파일: Ball.cs 프로젝트: oclipa/Breakout
 private void disableEvents()
 {
     this.RemoveAllListeners(EventName.BallsDiedEvent);
     this.RemoveAllListeners(EventName.SubtractBallsEvent);
     IntEventManager.RemoveInvoker(EventName.BallsDiedEvent, this);
     IntEventManager.RemoveInvoker(EventName.SubtractBallsEvent, this);
 }
예제 #3
0
파일: Block.cs 프로젝트: oclipa/Breakout
 // Use this for initialization
 virtual protected void Start()
 {
     // add self as event invoker
     intUnityEvents.Add(EventName.PointsAdded, new PointsAddedEvent());
     IntEventManager.AddInvoker(EventName.PointsAdded, this);
     intUnityEvents.Add(EventName.BlockDestroyed, new BlockDestroyedEvent());
     IntEventManager.AddInvoker(EventName.BlockDestroyed, this);
 }
예제 #4
0
    // Use this for initialization
    void Start()
    {
        scoreText          = GameObject.FindGameObjectWithTag("ScoreText").GetComponent <Text>();
        ballsLeftText      = GameObject.FindGameObjectWithTag("BallsLeftText").GetComponent <Text>();
        ballsLeft          = ConfigurationUtils.BallsPerGame;
        ballsLeftText.text = "Balls Left: " + ballsLeft.ToString();

        blockCount = LevelBuilder.BlockCount; // cheap 'n nasty; could also get this by finding tagged block count

        IntEventManager.AddListener(EventName.PointsAdded, AddPoints);
        IntEventManager.AddListener(EventName.SubtractBallsEvent, SubtractBalls);
        IntEventManager.AddListener(EventName.BlockDestroyed, SubtractBlocks);

        intUnityEvents.Add(EventName.GameOverEvent, new GameOverEvent());
        IntEventManager.AddInvoker(EventName.GameOverEvent, this);
    }
예제 #5
0
파일: Ball.cs 프로젝트: oclipa/Breakout
    // Use this for initialization
    void Start()
    {
        rb = GetComponent <Rigidbody2D>();

        timerBallLifeTime          = gameObject.AddComponent <Timer>();
        timerBallLifeTime.Duration = ConfigurationUtils.BallLifeTime;
        timerBallLifeTime.Run();

        timerBallStart          = gameObject.AddComponent <Timer>();
        timerBallStart.Duration = 1;
        timerBallStart.Run();

        intUnityEvents.Add(EventName.SubtractBallsEvent, new SubtractBallsEvent());
        IntEventManager.AddInvoker(EventName.SubtractBallsEvent, this);
        intUnityEvents.Add(EventName.BallsDiedEvent, new BallsDiedEvent());
        IntEventManager.AddInvoker(EventName.BallsDiedEvent, this);
    }
예제 #6
0
 // Use this for initialization
 void Start()
 {
     IntEventManager.AddListener(EventName.GameOverEvent, GameOver);
 }
예제 #7
0
파일: Block.cs 프로젝트: oclipa/Breakout
 private void OnBecameInvisible()
 {
     intUnityEvents[EventName.BlockDestroyed].Invoke(1);
     IntEventManager.RemoveInvoker(EventName.PointsAdded, this);
 }
예제 #8
0
파일: MainMenu.cs 프로젝트: oclipa/Breakout
 public void HandlePlayButtonOnClickEvent()
 {
     AudioManager.Play(AudioClipName.Click);
     IntEventManager.Initialize();
     SceneManager.LoadScene("Gameplay");
 }