コード例 #1
0
ファイル: Ball.cs プロジェクト: tktksml/pingpong
    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
ファイル: Ball.cs プロジェクト: stratok/Pong
 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;
    }
コード例 #7
0
    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
ファイル: GameService.cs プロジェクト: Bmak/Plops-Prototype
    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
ファイル: MultiPlayerGameMode.cs プロジェクト: disas69/Pong
        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 });
    }
コード例 #11
0
        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
ファイル: GameMode.cs プロジェクト: disas69/Pong
 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)