using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AudioManager : MonoBehaviour
{
private AudioSource audio;
public AudioClip sound01;
public AudioClip sound02;
public AudioClip sound03;
void Start()
{
audio = gameObject.AddComponent<AudioSource>();
}
void OnCollisionEnter(Collision other)
{
if (other.gameObject.tag == "Player")
{
audio.PlayOneShot(sound01);
}
else if (other.gameObject.tag == "Target")
{
audio.PlayOneShot(sound02);
}
else audio.PlayOneShot(sound03);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Bounce : MonoBehaviour
{
public float bounce = 10.0f;
void OnCollisionEnter(Collision other)
{
if (other.gameObject.tag == "Ball")
{
Vector3 norm = other.contacts[0].normal;
Vector3 vel = new Vector3(-norm.x, 0f, -norm.z);
other.rigidbody.AddForce(vel.normalized * bounce, ForceMode.VelocityChange);
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Broken : MonoBehaviour
{
void OnCollisionEnter(Collision other)
{
if (other.gameObject.tag == "Ball")
{
Destroy(gameObject, 0.2f);
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Bumper : MonoBehaviour
{
public float bounce = 10f;
void OnCollisionEnter(Collision other)
{
if (other.gameObject.tag == "Ball")
{
other.rigidbody.AddForce(0f, bounce/6, bounce, ForceMode.Impulse);
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class GameManager : MonoBehaviour
{
public int life = 3;
public GameObject ballPrefab;
public Text textGameOver;
void Start()
{
textGameOver.enabled = false;
}
void Update()
{
GameObject ballObj = GameObject.Find("Ball");
if (ballObj == null)
{
life--;
if (life > 0)
{
GameObject newBall = Instantiate(ballPrefab);
newBall.name = ballPrefab.name;
}
else
{
life = 0;
textGameOver.enabled = true;
}
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Kill : MonoBehaviour
{
void OnCollisionEnter(Collision other)
{
if (other.gameObject.tag == "Ball")
{
Destroy(other.gameObject, 0.1f);
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMove : MonoBehaviour
{
public float speed = 15f;
void FixedUpdate()
{
var velox = speed * Input.GetAxisRaw("Horizontal");
GetComponent<Rigidbody>().velocity = new Vector3(velox, 0f, 0f);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Rotation : MonoBehaviour
{
public float rotAngle = 4.0f;
void FixedUpdate()
{
transform.Rotate(0f, -rotAngle, 0f);
}
}