// Use this for initialization void Start() { if (this.gameObject.tag == "Blop1") { ScriptBlop1 = this.gameObject.GetComponent<Blop1Control>(); } else { ScriptBlop2 = this.gameObject.GetComponent<Blop2Control>(); } fTimer = 0.0f; isUsed = false; }
// Update is called once per frame void Update() { if(bIsMergin == true && rbody.isKinematic==false && audioPlayer.isPlaying==false && blocktype != BlockType.NPCAStar && bAudioHasPlayed == false ) { PlaySound(); } showSleeping = rbody.IsSleeping(); // Reset if object was an attachment in the previous frame and is no attachment now if (this.gameObject.tag == "Untagged" && stOldTag !="Untagged") { ResetObject(); } // Get access to the scripts of the two Blops if (GameObject.FindGameObjectWithTag("Blop1") != null) Blop1Script = GameObject.FindGameObjectWithTag("Blop1").GetComponent<Blop1Control>(); if (GameObject.FindGameObjectWithTag("Blop2") != null) Blop2Script = GameObject.FindGameObjectWithTag("Blop2").GetComponent<Blop2Control>(); if (!rbody.IsSleeping()) { saveSleeping = false; } if (!saveSleeping && rbody.IsSleeping() && blocktype != BlockType.NPCAStar) { if (Time.time > 10) { //Debug.Log("Update GridGraph from Object " + name); UpdateGraph.S.UpdateGridGraph(); } saveSleeping = true; } if(blocktype == BlockType.NPCAStar && finished) { if (Physics.Raycast(transform.position, Vector3.down, 1) && !bIsMergin) { StartCoroutine(ResetNPC()); GetComponent<FindTestPath>().Landed(); finished = false; } } // Get the Tag of the Object stOldTag = this.gameObject.tag; }
/// <summary> /// searches for the two Blops /// </summary> private void SearchForBlops() { if (Blop1 && Blop2) { return; } if (GameObject.FindGameObjectWithTag("Blop1") == null) return; Blop1 = GameObject.FindGameObjectWithTag("Blop1"); if (GameObject.FindGameObjectWithTag("Blop2") == null) return; Blop2 = GameObject.FindGameObjectWithTag("Blop2"); Blop1Script = Blop1.GetComponent<Blop1Control>(); Blop2Script = Blop2.GetComponent<Blop2Control>(); blopOneBody = Blop1.GetComponent<Rigidbody>(); blopTwoBody = Blop2.GetComponent<Rigidbody>(); }