Пример #1
0
 // Start is called before the first frame update
 virtual protected void Start()
 {
     lastBlockDestroyed = new LastBlockDestroyedEvent();
     pointsAddedEvent   = new PointsAddedEvent();
     EventManager.AddPointsAddedEventInvoker(this);
     EventManager.AddLastBlockDestroyedInvoker(this);
 }
Пример #2
0
 protected virtual void Start()
 {
     //hud = GameObject.FindGameObjectWithTag ("HUD").GetComponent<HUD>();
     pointAddedEvent     = new PointsAddedEvent();
     blockDestroyedEvent = new BlockDestroyEvent();
     EventManager.AddPointsInvoker(this);
     EventManager.BlockDestroyedInvoker(this);
 }
Пример #3
0
    /// <summary>
    /// Start is called on the frame when a script is enabled just before
    /// any of the Update methods is called the first time.
    /// </summary>
    virtual protected void Start()
    {
        pointsAddedEvent = new PointsAddedEvent();
        EventManager.AddInvokerPoints(this);

        blockDestroyedEvent = new BlockDestroyedEvent();
        EventManager.AddInvokerBlocDestroyed(this);
    }
Пример #4
0
    virtual protected void Start()
    {
        //add points event handling
        pointsAddedEvent = new PointsAddedEvent();

        //register as invoker to add points event
        EventManager.AddPointsInvoker(this);

        //add reduce blocks left event
        reduceBlocksLeftEvent = new ReduceBlocksLeftEvent();
        EventManager.AddReduceBlockInvoker(this);
    }
Пример #5
0
 private static void _onPointsAdded() => PointsAddedEvent?.Invoke(null, Points);
Пример #6
0
    /// <summary>
    /// Use this for initialization
    /// </summary>
    public virtual void Start()
    {
        speedUpActive = false;

        // gets Rigidbody2D Componenet
        rb2d = GetComponent <Rigidbody2D>();

        // Ball Collider Support
        ballCollider  = gameObject.GetComponent <BoxCollider2D>();
        ballHalfWidth = ballCollider.size.x / 2;

        // Initializes Events
        pointsAddedEvent = new PointsAddedEvent();
        ballLostEvent    = new BallLostEvent();
        ballDiedEvent    = new BallDiedEvent();

        // Adds appropriate invokers to the ball
        EventManager.AddPointsAddedInvoker(this);
        EventManager.BallLostInvoker(this);
        EventManager.BallDiedInvoker(this);
        EventManager.SpeedUpEffectListener(SpeedUpActive);

        // Angle selection support
        float angleSelect = Random.value;

        // Death Timer (with invoker)
        deathTimer = gameObject.AddComponent <Timer>();
        deathTimer.AddTimerFinishedListener(BallDeathTimer);
        deathTimer.Duration = ConfigurationUtils.BallLifetime;
        deathTimer.Run();

        // Start Timer (with invoker)
        startTimer = gameObject.AddComponent <Timer>();
        startTimer.AddTimerFinishedListener(BallStartTimer);
        startTimer.Duration = 1;
        startTimer.Run();

        speedUpTimer = gameObject.AddComponent <Timer>();
        speedUpTimer.AddTimerFinishedListener(SpeedUpDisabled);

        // Gets ball spawner component
        ballSpawner = Camera.main.GetComponent <BallSpawner>();

        // Sets min and max angle off of Random.Range
        if (angleSelect < 0.5f)
        {
            // sets left side angle to radians
            minAngle = 135 * Mathf.Deg2Rad;
            maxAngle = 225 * Mathf.Deg2Rad;
        }
        else
        {
            // sets right side angle to radians
            minAngle = -45f * Mathf.Deg2Rad;
            maxAngle = 45f * Mathf.Deg2Rad;
        }

        // Applies points and hits for Bonus Balls
        if (ballType == PickUpEffectsEnum.BonusBall)
        {
            score = ConfigurationUtils.BonusBallPoints;
            hits  = ConfigurationUtils.BonusBallHit;
        }

        // If not a Bonus Ball, Standard points are issued
        if (ballType == PickUpEffectsEnum.StandardBall)
        {
            score = ConfigurationUtils.StandardBallHit;
            hits  = ConfigurationUtils.StandardBallHit;
        }
        // randomly selects from the min and max angles
        float angle = Random.Range(minAngle, maxAngle);

        // sets new direction
        direction = new Vector2(Mathf.Cos(angle), Mathf.Sin(angle));
    }