Esempio n. 1
0
 void Awake()
 {
     _spriteRenderer = GetComponent<SpriteRenderer>();
     OnLeftTeam = transform.position.x <= 14.5 ? true : false;
     _leftPlayerScript = GameObject.FindGameObjectWithTag("LeftPlayer").GetComponent<BasePlayer>();
     _levelManagerScript = Camera.main.GetComponent<LevelManager>();
 }
Esempio n. 2
0
        // Use this for initialization
        void Start()
        {
            _initiallyHit = false;
            _rb2D = GetComponent<Rigidbody2D>();
            _ballRenderer = GetComponent<SpriteRenderer>();
            _ballColorChangePending = false;

            _leftPlayer = GameObject.FindGameObjectWithTag("LeftPlayer");
            _leftPlayerScript = _leftPlayer.GetComponent<BasePlayer>();
            _leftPlayerRenderer = _leftPlayer.GetComponent<SpriteRenderer>();
            _rightPlayer = GameObject.FindGameObjectWithTag("RightPlayer");
            _rightPlayerScript = _rightPlayer.GetComponent<BasePlayer>();
            _rightPlayerRenderer = _rightPlayer.GetComponent<SpriteRenderer>();

            _ballRenderer.color = OnLeftTeam ? _leftPlayerScript.TeamColor : _rightPlayerScript.TeamColor;

            _pendingColor = _ballRenderer.color;

            _lastDirectionChangeTime = Time.time;
            _prevDirection = Vector2.zero;
        }