// Start is called before the first frame update void Start() { p1_score_display = (LetterBoard)p1_score_obj.GetComponent(typeof(LetterBoard)); p2_score_display = (LetterBoard)p2_score_obj.GetComponent(typeof(LetterBoard)); letterboard = (LetterBoard)letterboard_obj.GetComponent(typeof(LetterBoard)); ball = (BallCollide)ball_obj.GetComponent(typeof(BallCollide)); paddle1 = (PaddleMove)paddle1_obj.GetComponent(typeof(PaddleMove)); paddle2 = (PaddleMove)paddle2_obj.GetComponent(typeof(PaddleMove)); game_init(); }
public void set_powerup(int player, int powerup) { PaddleMove paddle = paddle1; if (player == 2) { paddle = paddle2; } paddle.set_affliction(powerup); powerup_delay = powerup_delay_max; }
void Awake() { maxScore = StaticValues.MAXSCORE; particleObject = GetComponent <ParticleSystem>(); particleObject.Stop(); mh1 = GameObject.Find("MH1").GetComponent <AudioSource>(); mh2 = GameObject.Find("MH2").GetComponent <AudioSource>(); mh3 = GameObject.Find("MH3").GetComponent <AudioSource>(); mh4 = GameObject.Find("MH4").GetComponent <AudioSource>(); scoreUIP1 = GameObject.Find("P1 Score").GetComponent <Text>(); scoreUIP2 = GameObject.Find("P2 Score").GetComponent <Text>(); nameUIP1 = GameObject.Find("P1 Name").GetComponent <Text>(); nameUIP2 = GameObject.Find("P2 Name").GetComponent <Text>(); panelFinish = GameObject.Find("Game Over"); panelPause = GameObject.Find("Pause Screen"); rbody = GetComponent <Rigidbody2D>(); panelFinish.SetActive(false); panelPause.SetActive(false); scoreUIP1.text = ""; scoreUIP2.text = ""; nameUIP1.text = StaticValues.P1NAME; nameUIP2.text = StaticValues.P2NAME; StartCoroutine(FlashName()); PaddleMove P2 = GameObject.Find("PaddleKanan").GetComponent <PaddleMove>(); P2.bot = StaticValues.P2ISBOT; BolaMulai(""); }
private void MovePaddle(PaddleMove move) { gameState = backend.Run(new BigInteger[] { (int)move }); }
void OnCollisionEnter(Collision collision) { ContactPoint contact = collision.GetContact(0); Vector3 normal = contact.normal; AudioClip to_play = null; if (contact.otherCollider.CompareTag("paddle")) { to_play = paddle_hit[Random.Range(0, paddle_hit.Length)]; speed += speed_delta; float rel_pos = contact.otherCollider.transform.InverseTransformPoint(contact.point).z; rel_pos *= player == 1 ? 1 : -1; normal = Quaternion.AngleAxis((rel_pos * 45f), Vector3.up) * normal; PaddleMove paddlescript = (PaddleMove)contact.otherCollider.gameObject.GetComponent(typeof(PaddleMove)); player = paddlescript.player; if (paddlescript.affliction == 2) { immobile = true; to_play = squish[0]; paddlescript.hold(); } else if (Mathf.Abs(rel_pos) < 0.1) { to_play = ding; } } else if (!immortal && contact.otherCollider.CompareTag("kill_wall")) { gamemanager.round_over(contact.otherCollider.name); } else { to_play = table_hit[Random.Range(0, table_hit.Length)]; } //print(speed); //if (speed > 0.2f && !immobile) //{ // to_play = ding; //} ballspeaker.pitch = speed * 10 - 0.1f; if (to_play != null) { ballspeaker.PlayOneShot(to_play, 1f); } direction = Vector3.Reflect(direction, normal); if (normal.x != 0) { direction.x = Mathf.Abs(direction.x) * normal.x > 0 ? 1 : -1; } direction = Vector3.Normalize(direction); }