// Use this for initialization void Start() { Birb.Props props = new Birb.Props(); props.Add("text", this.text); var button = Birb.CreateElement(buttonPrefab, props); Birb.Render(uiRoot, button); }
public override bool TryAddBirb(Birb birb, Enums.BirbLocation location) { if (base.TryAddBirb(birb, location)) { ResetBreeding(); return(true); } return(false); }
public void TryMakeEgg() { Birb egg = MakeEgg(bh.birbList[0].stats.breedTime, bh.birbList[1].stats.breedTime); if (egg != null) { birbList.Add(egg as ChildEggBirb); bh.breeding = false; } }
public Birb MakeEgg(float breedTime1, float breedTime2) { if (bh.timeSinceBothParentsInBreeder >= (breedTime1 + breedTime2) / 2f) { GameObject go = Instantiate(birbPrefab, Vector3.zero, Quaternion.identity); go.transform.SetParent(birbTransform); go.GetComponent <RectTransform>().offsetMax = Vector2.zero; go.GetComponent <RectTransform>().offsetMin = Vector2.zero; Birb birb = go.GetComponent <Birb>().CreateNewBirbFromParents(bh.birbList[0], bh.birbList[1]); birb.birbLocation = Enums.BirbLocation.NestParentsEgg; ph.allPlayerBirbs.Add(birb); return(birb); } return(null); }
public Birb SetBirbStats(Birb birb) { speciesId = birb.speciesId; birbColor = birb.birbColor; birbSprite = birb.birbSprite; parents = birb.parents; status = birb.status; stats = birb.stats; birbLocation = birb.birbLocation; hatched = birb.hatched; SetBirbSpritesAndColours(); return((Birb)this.MemberwiseClone()); }
public override bool TryAddBirb(Birb birb, Enums.BirbLocation location) { openBirbSlot = CheckForOpenBirbSlot(); if (openBirbSlot >= 0) { GameObject go = Instantiate(birbPrefab, Vector3.zero, Quaternion.identity); go.transform.SetParent(birbTransform); go.GetComponent <RectTransform>().offsetMax = Vector2.zero; go.GetComponent <RectTransform>().offsetMin = Vector2.zero; birbList.Add(go.GetComponent <HatchingBirb>()); birbList[openBirbSlot].SetBirbStats(birb); birbList[openBirbSlot].birbLocation = location; return(true); } return(false); }
bool ShouldDieFromCollision(Collision2D collision) { if (_hasDied) { return(false); } Birb bird = collision.gameObject.GetComponent <Birb>(); if (bird != null) { return(true); } if (collision.contacts[0].normal.y < -0.5f) { return(true); } return(false); }
public Birb CreateNewBirbFromParents(Birb parent1, Birb parent2, Enums.BirbLocation location = Enums.BirbLocation.NestParentsEgg) { parents = new List <Birb>(); parents.Add(parent1.GetCopy()); parents.Add(parent2.GetCopy()); hatched = false; int species = Random.Range(0, parents.Count); speciesId = parents[species].speciesId; birbSprite = parents[species].birbSprite; BirbColors tempColors = new BirbColors(); //generate birb from parents if it has any, otherwise use defaults //TODO: make better algorithm here for getting parent traits tempColors.head = parents[Random.Range(0, parents.Count)].birbColor.head; tempColors.body = parents[Random.Range(0, parents.Count)].birbColor.body; tempColors.tail = parents[Random.Range(0, parents.Count)].birbColor.tail; tempColors.wings = parents[Random.Range(0, parents.Count)].birbColor.wings; birbColor = tempColors.MutateColors(tempColors); stats.breedTime = parents[Random.Range(0, parents.Count)].stats.breedTime; stats.carryWeight = parents[Random.Range(0, parents.Count)].stats.carryWeight; stats.collectAmount = parents[Random.Range(0, parents.Count)].stats.collectAmount; stats.collectTime = parents[Random.Range(0, parents.Count)].stats.collectTime; stats.growthPercent = 0f; stats.growthRate = parents[Random.Range(0, parents.Count)].stats.growthRate; stats.hatchTime = parents[Random.Range(0, parents.Count)].stats.hatchTime; stats.moveSpeed = parents[Random.Range(0, parents.Count)].stats.moveSpeed; stats.sight = parents[Random.Range(0, parents.Count)].stats.sight; birbLocation = location; return((Birb)this.MemberwiseClone()); //else //{ // //tempColors = GameObject.Find("CrappyDatabas").GetComponent<CrappyDatabase>().GetSpeciesById(speciesId).GetWeightedDefaultColor(); //} //birbImage = GameObject.Find("CrappyDatabas").GetComponent<CrappyDatabase>().GetSpeciesById(speciesId).image; }
public virtual bool TryAddBirb(Birb birb, Enums.BirbLocation location) { switch (location) { case Enums.BirbLocation.Aviary: if (!birb.hatched) { return(false); } break; case Enums.BirbLocation.NestParent: if (!birb.hatched) { return(false); } break; default: break; } openBirbSlot = CheckForOpenBirbSlot(); if (openBirbSlot >= 0) { GameObject go = Instantiate(birbPrefab, Vector3.zero, Quaternion.identity); go.transform.SetParent(birbTransform.GetChild(FindOpenBirbSlot())); go.GetComponent <RectTransform>().offsetMax = Vector2.zero; go.GetComponent <RectTransform>().offsetMin = Vector2.zero; birbList.Add(go.GetComponent <T>()); birbList[openBirbSlot].SetBirbStats(birb); birbList[openBirbSlot].birbLocation = location; return(true); } return(false); }
public virtual void CreateMoveBirbPopup(Birb birb) { mh.OpenMoveBirbModal(birb.birbLocation, birbList.FindIndex(x => x == birb)); }