// Use this for initialization void Start () { playerChar = GameObject.FindGameObjectWithTag ("Player"); charScript = playerChar.GetComponent<characterMovingScript> (); playerPos = playerChar.transform.position; camPos = new Vector3 (playerPos.x, playerPos.y, -10); furthestPosX = playerPos.x; }
void hitPlayer(RaycastHit2D ray){ playerScript = ray.collider.gameObject.GetComponent<characterMovingScript> (); Rigidbody2D playerRig = ray.collider.gameObject.GetComponent<Rigidbody2D> (); if (!playerScript._tookDamage) { playerRig.AddForce (new Vector2 (aiScale.x, 1) * 300); playerScript.StartCoroutine ("invincibility"); StartCoroutine ("WaitLaugh"); playerScript.hearts[playerScript.health].SetActive(false); playerScript.health--; playerScript._tookDamage = true; } }
void doPowerUp(Collider2D other){ AudioSource audio = GameObject.FindGameObjectWithTag ("audio").GetComponent<AudioSource> (); Audios clips = GameObject.FindGameObjectWithTag ("audio").GetComponent<Audios> (); script = other.gameObject.GetComponent<characterMovingScript> (); switch (gameObject.tag) { case "Pizza": if (script.health < 2) { script.health++; script.hearts [script.health].SetActive (true); } audio.PlayOneShot (clips.audios [3]); break; case "Mushroom": Debug.Log ("Not yet implemented"); break; case "Beer": texts = GameObject.FindGameObjectWithTag ("Survive").GetComponent<dontDestonload> (); script.beerCounter++; texts.counter++; audio.PlayOneShot (clips.audios [4]); break; } }
public IEnumerator AttackEnemy(){ //anim.SetBool ("_isAttacking", true); yield return new WaitForSeconds(0.3f); Vector3 forwardRay = new Vector3 (aiScale.x, 0, 0); RaycastHit2D ray = Physics2D.Raycast(rayFront.transform.position, forwardRay, 0.5f); //scan front if (ray.collider != null && ray.collider.tag == "Player") { playerScript = ray.collider.gameObject.GetComponent<characterMovingScript> (); Rigidbody2D playerRig = ray.collider.gameObject.GetComponent<Rigidbody2D> (); if (!playerScript._tookDamage && !dying) { playerRig.AddForce (new Vector2 (aiScale.x, 1) * 100); playerScript.StartCoroutine ("invincibility"); StartCoroutine ("WaitLaugh"); playerScript.hearts[playerScript.health].SetActive(false); playerScript.health--; playerScript._tookDamage = true; } } yield return new WaitForSeconds(0.2f); _isAttacking = false; //anim.SetBool ("_isAttacking", false); }
// Use this for initialization void Start () { script = GameObject.FindGameObjectWithTag ("Player").GetComponent<characterMovingScript> (); anim = GetComponent<Animator> (); }