Пример #1
0
    public void Init(BallSettings settings)
    {
        currentSettings = settings;

        ballRenderer.sharedMaterial.color = settings.color;
        transform.localScale = defaultScale * settings.scale;
        transform.position   = Vector3.zero;
        if (PhotonNetwork.IsMasterClient)
        {
            //Don't use typical random - Y can be equals ~0!
            float y, x;
            if (Random.Range(0, 2) == 0)
            {
                y = Random.Range(-1f, -3f);
            }
            else
            {
                y = Random.Range(1f, 3f);
            }
            x = Random.Range(-3f, 3f);

            Vector3 dir = new Vector3(x, y, 0).normalized;
            ballRb.velocity = dir * settings.speed;
        }
    }
Пример #2
0
 public virtual void Init(BallSettings settings, Vector2 tableSize)
 {
     m_Settings  = settings;
     m_TableSize = tableSize;
     m_Rigidbody = GetComponent <Rigidbody2D>();
     m_Transform = transform;
 }
Пример #3
0
        public override void Initialize(BallSettings ballSettings)
        {
            _hitsCount = 0;

            ResetRacket(_topRacket);
            ResetRacket(_bottomRacket);
            SetupBall(ballSettings);
        }
Пример #4
0
        public void Setup(BallSettings ballSettings)
        {
            _startSpeed    = ballSettings.StartSpeed;
            _bouncingSpeed = ballSettings.BouncingSpeed;
            _ballView      = Instantiate(ballSettings.View, transform);
            _effectsPool   = new Pool <ParticleSystem>(_ballView.HitEffect, transform.parent, _effectsPoolCapacity);

            transform.localScale = ballSettings.Size;
        }
Пример #5
0
        private void SetupBall(BallSettings ballSettings)
        {
            ClearBallRoot();

            var ballInstance = Instantiate(_ballPrefab, BallRoot);

            ballInstance.Setup(ballSettings);

            this.WaitForSeconds(GameConfiguration.Instance.BallKickOffDelay, () => ballInstance.KickOff());
        }
Пример #6
0
    protected override void SpawnBall(BallSettings settings)
    {
        if (!PhotonNetwork.IsMasterClient)
        {
            return;
        }

        m_Ball = PhotonNetwork.Instantiate(m_BallPrefab.name, Vector2.zero, Quaternion.identity).GetComponent <BallDualMode>();
        m_Ball.Init(settings, m_TableSize);
        m_Ball.GetComponent <SpriteRenderer>().color = m_BallColor;
    }
    public BallManager(IInput input, Camera camera, BallSettings ballSettings, Action gameOverCallBack)
    {
        _camera           = camera;
        _input            = input;
        _gameOverCallback = gameOverCallBack;

        _ballOffset  = ballSettings.BallOffset;
        _ballScale   = ballSettings.BallScale;
        _disableTime = ballSettings.DisableTime;
        _UIOffset    = ballSettings.UIOffset;

        _UITransform = (GameObject.Instantiate(ballSettings.BallCountUI) as GameObject).transform;

        _UITransform.gameObject.SetActive(false);
        _ballCounttext = _UITransform.GetComponentInChildren <Text>();
    }
Пример #8
0
    public BallSettings GetBallSettings()
    {
        BallSettings ballSettings = new BallSettings();

        ballSettings.Size = Random.Range(_settings.MinSize, _settings.MaxSize);

        ballSettings.Speed = (int)UtilFunc.MapValue(ballSettings.Size, _settings.MinSize, _settings.MaxSize,
                                                    _settings.MaxSpeed, _settings.MinSpeed) + _speedStep;

        ballSettings.StartPos = new Vector3(GetRandomXPos(ballSettings.Size), -GD.ScreenHeight / 2 - ballSettings.Size / 2);
        ballSettings.Color    = Random.ColorHSV();

        ballSettings.Points = (int)UtilFunc.MapValue(ballSettings.Speed,
                                                     _settings.MinSpeed + _speedStep, _settings.MaxSpeed + _speedStep,
                                                     _settings.MinPoints, _settings.MaxPoints + 1);

        return(ballSettings);
    }
Пример #9
0
        public override void Initialize(BallSettings ballSettings)
        {
            base.Initialize(ballSettings);

            ClearBallRoot();

            if (NetworkManager.IsHost)
            {
                _ballSettingsName = ballSettings.Name;

                this.WaitUntil(() => NetworkManager.IsReady, () =>
                {
                    NetworkServer.SendToAll(NetworkMessages.BallSettingsMessage, new StringMessage(ballSettings.Name));
                    NetworkServer.SendToAll(NetworkMessages.StartGameMessage, new EmptyMessage());
                    NetworkServer.Spawn(Instantiate(_ballPrefab, BallRoot).gameObject);
                });
            }
        }
Пример #10
0
    public static byte[] Serialize(object obj)
    {
        BallSettings settings = (BallSettings)obj;

        return(new byte[] { (byte)settings.color.r, (byte)settings.color.g, (byte)settings.color.b, (byte)settings.speed, (byte)settings.scale });
    }
        public MoveDrawTrajectoryAction(BallFacade ball, ITrajectoryDataSource trajectorySource, BallSettings ballSettings)
        {
            m_Ball             = ball;
            m_TrajectorySource = trajectorySource;

            m_WayPoints = m_TrajectorySource.GetWayPoints(m_Ball.BallIndex);

            MovingPrecision = ballSettings.MovingPrecision;
        }
Пример #12
0
 protected virtual void SpawnBall(BallSettings settings)
 {
 }
Пример #13
0
 public virtual void Initialize(BallSettings ballSettings)
 {
 }
Пример #14
0
 protected override void SpawnBall(BallSettings settings)
 {
     m_Ball = Instantiate(m_BallPrefab, transform).GetComponent <BallSingleMode>();
     m_Ball.Init(settings, m_TableSize);
     m_Ball.GetComponent <SpriteRenderer>().color = m_BallColor;
 }
Пример #15
0
 public BallMechanic(BallSettings settings, in FxNum tickDuration)