void InstantiateMonsterAtPosition(Transform trans, Monster monster) { GameObject model = creaturePrefabManager.GetMonster(monster.nID); GameObject monsterInstantiated = Instantiate(monsterPrefab, Vector3.zero, monsterPrefab.transform.localRotation) as GameObject; GameObject monsterModel = Instantiate(model, Vector3.zero, monsterPrefab.transform.localRotation) as GameObject; monsterInstantiated.transform.parent = trans; monsterInstantiated.transform.localPosition = Vector3.zero; monsterModel.transform.parent = monsterInstantiated.transform; // monsterInstantiated.transform.parent = rootMonsters; monsterInstantiated.transform.localScale = new Vector3(1f, 1f, 1f); monsterModel.transform.localPosition = Vector3.zero; MouseOverRecrute scripMouseOver = monsterModel.transform.GetChild(0).gameObject.AddComponent <MouseOverRecrute>(); monsterModel.transform.GetChild(0).gameObject.AddComponent <BoxCollider>(); scripMouseOver.fightherObj = monsterInstantiated; scripMouseOver.fighterUI = monsterInstantiated.GetComponent <FighterUI>(); scripMouseOver.fighterUI.fighter = monster; // Get Model monster of type id // Set script monster }
// Update is called once per frame void Update() { if (currentFighter != cm.currentFighter) { currentFighter = cm.currentFighter; foreach (Transform child in currentMeshHolder.transform) { Destroy(child.gameObject); } if (currentFighter.eCreatureType == CreatureType.Human) { currentMeshHolder.transform.position = positionHuman.transform.position; // GameObject gHuman = prefabManager.GetHuman(currentFighter.nID); GameObject gHuman = prefabManager.GetHumanOfSex(currentFighter.nID, currentFighter.sexe); int layer = LayerMask.NameToLayer("UI"); ModelHumainUI modelUI = gHuman.GetComponent <ModelHumainUI>(); ModelHumainUI modelCurrent = ((Human)currentFighter).currentUI.gameObject.GetComponentInChildren <ModelHumainUI>(); modelUI.SetCaract(modelCurrent.caractCheveux); GameObject instanceHuman = Instantiate(gHuman, Vector3.zero, Quaternion.Euler(0, 90, 0)) as GameObject; instanceHuman.transform.parent = currentMeshHolder.transform; instanceHuman.transform.localPosition = Vector3.zero; instanceHuman.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f); } else { currentMeshHolder.transform.position = positionMonster.transform.position; GameObject gMonster = prefabManager.GetMonster(currentFighter.nID); ModelMonsterUI modelUI = gMonster.GetComponent <ModelMonsterUI>(); ModelMonsterUI modelCurrent = ((Monster)currentFighter).currentUI.gameObject.GetComponentInChildren <ModelMonsterUI>(); modelUI.SetCaract(modelCurrent.caractMonster); GameObject instanceMonster = Instantiate(gMonster, Vector3.zero, Quaternion.Euler(0, 90, 0)) as GameObject; instanceMonster.transform.parent = currentMeshHolder.transform; instanceMonster.transform.localPosition = Vector3.zero; instanceMonster.transform.localScale = new Vector3(-0.5f, 0.5f, 0.5f); } } if (cm.bCombatEnded && !processedEnd) { processedEnd = true; if (cm.bSpecialFight && cm.specialType == SpecialType.Bard) { foreach (Transform child in currentMeshHolder.transform) { Destroy(child.gameObject); } currentMeshHolder.transform.position = positionHuman.transform.position; GameObject gHuman = prefabManager.GetSpecial(31); // ModelHumainUI modelUI = gHuman.GetComponent<ModelHumainUI>(); // ModelHumainUI modelCurrent = ((Human)currentFighter).currentUI.gameObject.GetComponentInChildren<ModelHumainUI>(); // modelUI.SetCaract(modelCurrent.caractCheveux); GameObject instanceHuman = Instantiate(gHuman, Vector3.zero, Quaternion.Euler(0, 90, 0)) as GameObject; instanceHuman.transform.parent = currentMeshHolder.transform; instanceHuman.transform.localPosition = Vector3.zero; instanceHuman.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f); } } if (talk.active == true) { currentMeshHolder.SetActive(true); foreach (Transform child in currentMeshHolder.transform) { child.gameObject.SetActive(true); } } else { foreach (Transform child in currentMeshHolder.transform) { child.gameObject.SetActive(false); } } }
void CheckDeadFighters() { foreach (Order order in combatOrder) { if (order.fighter.IsDead()) { AkSoundEngine.SetSwitch("Tension", "T4", gameObject); combatOrder.Remove(order); } } for (int i = 0; i < combatOrder.Count; i++) { if (combatOrder[i].fighter == currentFighter && combatOrder[i].nInitiative == currentInitiative) { currentFighterIndex = i; break; } } if (monsterGroupFighter.lFighters.Count < 4 && !monsterGroupFighter.SomeTryToRun()) { if (caravane.lFighters.Count >= 4) { Fighter lastDeadFighter = monsterGroupFighter.ReplacDeadFighter(); GameObject prefab = prefabMonster; CreatureType creatureType = CreatureType.Monster; Fighter fighter = caravane.lFighters[3]; fighter.bTryToescape = false; GameObject g = Instantiate(prefab, fighterMouvementManager.SpawnPosition, Quaternion.Euler(0, 90, 0)) as GameObject; GameObject mo; GameObject model = creaturePrefabManager.GetMonster(fighter.nID); mo = Instantiate(model, Vector3.zero, Quaternion.Euler(0, 270, 0)) as GameObject; mo.transform.parent = g.transform; mo.transform.localPosition = Vector3.zero; mo.transform.localScale = new Vector3(0.3f, 0.3f, 0.3f); mo.transform.GetChild(0).gameObject.AddComponent <BoxCollider>(); g.GetComponent <FighterUI>().fighter = fighter; monsterGroupFighter.lFighters.Add(fighter); g.transform.parent = GameObject.FindGameObjectWithTag("Monsters").transform; g.name = fighter.sName; MouseOverCreature mouseOver = mo.transform.GetChild(0).gameObject.AddComponent <MouseOverCreature>(); mouseOver.fighterUI = g.GetComponent <FighterUI>(); g.GetComponent <FighterUI>().fighterRenderer = mouseOver.gameObject.GetComponent <Renderer>(); fighterMouvementManager.lastDeadFighterPosition = lastDeadFighter.currentUI.gameObject.transform.position; fighterMouvementManager.SpawnMonster(g); fighterMouvementManager.lastDeadFighterPosition = lastDeadFighter.currentUI.transform.position; g.transform.position = fighterMouvementManager.spawn.position; Order order = new Order(fighter, 6); combatOrder.Add(order); } } }