Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class GKC_RepSystem : MonoBehaviour
- {
- string[] fac = {"Player", "Rome", "Paris", "Berlin"};
- factionSystem factSys;
- public GameObject[] npcs;
- // Start is called before the first frame update
- void Awake()
- {
- Debug.Log("Detecting Faction System Super-Manager");
- factSys = FindObjectOfType(typeof(factionSystem)) as factionSystem;
- if(factSys == null)
- Debug.LogError("System Super-Manager *** NOT FOUND ***");
- factSys.factionList.Clear();
- // First we add the factions to the List
- for (int i = 0; i < fac.Length; i++)
- {
- factionSystem.factionInfo factInfo = new factionSystem.factionInfo();
- factInfo.Name = fac[i];
- factInfo.turnToEnemyIfAttack = true;
- factSys.factionList.Add(factInfo);
- }
- factSys.updateFactionsList();
- // Second we fill the Relation with Factions
- foreach (var item in factSys.factionList)
- {
- item.relationWithFactions.Clear();
- for (int factIndex = 0; factIndex < factSys.factionList.Count; factIndex++)
- {
- if (factSys.factionList[factIndex].Name != item.Name)
- {
- Debug.Log("adding relationship to " + factSys.factionList[factIndex].Name + " about " + fac[factIndex]);
- factionSystem.relationInfo relInfo = new factionSystem.relationInfo();
- relInfo.factionName = fac[factIndex];
- int relInt = Mathf.CeilToInt(Random.Range(0, 100));
- if (relInt < 40)
- relInfo.relation = factionSystem.relationInfo.relationType.enemy;
- else if (relInt > 40 && relInt < 50)
- relInfo.relation = factionSystem.relationInfo.relationType.neutral;
- else
- relInfo.relation = factionSystem.relationInfo.relationType.friend;
- relInfo.factionIndex = factIndex;
- item.relationWithFactions.Add(relInfo);
- }
- }
- }
- // Third Assign NPCs to the factions
- foreach (var npc in npcs)
- {
- npc.GetComponentInChildren<characterFactionManager>().getFactionList();
- //npc.GetComponentInChildren<characterFactionManager>().getFactionList();
- int factionID = Random.Range(1, fac.Length);
- npc.GetComponentInChildren<characterFactionManager>().factionIndex = factionID;
- string name = "Roberto"; //npc.GetComponentInChildren<health>().settings.allyName;
- string faction = npc.GetComponentInChildren<characterFactionManager>().factionName;
- npc.GetComponentInChildren<health>().setAllyNewName(name + " from " + faction);
- npc.GetComponentInChildren<health>().setEnemyNewName(name + " from " + faction);
- }
- }
- private void Start()
- {
- // Third Assign NPCs to the factions
- foreach (var npc in npcs)
- {
- npc.GetComponentInChildren<characterFactionManager>().getFactionList();
- //npc.GetComponentInChildren<characterFactionManager>().getFactionList();
- int factionID = Random.Range(1, fac.Length);
- npc.GetComponentInChildren<characterFactionManager>().factionIndex = factionID;
- string name = "Roberto"; //npc.GetComponentInChildren<health>().settings.allyName;
- string faction = npc.GetComponentInChildren<characterFactionManager>().factionName;
- npc.GetComponentInChildren<health>().setAllyNewName(name + " from " + faction);
- npc.GetComponentInChildren<health>().setEnemyNewName(name + " from " + faction);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement