コード例 #1
0
ファイル: BallMoving.cs プロジェクト: Hindi/C3P0GitHub
 // Use this for initialization
 void Start()
 {
     managerScript = manager.GetComponent <PongManagerScript>();
     defaultPos    = transform.position;
     defaultSpeed  = new Vector2(speed.x, speed.y);
     //Laws.setUniformValues(new double[] { 45, -45 });
 }
コード例 #2
0
 /// <summary>
 /// Initiates the special shot to this player
 /// </summary>
 /// <param name="s">The pong script</param>
 public void getCoupSpecial(PongManagerScript s)
 {
     pms         = s;
     coupSpecial = true;
     initTimer   = Time.time;
     timer       = Math.Abs((float)Laws.gauss() + 10) % 3;
 }
コード例 #3
0
ファイル: PongState.cs プロジェクト: Hindi/C3P0GitHub
 /// <summary>
 /// Delegate called when the game scene is done loading.
 /// </summary>
 /// <param name="lvl">The game's level done loading</param>
 public override void onLevelWasLoaded(int lvl)
 {
     base.onLevelWasLoaded(lvl);
     gameScript = GameObject.FindGameObjectWithTag("PongManagerScript").GetComponent <PongManagerScript>();
     player     = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerControl>();
     if (Application.isMobilePlatform)
     {
         Screen.orientation = ScreenOrientation.Landscape;
     }
     gameScript.updateElementsResolution();
     setParameter(new Parameter());
 }
コード例 #4
0
ファイル: BallMoving.cs プロジェクト: Hindi/C3P0GitHub
    /**
     * When the ball hits a Pallet and goes back
     * This is where the whole "random" collision has to be made
     **/
    /// <summary>
    /// Called when the ball hits a pallet
    /// </summary>
    void OnTriggerEnter2D(Collider2D obstacle)
    {
        PongManagerScript managerScript = manager.GetComponent <PongManagerScript>();

        if (((coupPlayer == -1 && transform.position.x < 0) || (coupPlayer == 1 && transform.position.x > 0)) && coupSpecial)
        {
            managerScript.activateCoupSpecial(speed);
            speed       = new Vector2(0, 0);
            coupSpecial = false;
        }
        else
        {
            speed.x *= -1;
            float norm  = Mathf.Sqrt(speed.x * speed.x + speed.y * speed.y);
            float Angle = 0;
            if (transform.position.x < 0) // côté joueur
            {
                Angle = Mathf.Atan2(speed.y, speed.x) * Mathf.Rad2Deg;
            }
            else
            {
                /* Here is the magic stuff ! */
                if (managerScript.param.id == 0)
                {
                    Angle = (float)Laws.uniforme(-80, 81);
                }
                else if (managerScript.param.id == 1)
                {
                    Angle += -80 + 2 * (float)Laws.poisson(4);
                }
                else if (managerScript.param.id == 2)
                {
                    Angle += ((float)Laws.binom(0.5, 10) - 5) * 16;
                }
                if (Angle > 80)
                {
                    Angle = 80;
                }
                if (Angle < -80)
                {
                    Angle = 80;
                }

                speed.x = Mathf.Cos(Angle * Mathf.Deg2Rad) * norm * ((transform.position.x > 0) ? -1 : 1);
                speed.y = Mathf.Sin(Angle * Mathf.Deg2Rad) * norm;
            }

            if (fireBall)
            {
                transform.localEulerAngles = new Vector3(0, 0, 90 + ((transform.position.x > 0) ? 0 : 180) + ((transform.position.x > 0) ? -1 : 1) * Angle);
            }
        }
    }
コード例 #5
0
 // Use this for initialization
 void Start()
 {
     pms           = GameObject.FindGameObjectWithTag("PongManagerScript").GetComponent <PongManagerScript>();
     defaultPos    = transform.position;
     originalScale = transform.localScale;
 }