void Possess(Caster caster, VillagerAI villager) { if (OnPossess != null) { OnPossess(); } villager.Possess(caster.transform); SoundManager.Instance.CreatePlayAndDestroy(SoundManager.Instance.possessSound, 1.0f); var pv = caster.GetComponent <PossessedVillagers>(); if (!villager.isInquisitor) { if (!pv.possessedVillagers.Contains(villager)) { pv.possessedVillagers.Add(villager); } } else { if (!pv.inquisitors.Contains(villager)) { pv.inquisitors.Add(villager); } } }
public void SpawnInquisitor(GoldBarCarry carrier) { var inqList = carrier.GetComponent <PossessedVillagers>().inquisitors; VillagerAI inq = Instantiate(inquisitorPrefab, spawnPoint.position, Quaternion.identity); inq.SetTargetTrans(carrier.transform); inqList.Add(inq); }
/// <summary> /// Initialize the Villager with the ability to move to given targets and the villagerAI. /// Set his state to THINKING for further decision making. /// </summary> void Start() { villagerName = RandomVillagerNamer.GetRandomName(); villagerAI = GetComponent <VillagerAI>(); villagerMovement = GetComponent <VillagerMovement>(); villagerState = VillagerState.THINKING; }
public void Sacrifice(VillagerAI target) { target.GetComponent <SacrificeParticles>().SpawnSacrificeParticles(); Destroy(target.gameObject); InfluenceManager.Instance.AddInfluence(influencePerSacrifice); SoundManager.Instance.CreatePlayAndDestroy(SoundManager.Instance.sacrificeSounds[UnityEngine.Random.Range(0, 2)], 0.1f); OnSacrifice?.Invoke(); }
/// <summary> /// Try to add a Villager to the house as Resident /// </summary> /// <param name="villager">The Villager</param> /// <returns>true if successful</returns> public bool AddResident(VillagerAI villager) { if (m_Residents.Count < m_MaxResidents) { m_Residents.Add(villager); return(true); } return(false); }
public int GetVillagerIndex(VillagerAI villager) { for (int i = 0; i < m_VillagerList.Count; i++) { if (m_VillagerList[i] == villager) { return(i); } } return(-1); }
private GameObject GenerateVillager(int cityHallLevel) { string prefabPath = ActorPrefabConfig.Instance.GetVillagerActorPrefab(cityHallLevel); GameObject villagerPrefab = Resources.Load(prefabPath) as GameObject; GameObject villager = GameObject.Instantiate(villagerPrefab) as GameObject; VillagerAI villagerAI = villager.GetComponent <VillagerAI>(); villagerAI.MapData = this.m_MapData; villagerAI.SceneHelper = this.m_SceneHelper; villagerAI.Spawn(); return(villager); }
// Update is called once per frame void Update() { if (building) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); Vector3 temp; RaycastHit hit; if (Physics.Raycast(ray, out hit, 100f, 9)) { temp = hit.point; clone.transform.position = temp; clone.transform.rotation = Quaternion.FromToRotation(Vector3.up, hit.normal); } if (Input.GetMouseButtonDown(0)) { Debug.Log(clone.transform.position); Place(clone); Debug.Log("Placing"); } else if (Input.GetMouseButtonDown(1)) { building = false; clone.SetActive(false); Debug.Log("Cancel"); } } if (Input.GetMouseButtonDown(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); Vector3 temp; RaycastHit hit; if (Physics.Raycast(ray, out hit)) { temp = hit.point; } Debug.Log(hit.collider.name); if (hit.collider.tag == "Villager") { VillagerAI.Select(hit.collider.gameObject); } } }
public void SendRunAway() { List <IBuildingInfo> builderHuts = this.m_BattleSceneHelper.GetBuildings(BuildingType.BuilderHut); BuildingType[] disappearBuildings = ActorPrefabConfig.Instance.GetComponent <ActorConfig>().VillagerDisappearBuildingTypes; HashSet <BuildingType> buildings = new HashSet <BuildingType>(); foreach (BuildingType building in disappearBuildings) { buildings.Add(building); } foreach (KeyValuePair <int, GameObject> builder in this.m_Builders) { BuilderAI builderAI = builder.Value.GetComponent <BuilderAI>(); builderAI.RunAway(builderHuts); } foreach (GameObject villager in this.m_Villagers) { VillagerAI villagerAI = villager.GetComponent <VillagerAI>(); villagerAI.RunAway(buildings); } }
/// <summary> /// Deregister a Villager /// </summary> /// <param name="villager">The Villager</param> public void DeregisterVillager(VillagerAI villager) { m_VillagerList.Remove(villager); }
/// <summary> /// Register a Villager /// </summary> /// <param name="villager">The Villager</param> public void RegisterVillager(VillagerAI villager) { m_VillagerList.Add(villager); }
/// <summary> /// Remove this Villager from the House /// </summary> /// <param name="villager">The Villager</param> /// <returns>true if successful</returns> public bool RemoveResident(VillagerAI villager) { return(m_Residents.Remove(villager)); }