Esempio n. 1
0
 // Start is called before the first frame update
 void Start()
 {
     P1Rigidbody   = P1.GetComponent <Rigidbody2D>();
     P2Rigidbody   = P2.GetComponent <Rigidbody2D>();
     ballRigidbody = ball.GetComponent <Rigidbody2D>();
     ballCollider  = ball.GetComponent <CircleCollider2D>();
 }
Esempio n. 2
0
 // Start is called before the first frame update
 void Start()
 {
     player1RB = player1.GetComponent <Rigidbody2D>();
     player2RB = player2.GetComponent <Rigidbody2D>();
     ballRB    = ball.GetComponent <Rigidbody2D>();
     ballCol   = ball.GetComponent <CircleCollider2D>();
 }
Esempio n. 3
0
 void Awake()
 {
     player1Rigidbody = player1.GetComponent <Rigidbody2D>();
     player2Rigidbody = player2.GetComponent <Rigidbody2D>();
     ballRigidbody    = ball.GetComponent <Rigidbody2D>();
     ballCollider     = ball.GetComponent <CircleCollider2D>();
 }
Esempio n. 4
0
 private void Start()
 {
     player1RigidBody = player1.GetComponent <Rigidbody2D>();
     player2RigidBody = player2.GetComponent <Rigidbody2D>();
     ballCollider     = ball.GetComponent <CircleCollider2D>();
     ballRigidBody    = ball.GetComponent <Rigidbody2D>();
 }
Esempio n. 5
0
 // Start is called before the first frame update
 void Start()
 {
     // Inisialisasi rigidbody dan collider
     player1Rigidbody = player1.GetComponent <Rigidbody2D>();
     player2Rigidbody = player2.GetComponent <Rigidbody2D>();
     ballRigidbody    = ball.GetComponent <Rigidbody2D>();
     ballCollider     = ball.GetComponent <CircleCollider2D>();
 }
Esempio n. 6
0
 void Start()
 {
     player1rigidbody2d = player1.GetComponent <Rigidbody2D>();
     player2rigidbody2d = player2.GetComponent <Rigidbody2D>();
     ballRigidbody      = ball.GetComponent <Rigidbody2D>();
     ballCollider       = ball.GetComponent <CircleCollider2D>();
     startPowerUpSpawner();
 }
Esempio n. 7
0
 // Start is called before the first frame update
 void Start()
 {
     Screen.fullScreen = false;
     Screen.SetResolution(1280, 720, false);
     player1Rigidbody = player1.GetComponent <Rigidbody2D>();
     player2Rigidbody = player2.GetComponent <Rigidbody2D>();
     ballRigidbody    = ball.GetComponent <Rigidbody2D>();
     ballCollider     = ball.GetComponent <CircleCollider2D>();
 }
Esempio n. 8
0
    // Start is called before the first frame update
    void Start()
    {
        player1Rigidbody = player1.GetComponent <Rigidbody2D>();
        player2Rigidbody = player2.GetComponent <Rigidbody2D>();
        ballRigidbody    = ball.GetComponent <Rigidbody2D>();
        ballCollider     = ball.GetComponent <CircleCollider2D>();

        StartCoroutine(SpawnPowerUp());
        StartCoroutine(SpawnFireball());
    }
Esempio n. 9
0
    void Start()
    {
        _ballRigidBody2D   = ballControl.GetComponent <Rigidbody2D>();
        _ballCollider2D    = ballControl.GetComponent <CircleCollider2D>();
        trajectory.enabled = false;

        player1Left.dieFireball.AddListener(delegate { _player2Win = true; });
        player2Right.dieFireball.AddListener(delegate { _player1Win = true; });

        StartGame();
    }
Esempio n. 10
0
    //Coroutine buffCyclee, debuffCycle, getPower;

    // Start is called before the first frame update
    void Start()
    {
        player1Rigidbody   = player1.GetComponent <Rigidbody2D>();
        player2Rigidbody   = player2.GetComponent <Rigidbody2D>();
        ballRigidbody      = ball.GetComponent <Rigidbody2D>();
        ballCollider       = ball.GetComponent <CircleCollider2D>();
        oldPlayer1Boundary = player1.yBoundary;
        oldPlayer2Boundary = player2.yBoundary;
        StartCoroutine(BuffCycle());
        StartCoroutine(DebuffCycle());
    }
Esempio n. 11
0
    // Start is called before the first frame update
    void Start()
    {
        //Inisialisasi rigidbody dan collider
        playerRigidbody  = player1.GetComponent <Rigidbody2D>();
        player2Rigidbody = player2.GetComponent <Rigidbody2D>();
        ballRigidbody    = ball.GetComponent <Rigidbody2D>();
        ballCollider     = ball.GetComponent <CircleCollider2D>();
        powRigidbody     = pow.GetComponent <Rigidbody2D>();
        powCollider      = pow.GetComponent <CircleCollider2D>();

        //Beri jeda waktu untuk aktivasi GameObject
        Invoke("ActivatePow", 3);
    }
Esempio n. 12
0
    // Start is called before the first frame update
    void Start()
    {
        player1Rigidbody = player1.GetComponent <Rigidbody2D>();
        player2Rigidbody = player2.GetComponent <Rigidbody2D>();
        ballRigidbody    = ball.GetComponent <Rigidbody2D>();
        ballCollider     = ball.GetComponent <CircleCollider2D>();

        jumlahPowerUp = 0;
        InvokeRepeating("MakePowerUp", 9.0f + (Random.Range(0, 30) / 10.0f), 4.0f + (Random.Range(0, 30) / 10.0f));

        jumlahFireBall = 0;
        InvokeRepeating("MakeFireBall", 9.0f + (Random.Range(0, 30) / 10.0f), 4.0f + (Random.Range(0, 30) / 10.0f));

        player1FireBall = false;
        player2FireBall = false;
    }
Esempio n. 13
0
    // Start is called before the first frame update
    // Inisialisasi rigidbody dan collider
    void Start()
    {
        player1Rigidbody = player1.GetComponent <Rigidbody2D>();
        player2Rigidbody = player2.GetComponent <Rigidbody2D>();
        ballRigidbody    = ball.GetComponent <Rigidbody2D>();
        ballCollider     = ball.GetComponent <CircleCollider2D>();

        fireballRigidbody = fireball.GetComponent <Rigidbody2D>();
        fireballCollider  = fireball.GetComponent <CircleCollider2D>();

        fireballCounter        = 0;
        fireballFrameThreshold = Random.Range(300, 1200);

        expanderCounter        = 0;
        expanderFrameThreshold = Random.Range(1500, 4800);
    }
Esempio n. 14
0
    public IEnumerator AnimationOfSprite()      // animation off object (example: ball, multi-ball etc.)]
    {
        bool      isAnim = true;
        ThrowBall tb     = SaveComponent.GetComponent <ThrowBall>();

        if (tb != null)
        {
            if (tb.This_destroyBall || tb.This_multiBall)
            {
                isAnim = false;
            }
        }
        if (isAnim)
        {
            SaveComponent.AnimationOfBall(0.5f);
            yield return(new WaitForFixedUpdate());

            StartCoroutine("AnimationOfSprite");
        }
        else
        {
            yield return(new WaitForFixedUpdate());
        }
    }
Esempio n. 15
0
 void Awake()
 {
     ballRigidbody = ball.GetComponent <Rigidbody2D>();
     ballCollider  = ball.GetComponent <CircleCollider2D>();
 }
Esempio n. 16
0
 // Use this for initialization
 void Start()
 {
     ballRigidBody = ball.GetComponent <Rigidbody2D>();
     ballCollider  = ball.GetComponent <CircleCollider2D>();
 }
Esempio n. 17
0
    void OnTriggerEnter(Collider other)
    {
        if (!once && GameObject.Find("Main Camera").GetComponent <ControlOfPl> ().Player_off == 0)                                                                                                                   // if all right
        {
            if (other.gameObject.GetComponent <BallControl> () != null && gameObject.name == "throw ball" && !This_destroyBall && !This_fireBall && !This_DestroyColor && other.gameObject.name != "ball under off") // if it`s simple ball
            {
                if (other.GetComponent <BallControl> ().c < other.GetComponent <BallControl> ().ccObject.SetOfPoints.Count - 7)                                                                                      // if it`s not near finish
                {
                    BallControl otherToScript = other.gameObject.GetComponent <BallControl> ();                                                                                                                      // get component from other ball
                    mainStart = otherToScript.msScript;

                    GetComponent <BallControl> ().ccObject = otherToScript.ccObject;
                    GetComponent <BallControl> ().msScript = otherToScript.msScript;

                    //тут идет проигрывание звука шарик ударяется
                    if (GameObject.Find("Sound Center").GetComponent <SoundCenter> ().Ball_collision_with_line != null)
                    {
                        GameObject.Find("SC 1").GetComponent <AudioSource> ().PlayOneShot(GameObject.Find("Sound Center").GetComponent <SoundCenter> ().Ball_collision_with_line);
                    }

                    timeBall = mainStart.TimeBall;
                    once     = true;
                    Vector3 GetFirst  = otherToScript.ccObject.GetNewVector(otherToScript, 0.001f, otherToScript.t - 1, otherToScript.c, true);
                    Vector3 GetSecond = otherToScript.ccObject.GetNewVector(otherToScript, 0.001f, otherToScript.t + 1, otherToScript.c, true);
                    // calculate a two distances, need for get info about future position of ball
                    float dist1    = Mathf.Sqrt((transform.position.x - GetFirst.x) * (transform.position.x - GetFirst.x) + (transform.position.y - GetFirst.y) * (transform.position.y - GetFirst.y) + (transform.position.z - GetFirst.z) * (transform.position.z - GetFirst.z));
                    float dist2    = Mathf.Sqrt((transform.position.x - GetSecond.x) * (transform.position.x - GetSecond.x) + (transform.position.y - GetSecond.y) * (transform.position.y - GetSecond.y) + (transform.position.z - GetSecond.z) * (transform.position.z - GetSecond.z));
                    float interval = mainStart.interval;

                    if (dist1 > dist2)
                    {
                        // After this ball
                        mode       = mainStart.GeneratedBalls.IndexOf(otherToScript) - 1;
                        StopIndex2 = mainStart.FindStopIndex(mode, 1f, mainStart.BaseSpeed, 0);
                        if (mainStart.BaseSpeed < 0)
                        {
                            StopIndex2 = mainStart.FindStopIndex(mode, 1f, -mainStart.BaseSpeed, 0);
                        }

                        if (mode >= 0)
                        {
                            if ((interval * mainStart.GeneratedBalls [mode].c + interval * mainStart.GeneratedBalls [mode].t) - (interval * mainStart.GeneratedBalls [mode + 1].c + interval * mainStart.GeneratedBalls [mode + 1].t) > mainStart.distance * 0.99f &&
                                (interval * mainStart.GeneratedBalls [mode].c + interval * mainStart.GeneratedBalls [mode].t) - (interval * mainStart.GeneratedBalls [mode + 1].c + interval * mainStart.GeneratedBalls [mode + 1].t) < mainStart.distance * 3f)
                            {
                                StopIndex2 = mainStart.FindStopIndex(mode, 1f, mainStart.BaseSpeed, 0);
                                if (mainStart.BaseSpeed < 0)
                                {
                                    StopIndex2 = mainStart.FindStopIndex(mode, 1f, -mainStart.BaseSpeed, 0);
                                }
                                dmode = -1;
                            }
                        }
                    }
                    else
                    {
                        // Before this ball
                        mode       = mainStart.GeneratedBalls.IndexOf(otherToScript);
                        StopIndex2 = mainStart.FindStopIndex(mode, 1f, mainStart.BaseSpeed, 0);
                        if (mainStart.BaseSpeed < 0)
                        {
                            StopIndex2 = mainStart.FindStopIndex(mode, 1f, -mainStart.BaseSpeed, 0);
                        }
                        if (mode < mainStart.GeneratedBalls.Count - 2)
                        {
                            if ((interval * mainStart.GeneratedBalls [mode].c + interval * mainStart.GeneratedBalls [mode].t) - (interval * mainStart.GeneratedBalls [mode + 1].c + interval * mainStart.GeneratedBalls [mode + 1].t) > mainStart.distance * 1.01f)
                            {
                                dmode      = 1;
                                StopIndex2 = mainStart.FindStopIndex((mode - 1), 1f, mainStart.BaseSpeed, 0);
                                if (mainStart.BaseSpeed < 0)
                                {
                                    StopIndex2 = mainStart.FindStopIndex((mode - 1), 1f, -mainStart.BaseSpeed, 0);
                                }
                            }
                        }
                    }
                    // start Coroutine for other work
                    if (mainStart.BaseSpeed >= 0)
                    {
                        StartCoroutine(pGoInLine(other.gameObject.GetComponent <SpriteRenderer> ().sortingOrder));
                    }
                    if (mainStart.BaseSpeed < 0)
                    {
                        StartCoroutine(nGoInLine(other.gameObject.GetComponent <SpriteRenderer> ().sortingOrder));
                    }
                    mainStart.mode_IndexStop = mode;
                }
            }
            else if (other.gameObject.GetComponent <BallControl> () != null && gameObject.name == "throw ball" && This_destroyBall && other.gameObject.name != "ball under off")                // if it`s object that can destroy a ball
            {
                once = true;
                if (GameObject.Find("Sound Center").GetComponent <SoundCenter> ().Bonus_Set_of_destroyBall != null)
                {
                    GameObject.Find("SC 7").GetComponent <AudioSource> ().PlayOneShot(GameObject.Find("Sound Center").GetComponent <SoundCenter> ().Bonus_Set_of_destroyBall);
                }
                BallControl otherToScript = other.gameObject.GetComponent <BallControl> ();
                GetComponent <BallControl> ().ccObject = otherToScript.ccObject;
                GetComponent <BallControl> ().msScript = otherToScript.msScript;
                mainStart = otherToScript.msScript;
                int Indexofball = mainStart.GeneratedBalls.IndexOf(otherToScript);
                mainStart.GeneratedBalls.Remove(otherToScript);
                mainStart.CreateDestroyBall(otherToScript.gameObject);

                Vector3 ResultPosition = otherToScript.gameObject.transform.position;
                mainStart.GetComponent <ControlOfPl> ().AddScoreGlobal(mainStart.GetComponent <ControlOfPl> ().Score_Bonuse, otherToScript.GetComponent <SpriteRenderer> ().color, ResultPosition);

                Destroy(otherToScript.gameObject);
                mainStart.IndexStop = mainStart.FindStopIndex((mainStart.GeneratedBalls.Count - 2), 1f, mainStart.BaseSpeed, 0);
                mainStart.gameObject.GetComponent <ControlOfPl> ().SearchAvCollors();
                if (Indexofball > 0 && Indexofball < mainStart.GeneratedBalls.Count - 1 && !mainStart.EndOfLine)
                {
                    if (mainStart.GeneratedBalls [Indexofball].GetComponent <SpriteRenderer> ().color == mainStart.GeneratedBalls [Indexofball - 1].GetComponent <SpriteRenderer> ().color)
                    {
                        if (Indexofball > 1)
                        {
                            if (mainStart.GeneratedBalls [Indexofball - 1].GetComponent <SpriteRenderer> ().color == mainStart.GeneratedBalls [Indexofball - 2].GetComponent <SpriteRenderer> ().color)
                            {
                                mainStart.BaseSpeed = mainStart.saveBaseSpeed;
                                mainStart.StartCoroutine(mainStart.CollisionInline(Indexofball - 1));
                            }
                        }
                        if (Indexofball < mainStart.GeneratedBalls.Count - 2)
                        {
                            if (mainStart.GeneratedBalls [Indexofball].GetComponent <SpriteRenderer> ().color == mainStart.GeneratedBalls [Indexofball + 1].GetComponent <SpriteRenderer> ().color)
                            {
                                mainStart.BaseSpeed = mainStart.saveBaseSpeed;
                                mainStart.StartCoroutine(mainStart.CollisionInline(Indexofball - 1));
                            }
                        }
                    }
                }
                Destroy(gameObject);
            }
            // if`s fire
            if (other.gameObject.GetComponent <BallControl> () != null && gameObject.name == "throw ball" && This_fireBall)
            {
                BallControl otherToScript = other.gameObject.GetComponent <BallControl> ();
                GetComponent <BallControl> ().ccObject = otherToScript.ccObject;
                GetComponent <BallControl> ().msScript = otherToScript.msScript;
                mainStart = otherToScript.msScript;
                mainStart.GeneratedBalls.Remove(otherToScript);
                mainStart.CreateDestroyBall(otherToScript.gameObject);

                Vector3 ResultPosition = otherToScript.gameObject.transform.position;
                mainStart.GetComponent <ControlOfPl> ().AddScoreGlobal(mainStart.GetComponent <ControlOfPl> ().Score_Bonuse, otherToScript.GetComponent <SpriteRenderer> ().color, ResultPosition);

                Destroy(otherToScript.gameObject);
                mainStart.IndexStop = mainStart.FindStopIndex((mainStart.GeneratedBalls.Count - 2), 1f, mainStart.BaseSpeed, 0);
                mainStart.gameObject.GetComponent <ControlOfPl> ().SearchAvCollors();
            }
            // if it`s arrow
            if (other.gameObject.GetComponent <BallControl> () != null && gameObject.name == "throw ball" && This_DestroyColor && other.gameObject.name != "ball under off")
            {
                once = true;
                if (GameObject.Find("Sound Center").GetComponent <SoundCenter> ().Bonus_Destroy_color != null)
                {
                    GameObject.Find("SC 8").GetComponent <AudioSource> ().PlayOneShot(GameObject.Find("Sound Center").GetComponent <SoundCenter> ().Bonus_Destroy_color);
                }
                BallControl otherToScript = other.gameObject.GetComponent <BallControl> ();
                GetComponent <BallControl> ().ccObject = otherToScript.ccObject;
                GetComponent <BallControl> ().msScript = otherToScript.msScript;
                mainStart = otherToScript.msScript;
                Color Color_use = otherToScript.GetComponent <SpriteRenderer> ().color;
                int   countGB   = 0;
                List <BallControl> ListOfDel = new List <BallControl> {
                };
                while (countGB < mainStart.GeneratedBalls.Count)
                {
                    if (mainStart.GeneratedBalls [countGB].GetComponent <SpriteRenderer> ().color == Color_use && mainStart.GeneratedBalls [countGB].gameObject.name == "ball")
                    {
                        ListOfDel.Add(mainStart.GeneratedBalls [countGB]);
                    }
                    countGB++;
                }

                while (ListOfDel.Count > 0)
                {
                    mainStart.GeneratedBalls.Remove(ListOfDel [0]);
                    mainStart.CreateDestroyBall(ListOfDel [0].gameObject);

                    Vector3 ResultPosition = ListOfDel [0].gameObject.transform.position;
                    mainStart.GetComponent <ControlOfPl> ().AddScoreGlobal(mainStart.GetComponent <ControlOfPl> ().Score_Bonuse, otherToScript.GetComponent <SpriteRenderer> ().color, ResultPosition);

                    Destroy(ListOfDel [0].gameObject);
                    ListOfDel.Remove(ListOfDel [0]);
                }

                mainStart.gameObject.GetComponent <ControlOfPl> ().SearchAvCollors();
                mainStart.IndexStop = mainStart.FindStopIndex((mainStart.GeneratedBalls.Count - 2), 1f, mainStart.BaseSpeed, 0);
                Destroy(gameObject);
            }
        }
    }
Esempio n. 18
0
 void Start()
 {
     _ballRigidbody2D      = ball.GetComponent <Rigidbody2D>();
     _ballCircleCollider2D = ball.GetComponent <CircleCollider2D>();
 }