private void OnTriggerEnter(Collider other) { if (other.gameObject.name == "Main Cube") { mainCharacter character = other.gameObject.GetComponent <mainCharacter>(); if (!character.isPowerful()) { character.becomePowerful(timeActive); Destroy(gameObject); } } }
// Use this for initialization void Awake() { player = GameObject.FindGameObjectWithTag("Player").GetComponent <mainCharacter>(); audioPlay = GameObject.FindGameObjectWithTag("AudioPlay").GetComponent <AudioPlay>(); text = GameObject.FindGameObjectWithTag("PairUI").GetComponent <Text>(); gameOverUI = GameObject.FindGameObjectWithTag("GameOver"); inGameUI = GameObject.FindGameObjectWithTag("InGame"); Debug.Log(GameObject.FindGameObjectWithTag("FinalText")); finalText = GameObject.FindGameObjectWithTag("FinalText").GetComponent <Text>(); finalText.gameObject.SetActive(false); text.text = textPrefix + numOfPairs; }
public IEnumerator Hugging() { if (!mainC) { mainC = GameManager.player; } Vector3 relativeToPlayer = mainC.transform.position - transform.position; while (isHugging) { transform.position = mainC.transform.position - relativeToPlayer; yield return(null); } }
public void Hug(GameObject gameObject) { Debug.Log("Hug " + gameObject); mainCharacter mc = gameObject.GetComponent <mainCharacter>(); if (!isHugging && mainCharacter.state != mainCharacter.MainCharacterGameState.CaughtByDude) { isHugging = true; anim.SetBool("Hug", true); //transform.SetParent(gameObject.transform); StartCoroutine("Hugging"); gameObject.GetComponent <mainCharacter>().enterCaughByDude(); } }
private void OnCollisionEnter(Collision collision) { speed = 0 - speed; if (collision.gameObject.name == "Main Cube") { mainCharacter mc = collision.gameObject.GetComponent <mainCharacter>(); if (mc.isPowerful()) { Destroy(this.gameObject); } else { mc.decreaseLives(); } } }
void OnTriggerEnter(Collider other) { if (!mainC) { mainC = GameManager.player; } if (mainC.isAttack && other.CompareTag("Punch")) { ReceiveDamage(mainC.punchDmg); GameManager.audioPlay.PlayRandomSound(aus, punchClips); GameObject bloodP = Instantiate(bloodParticle, transform.position, Quaternion.identity) as GameObject; Destroy(bloodP, 10f); } }