예제 #1
0
파일: Ball.cs 프로젝트: pkunjam/Breakout-PC
    /// <summary>
    /// Use this for initialization
    /// </summary>
    void Start()
    {
        // start move timer
        moveTimer          = gameObject.AddComponent <Timer>();
        moveTimer.Duration = 1;
        moveTimer.AddTimerFinishedListener(HandleMoveTimerFinished);
        moveTimer.Run();

        // start death timer
        deathTimer          = gameObject.AddComponent <Timer>();
        deathTimer.Duration = ConfigurationUtils.BallLifeSeconds;
        deathTimer.AddTimerFinishedListener(HandleDeathTimerFinished);
        deathTimer.Run();

        // ball death support
        ballDied = new BallDied();
        EventManager.AddBallDiedInvoker(this);

        // lost ball support
        ballLost = new BallLost();
        EventManager.AddBallLostInvoker(this);

        // speedup effect support
        speedupTimer = gameObject.AddComponent <Timer>();
        speedupTimer.AddTimerFinishedListener(HandleSpeedupTimerFinished);
        EventManager.AddSpeedupEffectListener(HandleSpeedupEffectActivatedEvent);
        rb2d = GetComponent <Rigidbody2D>();
    }
예제 #2
0
    /// <summary>
    /// Use this for initialization
    /// </summary>
    public virtual void Start()
    {
        // set number of points and hits the ball is worth
        if (ballType == BallType.Standard)
        {
            points = ConfigurationUtils.StandardPoints;
            hits   = ConfigurationUtils.StandardHits;
        }
        else if (ballType == BallType.Bonus)
        {
            points = ConfigurationUtils.BonusPoints;
            hits   = ConfigurationUtils.BonusHits;
        }

        // start move timer
        moveTimer          = gameObject.AddComponent <Timer>();
        moveTimer.Duration = 1;
        moveTimer.Run();
        moveTimer.AddTimerFinishedListener(HandleMoveTimerFinished);

        // start death timer
        deathTimer          = gameObject.AddComponent <Timer>();
        deathTimer.Duration = ConfigurationUtils.BallLifeSeconds;
        deathTimer.Run();
        deathTimer.AddTimerFinishedListener(HandleDeathTimerFinished);

        // save for efficiency
        rb2d = GetComponent <Rigidbody2D>();

        // add as invoker of various events
        EventManager.AddBallLostInvoker(this);
        EventManager.AddBallDiedInvoker(this);
    }
예제 #3
0
	/// <summary>
	/// Use this for initialization
	/// </summary>
	void Start()
	{
        // start move timer
        moveTimer = gameObject.AddComponent<Timer>();
        moveTimer.AddTimerFinishedListener(HandleMoveTimerFInished);
        moveTimer.Duration = 1;
        moveTimer.Run();

        // start death timer
        deathTimer = gameObject.AddComponent<Timer>();
        deathTimer.AddTimerFinishedListener(HandleDeathTimerFinished);
        deathTimer.Duration = ConfigurationUtils.BallLifeSeconds;
        deathTimer.Run();


        // work with speed up timer
        speedUpTimer = gameObject.AddComponent<Timer>();
        speedUpTimer.AddTimerFinishedListener(HandleSpeedUpTimerFinished);
        EventManager.AddSpeedUpEffectListener(HandleSpeedUpEffectActivated);

        rigidbody2D = gameObject.GetComponent<Rigidbody2D>();


        ballDied = new BallDied();
        ballLost = new BallLost();
        EventManager.AddBallDiedInvoker(this);
        EventManager.AddBallLostInvoker(this);

    }
예제 #4
0
파일: Ball.cs 프로젝트: zixu6769/Wacky-Pong
    BallDeadEvent ballDeadEvent = new BallDeadEvent();          // Initialize dead ball event
    public virtual void Start()
    {
        // Connet rigidbody2d to the ball
        rb2D = GetComponent <Rigidbody2D>();
        // Sign score based on BallType
        if (currentBall == BallType.StandardBall)
        {
            hits   = ConfigurationUtils.StandardBallHit;
            points = ConfigurationUtils.StandardBallScore;
        }
        else if (currentBall == BallType.BonusBall)
        {
            hits   = ConfigurationUtils.BonusBallHit;
            points = ConfigurationUtils.BonusBallScore;
        }
        else
        {
            hits   = 0;
            points = 0;
        }
        // Create and start timers
        deathTimer          = gameObject.AddComponent <Timer>();
        deathTimer.Duration = ConfigurationUtils.BallLifetime;
        deathTimer.Run();
        deathTimer.AddTimerFinishedEventListener(RedrawBall);

        waitTimer          = gameObject.AddComponent <Timer>();
        waitTimer.Duration = ConfigurationUtils.BallWaittime;
        waitTimer.Run();
        waitTimer.AddTimerFinishedEventListener(StartMoving);

        speedupTimer = gameObject.AddComponent <Timer>();
        speedupTimer.AddTimerFinishedEventListener(SlowdownBalls);

        // Connect the invokers
        EventManager.AddScoreInvoker(this);
        EventManager.AddBallLostInvoker(this);
        EventManager.AddBallDeadInvoker(this);
        EventManager.AddSpeedupListener(SpeedupBalls);
    }
예제 #5
0
 private void Awake()
 {
     ballLostEvent = new BallLost();
     EventManager.AddBallLostInvoker(this);
     EventManager.AddGameEndedListener(OnGameEnded);
 }