void AssignMemberClick() { EventSave curE = GM.EM.events.Find(es => es.obj.id == obj.id); TribeGO tribe = GM.TribeGO.GetComponent <TribeGO>(); if (curE != null) { CharacterSave addedchar = tribe.tribeCurrent.members.Find(cs => cs.name == UI_Dropdown_Assign.captionText.text); if (addedchar != null) { if (!curE.cs.Contains(addedchar)) { if (curE.obj.modifiers.ContainsKey("activity")) { switch (curE.obj.modifiers["activity"]) { case "gather": if (!tribe.tribeCurrent.gatherers.Contains(addedchar) && (addedchar.available == true)) { addedchar.available = false; tribe.tribeCurrent.gatherers.Add(addedchar); curE.cs.Add(addedchar); } break; case "fish": if (!tribe.tribeCurrent.fishers.Contains(addedchar) && (addedchar.available == true)) { addedchar.available = false; tribe.tribeCurrent.fishers.Add(addedchar); curE.cs.Add(addedchar); } break; case "hunt": if (!tribe.tribeCurrent.hunters.Contains(addedchar) && (addedchar.available == true)) { addedchar.available = false; tribe.tribeCurrent.hunters.Add(addedchar); curE.cs.Add(addedchar); } break; case "source": if (!tribe.tribeCurrent.sourcers.Contains(addedchar) && (addedchar.available == true)) { addedchar.available = false; tribe.tribeCurrent.sourcers.Add(addedchar); curE.cs.Add(addedchar); } break; default: break; } } } } } }
void RemoveMemberClick() { EventSave curE = GM.EM.events.Find(es => es.obj.id == obj.id); TribeGO tribe = GM.TribeGO.GetComponent <TribeGO>(); if (curE != null) { CharacterSave removechar = tribe.tribeCurrent.members.Find(cs => cs.name == UI_Dropdown_Remove.captionText.text); if (removechar != null) { if (curE.cs.Contains(removechar)) { if (curE.obj.modifiers.ContainsKey("activity")) { switch (curE.obj.modifiers["activity"]) { case "gather": if (tribe.tribeCurrent.gatherers.Contains(removechar) && (removechar.available == false)) // available check not necessary, in case multiple assignments go back here later { removechar.available = true; curE.cs.Remove(removechar); tribe.tribeCurrent.gatherers.Remove(removechar); } break; case "fish": if (tribe.tribeCurrent.fishers.Contains(removechar) && (removechar.available == false)) // available check not necessary, in case multiple assignments go back here later { removechar.available = true; curE.cs.Remove(removechar); tribe.tribeCurrent.fishers.Remove(removechar); } break; case "hunt": if (tribe.tribeCurrent.hunters.Contains(removechar) && (removechar.available == false)) // available check not necessary, in case multiple assignments go back here later { removechar.available = true; curE.cs.Remove(removechar); tribe.tribeCurrent.hunters.Remove(removechar); } break; case "source": if (tribe.tribeCurrent.sourcers.Contains(removechar) && (removechar.available == false)) // available check not necessary, in case multiple assignments go back here later { removechar.available = true; curE.cs.Remove(removechar); tribe.tribeCurrent.sourcers.Remove(removechar); } break; } } } // else no char to remove } // else no char with that name } // no event associated (no char assigned to it) }
void NomadismClick() { if (GM.TribeGO != null) { tribe = GM.tribe; if (tribe.tribeCurrent.nomadism == false) { tribe.tribeCurrent.nomadism = true; NomadismT.text = "Nomadism : On"; } else { tribe.tribeCurrent.nomadism = false; NomadismT.text = "Nomadism : Off"; } } }
void CreateCharClick() { try { TribeGO tribeGO = GameObject.Find("GameManager").GetComponent <GameManager>().TribeGO.GetComponent <TribeGO>(); GameObject Tribe_Members = GameObject.Find("Tribe_Members"); CharacterSave addedChar = new CharacterSave(); addedChar.age.years = Convert.ToInt32(CharAge.text); GameObject.Find("GameManager").GetComponent <GameManager>().CreatePlayer(tribeGO.tribeCurrent.members.Count, CharName.text, addedChar, tribeGO, Tribe_Members); GameObject Charlist = GameObject.Find("UI_CharPanel"); if (Charlist != null) { Charlist.GetComponent <PanelChar>().SetExistingChars(); } Debug.Log("Char : " + CharName.text + " created."); } catch (FormatException) { } }
// public List<GameObject> PrefabTiles = new List<GameObject>(); public GameObject LoadGO(SaveData sdata) { GM = GameObject.Find("GameManager").GetComponent <GameManager>(); GameObject Tribe = new GameObject(sdata.tribesave.tribename); GameObject Tribe_Members = new GameObject("Tribe_Members"); Tribe_Members.AddComponent <SpriteRenderer>(); Tribe_Members.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("Play/Sprite_Camp"); Tribe_Members.AddComponent <BoxCollider2D>(); Tribe_Members.AddComponent <TribeMembersGO>(); GameObject Tribe_Radius = new GameObject("Tribe_Radius"); RatioFactory RF = new RatioFactory(); Tribe_Radius.AddComponent <CircleCollider2D>(); Tribe_Radius.GetComponent <CircleCollider2D>().radius = RF.tribe_sightradius; Tribe_Radius.AddComponent <TribeRadiusGO>(); Tribe_Radius.GetComponent <CircleCollider2D>().isTrigger = true; Tribe_Radius.GetComponent <Transform>().SetParent(Tribe_Members.GetComponent <Transform>()); Tribe_Radius.AddComponent <SpriteRenderer>(); Sprite Radius = Resources.Load <Sprite>("Play/radius"); Tribe_Radius.GetComponent <SpriteRenderer>().sprite = Radius; Tribe_Radius.GetComponent <Transform>().position = new Vector3(Tribe_Radius.GetComponent <Transform>().position.x, Tribe_Radius.GetComponent <Transform>().position.y, GM.ZGround); Tribe_Radius.GetComponent <Transform>().localScale = new Vector3(RF.tribe_sightradius, RF.tribe_sightradius, 1.0f); Tribe_Radius.tag = "radius"; Tribe.AddComponent <TribeGO>(); TribeGO tribego = Tribe.GetComponent <TribeGO>(); GameObject Tribe_Fire = new GameObject("Tribe_Fire"); Tribe_Fire.AddComponent <SpriteRenderer>(); Sprite[] Fire = Resources.LoadAll <Sprite>("Play/Feu_Spritesheet"); Tribe_Fire.GetComponent <SpriteRenderer>().sprite = Fire[0]; Tribe_Members.GetComponent <TribeMembersGO>().fire = Tribe_Fire; Tribe_Members.GetComponent <TribeMembersGO>().firesprites = Fire; Tribe_Members.GetComponent <TribeMembersGO>().radius = Tribe_Radius; Vector3 frontfire = new Vector3(Tribe_Members.GetComponent <Transform>().position.x, Tribe_Members.GetComponent <Transform>().position.y, Tribe_Members.GetComponent <Transform>().position.z - 0.5f); Tribe_Fire.GetComponent <Transform>().position = frontfire; Tribe_Fire.GetComponent <Transform>().SetParent(Tribe_Members.GetComponent <Transform>()); tribego.tribeCurrent = sdata.tribesave; if (sdata.tribesave != null) { if (sdata.tribesave.members.Count > 0) { foreach (CharacterSave chara in sdata.tribesave.members) { GameObject newchar = new GameObject(chara.name); newchar.AddComponent <CharacterGO>(); newchar.GetComponent <CharacterGO>().charCurrent = chara; GameObject body = new GameObject(chara.name + "_Body"); Transform bodyT = body.GetComponent <Transform>(); bodyT.SetParent(newchar.GetComponent <Transform>()); bodyT.position = new Vector3(bodyT.position.x, bodyT.position.y, GM.ZCharacters + 5); body.AddComponent <SpriteRenderer>(); Sprite FaceSprite; if (chara.sexe == 0) { FaceSprite = GM.basesF[chara.Pic_base]; } else { FaceSprite = GM.basesM[chara.Pic_base]; } body.GetComponent <SpriteRenderer>().sprite = FaceSprite; GameObject paints = new GameObject(chara.name + "_Paints"); Transform paintsT = paints.GetComponent <Transform>(); paintsT.SetParent(newchar.GetComponent <Transform>()); paintsT.position = new Vector3(paintsT.position.x, paintsT.position.y, GM.ZCharacters + 4); paints.AddComponent <SpriteRenderer>(); Sprite PaintSprite; if (chara.sexe == 0) { PaintSprite = GM.paintsF[chara.Pic_paints]; } else { PaintSprite = GM.paintsM[chara.Pic_paints]; } paints.GetComponent <SpriteRenderer>().sprite = PaintSprite; GameObject hairs = new GameObject(chara.name + "_Hairs"); Transform hairsT = hairs.GetComponent <Transform>(); hairsT.SetParent(newchar.GetComponent <Transform>()); hairsT.position = new Vector3(hairsT.position.x, hairsT.position.y, GM.ZCharacters + 3); hairs.AddComponent <SpriteRenderer>(); Sprite HairsSprite; if (chara.sexe == 0) { HairsSprite = GM.hairsF[chara.Pic_hairs]; } else { HairsSprite = GM.hairsM[chara.Pic_hairs]; } hairs.GetComponent <SpriteRenderer>().sprite = HairsSprite; GameObject extra = new GameObject(chara.name + "_Extra"); Transform extraT = extra.GetComponent <Transform>(); extraT.SetParent(newchar.GetComponent <Transform>()); extraT.position = new Vector3(extraT.position.x, extraT.position.y, GM.ZCharacters + 2); extra.AddComponent <SpriteRenderer>(); Sprite ExtraSprite; if (chara.sexe == 0) { ExtraSprite = GM.jewelsF[chara.Pic_jewels]; } else { ExtraSprite = GM.beardsM[chara.Pic_beard]; } extra.GetComponent <SpriteRenderer>().sprite = ExtraSprite; GameObject clothes = new GameObject(chara.name + "_Clothes"); Transform clothesT = clothes.GetComponent <Transform>(); clothesT.SetParent(newchar.GetComponent <Transform>()); clothesT.position = new Vector3(clothesT.position.x, clothesT.position.y, GM.ZCharacters + 1); clothes.AddComponent <SpriteRenderer>(); Sprite ClothesSprite; if (chara.sexe == 0) { ClothesSprite = GM.clothesF[chara.Pic_clothes]; } else { ClothesSprite = GM.clothesM[chara.Pic_clothes]; } clothes.GetComponent <SpriteRenderer>().sprite = ClothesSprite; newchar.GetComponent <Transform>().position = Vector3.zero;//(chara.x, chara.y, chara.z); newchar.GetComponent <Transform>().SetParent(Tribe_Members.transform); paints.GetComponent <SpriteRenderer>().enabled = false; extra.GetComponent <SpriteRenderer>().enabled = false; clothes.GetComponent <SpriteRenderer>().enabled = false; hairs.GetComponent <SpriteRenderer>().enabled = false; body.GetComponent <SpriteRenderer>().enabled = false; tribego.CharsGO.Add(newchar); } Vector3 TribePos = new Vector3(sdata.tribesave.TribePosX, sdata.tribesave.TribePosY, GM.ZCharacters); Tribe_Members.GetComponent <Transform>().position = TribePos; } } return(Tribe); }