123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using Sirenix.OdinInspector;
- namespace KairoEngine.CharacterSystem
- {
- public class FactionRelation
- {
- public string title;
- public bool isEnemy = true;
- public FactionRelation(string title, bool isEnemy)
- {
- this.title = title;
- this.isEnemy = isEnemy;
- }
- }
-
- [CreateAssetMenu(fileName = "Faction", menuName = "KairoEngine/Faction", order = 4)]
- public class Faction : SerializedScriptableObject
- {
- public string title;
- public bool defaultRelationIsEnemy = true;
- public List<FactionRelation> _relations = new List<FactionRelation>();
- private List<FactionRelation> relations = new List<FactionRelation>();
- public void Initialize()
- {
- relations = new List<FactionRelation>();
- foreach (var relation in _relations)
- {
- FactionRelation newRelation = new FactionRelation(relation.title, relation.isEnemy);
- relations.Add(newRelation);
- }
- }
- public bool IsEnemy(string factionName)
- {
- if(factionName == title) return false;
- for (int i = 0; i < relations.Count; i++)
- {
- if(relations[i].title == factionName) return relations[i].isEnemy;
- }
- return defaultRelationIsEnemy;
- }
- }
- }
|