Ejemplo n.º 1
0
 // Update is called once per frame
 void Update()
 {
     if (hotness != null)
     {
         if (hotness.GetIsHot() && trailObject != null)
         {
             trailObject.transform.position = new Vector3(transform.position.x, transform.position.y, -1);
         }
         if (hotness.GetIsHot() != hot)
         {
             hot = hotness.GetIsHot();
             if (hot)
             {
                 trailObject = Instantiate(trailPrefab);
                 trailObject.transform.position = new Vector3(transform.position.x, transform.position.y, -1);
                 trail = trailObject.GetComponent <ParticleSystem>();
                 trailObject.GetComponent <BallTrailCollider>().SetBallSource(ballSource);
             }
             else
             {
                 if (trailObject != null)
                 {
                     trail.Stop();
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
 void OnCollisionEnter2D(Collision2D coll)
 {
     if (hotness.GetIsHot() && coll.collider.tag == "Player")
     {
         cameraShake.StartShake();
     }
 }
Ejemplo n.º 3
0
 public void OnTriggerEnter2D(Collider2D coll)
 {
     if (hotness.GetIsHot() && smackable && coll.tag == "Smack")
     {
         rb.velocity = (transform.position - coll.transform.position).normalized * knockbackSpeed;
         source.SetThrower(coll.gameObject.transform.parent.transform.parent.GetComponent <PlayerData>());
     }
 }
Ejemplo n.º 4
0
    void FixedUpdate()
    {
        if (hotness.GetIsHot() && rigid.velocity.magnitude > seekThreshold)
        {
            GameObject target = FindClosestPlayer();

            Vector3 currentDirection = rigid.velocity.normalized;
            Vector3 targetDirection  = (target.transform.position - this.transform.position).normalized;
            Vector3 newDirection     = Vector3.Slerp(currentDirection, targetDirection, Time.deltaTime * aggressiveness);

            rigid.velocity = newDirection * rigid.velocity.magnitude;
        }
    }
Ejemplo n.º 5
0
 void OnCollisionEnter2D(Collision2D coll)
 {
     if (hotness.GetIsHot())
     {
         if (coll.collider.tag == "Player")
         {
             GameObject particles = Instantiate(particlesPrefab);
             particles.transform.position = transform.position;
             particles.GetComponent <BallParticleSystem>().SetColor(
                 PlayerManager.inst.GetColor(source.GetThrower().num));
         }
     }
 }
Ejemplo n.º 6
0
    void OnCollisionEnter2D(Collision2D coll)
    {
        if (hotness.GetIsHot())
        {
            switch (coll.collider.tag)
            {
            case "Player":
                AudioManager.instance.PlayClipAtPoint(AudioManager.instance.playerHit, transform.position);
                break;

            default:
                AudioManager.instance.PlayClipAtPoint(AudioManager.instance.otherHit, transform.position);
                break;
            }
        }
    }