private void GrabObject() { if (grabbedObj == null || currentCode == null) { moving = false; anim.SetTrigger("Pick"); this.tt("@DelayPick").Add(0.2f, () => { Debug.Log("Try"); Collider[] cols = Physics.OverlapSphere(transform.position, 1, mask); if (cols.Length > 0) { CreaturesBehaviour creature = cols[0].GetComponent <CreaturesBehaviour>(); if (creature) { currentCode = creature.ExtractGenetic(this); } else { grabbedObj = cols[0].transform; cols[0].isTrigger = true; grabbedObj.GetComponent <Rigidbody>().isKinematic = true; formerParent = grabbedObj.parent; grabbedObj.SetParent(transform); } } moving = true; }).Immutable(); } }
private void OnTriggerExit(Collider other) { if (other.gameObject.Equals(actor.gameObject)) { if (hatchedEgg != null) { actor.currentCode = hatchedEgg; actor.capsule.gameObject.SetActive(true); actor.capsule.materials[1].color = hatchedEgg.capsuleColor; actor.capsule.materials[1].SetColor("_EmissionColor", hatchedEgg.capsuleColor); hatchedEgg.gameObject.SetActive(false); eggOne.gameObject.SetActive(false); eggTwo.gameObject.SetActive(false); hatchedEgg = null; eggOne = null; eggTwo = null; } } }
public void HitSomething() { moving = false; anim.SetTrigger("Hit"); this.tt("@DelayHit").Add(0.5f, () => { Collider[] cols = Physics.OverlapSphere(transform.position, 2); if (cols.Length > 0) { for (int i = 0; i < cols.Length; i++) { CreaturesBehaviour creature = cols[i].GetComponent <CreaturesBehaviour>(); if (creature) { creature.HitCreature(); } } } moving = true; }).Immutable(); }
public void SetEgg(CreaturesBehaviour egg) { if (eggOne == null) { eggOne = egg; Transform newEgg = eggObj.liteInstantiate(eggSpotOne.position, eggObj.rotation); eggOne = newEgg.GetComponent <CreaturesBehaviour>(); actor.capsule.gameObject.SetActive(false); newEgg.GetComponent <Renderer>().materials[1].color = egg.capsuleColor; newEgg.GetComponent <Renderer>().materials[1].SetColor("_EmissionColor", egg.capsuleColor); } else if (eggTwo == null) { eggTwo = egg; Transform newEgg = eggObj.liteInstantiate(eggSpotTwo.position, eggObj.rotation); eggTwo = newEgg.GetComponent <CreaturesBehaviour>(); actor.capsule.gameObject.SetActive(false); newEgg.GetComponent <Renderer>().materials[1].color = egg.capsuleColor; newEgg.GetComponent <Renderer>().materials[1].SetColor("_EmissionColor", egg.capsuleColor); } if (eggOne != null && eggTwo != null) { this.tt("@HatchEgg").Add(hatchTime, () => { Transform newEgg = eggObj.liteInstantiate(eggSpotThree.position, eggObj.rotation); Color heirColor = eggOne.GetComponent <Renderer>().materials[1].color + eggTwo.GetComponent <Renderer>().materials[1].color; newEgg.GetComponent <Renderer>().materials[1].color = heirColor; newEgg.GetComponent <Renderer>().materials[1].SetColor("_EmissionColor", heirColor); hatchedEgg = newEgg.GetComponent <CreaturesBehaviour>(); hatchedEgg.patternLevel = 3; hatchedEgg.capsuleColor = heirColor; this.tt("@ShowCode").Add(() => { codeDisplay.gameObject.SetActive(true); hatchedEgg.codePattern = new List <int>(); for (int i = 0; i < codeDisplay.childCount; i++) { int rmd = Random.Range(0, hatchedEgg.codePatternSprites.Length); hatchedEgg.codePattern.Add(rmd); codeDisplay.GetChild(i).GetComponent <SpriteRenderer>().sprite = hatchedEgg.codePatternSprites[rmd]; } }).Add(hatchedEgg.timeToWait, () => { if (hatchedEgg != null) { actor.currentCode = hatchedEgg; actor.capsule.gameObject.SetActive(true); actor.capsule.materials[1].color = hatchedEgg.capsuleColor; actor.capsule.materials[1].SetColor("_EmissionColor", hatchedEgg.capsuleColor); hatchedEgg.gameObject.SetActive(false); eggOne.gameObject.SetActive(false); eggTwo.gameObject.SetActive(false); hatchedEgg = null; eggOne = null; eggTwo = null; codeDisplay.gameObject.SetActive(false); } }).Immutable(); }); // Init new egg } }