diff --git a/Dots-RTS-Development/Assets/Scenes/Debug.unity b/Dots-RTS-Development/Assets/Scenes/Debug.unity index b54ecaa..fc24eb0 100644 --- a/Dots-RTS-Development/Assets/Scenes/Debug.unity +++ b/Dots-RTS-Development/Assets/Scenes/Debug.unity @@ -353,12 +353,12 @@ Prefab: - target: {fileID: 224330000714602946, guid: d1ba9546a2394a84a8392d5719b29294, type: 2} propertyPath: m_AnchoredPosition.x - value: 996.8205 + value: 996.6728 objectReference: {fileID: 0} - target: {fileID: 224330000714602946, guid: d1ba9546a2394a84a8392d5719b29294, type: 2} propertyPath: m_AnchoredPosition.y - value: -81.01452 + value: -80.99673 objectReference: {fileID: 0} - target: {fileID: 224330000714602946, guid: d1ba9546a2394a84a8392d5719b29294, type: 2} @@ -621,12 +621,12 @@ Prefab: - target: {fileID: 224330000714602946, guid: d1ba9546a2394a84a8392d5719b29294, type: 2} propertyPath: m_AnchoredPosition.x - value: 334.80585 + value: 334.7636 objectReference: {fileID: 0} - target: {fileID: 224330000714602946, guid: d1ba9546a2394a84a8392d5719b29294, type: 2} propertyPath: m_AnchoredPosition.y - value: -81.01452 + value: -80.99673 objectReference: {fileID: 0} - target: {fileID: 224330000714602946, guid: d1ba9546a2394a84a8392d5719b29294, type: 2} @@ -1673,6 +1673,47 @@ Prefab: m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: d1ba9546a2394a84a8392d5719b29294, type: 2} m_IsPrefabParent: 0 +--- !u!1 &281681152 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 281681154} + - component: {fileID: 281681153} + m_Layer: 0 + m_Name: InterfaceTester (1) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &281681153 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 281681152} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3a609d74af62adc4498b9be5e7c202d3, type: 3} + m_Name: + m_EditorClassIdentifier: + identifier: Two +--- !u!4 &281681154 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 281681152} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 555.54016, y: 458.44223, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 14 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &293755674 GameObject: m_ObjectHideFlags: 0 @@ -2983,12 +3024,12 @@ Prefab: - target: {fileID: 224330000714602946, guid: d1ba9546a2394a84a8392d5719b29294, type: 2} propertyPath: m_AnchoredPosition.x - value: 1261.6265 + value: 1261.4365 objectReference: {fileID: 0} - target: {fileID: 224330000714602946, guid: d1ba9546a2394a84a8392d5719b29294, type: 2} propertyPath: m_AnchoredPosition.y - value: -81.01452 + value: -80.99673 objectReference: {fileID: 0} - target: {fileID: 224330000714602946, guid: d1ba9546a2394a84a8392d5719b29294, type: 2} @@ -3674,12 +3715,12 @@ Prefab: - target: {fileID: 224330000714602946, guid: d1ba9546a2394a84a8392d5719b29294, type: 2} propertyPath: m_AnchoredPosition.x - value: 599.6117 + value: 599.5272 objectReference: {fileID: 0} - target: {fileID: 224330000714602946, guid: d1ba9546a2394a84a8392d5719b29294, type: 2} propertyPath: m_AnchoredPosition.y - value: -81.01452 + value: -80.99673 objectReference: {fileID: 0} - target: {fileID: 224330000714602946, guid: d1ba9546a2394a84a8392d5719b29294, type: 2} @@ -4052,12 +4093,12 @@ Prefab: - target: {fileID: 224330000714602946, guid: d1ba9546a2394a84a8392d5719b29294, type: 2} propertyPath: m_AnchoredPosition.x - value: 732.01465 + value: 731.9091 objectReference: {fileID: 0} - target: {fileID: 224330000714602946, guid: d1ba9546a2394a84a8392d5719b29294, type: 2} propertyPath: m_AnchoredPosition.y - value: -81.01452 + value: -80.99673 objectReference: {fileID: 0} - target: {fileID: 224330000714602946, guid: d1ba9546a2394a84a8392d5719b29294, type: 2} @@ -4407,6 +4448,47 @@ CanvasRenderer: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 1014244533} +--- !u!1 &1030888069 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 1030888071} + - component: {fileID: 1030888070} + m_Layer: 0 + m_Name: InterfaceTester + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1030888070 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1030888069} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3a609d74af62adc4498b9be5e7c202d3, type: 3} + m_Name: + m_EditorClassIdentifier: + identifier: One +--- !u!4 &1030888071 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1030888069} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 555.54016, y: 458.44223, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 13 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &1035893648 Prefab: m_ObjectHideFlags: 0 @@ -5902,12 +5984,12 @@ Prefab: - target: {fileID: 224330000714602946, guid: d1ba9546a2394a84a8392d5719b29294, type: 2} propertyPath: m_AnchoredPosition.x - value: 202.40292 + value: 202.3818 objectReference: {fileID: 0} - target: {fileID: 224330000714602946, guid: d1ba9546a2394a84a8392d5719b29294, type: 2} propertyPath: m_AnchoredPosition.y - value: -81.01452 + value: -80.99673 objectReference: {fileID: 0} - target: {fileID: 224330000714602946, guid: d1ba9546a2394a84a8392d5719b29294, type: 2} @@ -6753,12 +6835,12 @@ Prefab: - target: {fileID: 224330000714602946, guid: d1ba9546a2394a84a8392d5719b29294, type: 2} propertyPath: m_AnchoredPosition.x - value: 864.41754 + value: 864.29095 objectReference: {fileID: 0} - target: {fileID: 224330000714602946, guid: d1ba9546a2394a84a8392d5719b29294, type: 2} propertyPath: m_AnchoredPosition.y - value: -81.01452 + value: -80.99673 objectReference: {fileID: 0} - target: {fileID: 224330000714602946, guid: d1ba9546a2394a84a8392d5719b29294, type: 2} @@ -7381,7 +7463,7 @@ Prefab: - target: {fileID: 224330000714602946, guid: d1ba9546a2394a84a8392d5719b29294, type: 2} propertyPath: m_AnchoredPosition.y - value: -81.01452 + value: -80.99673 objectReference: {fileID: 0} - target: {fileID: 224330000714602946, guid: d1ba9546a2394a84a8392d5719b29294, type: 2} @@ -8132,12 +8214,12 @@ Prefab: - target: {fileID: 224330000714602946, guid: d1ba9546a2394a84a8392d5719b29294, type: 2} propertyPath: m_AnchoredPosition.x - value: 467.20877 + value: 467.14542 objectReference: {fileID: 0} - target: {fileID: 224330000714602946, guid: d1ba9546a2394a84a8392d5719b29294, type: 2} propertyPath: m_AnchoredPosition.y - value: -81.01452 + value: -80.99673 objectReference: {fileID: 0} - target: {fileID: 224330000714602946, guid: d1ba9546a2394a84a8392d5719b29294, type: 2} @@ -8485,12 +8567,12 @@ Prefab: - target: {fileID: 224330000714602946, guid: d1ba9546a2394a84a8392d5719b29294, type: 2} propertyPath: m_AnchoredPosition.x - value: 1129.2234 + value: 1129.0547 objectReference: {fileID: 0} - target: {fileID: 224330000714602946, guid: d1ba9546a2394a84a8392d5719b29294, type: 2} propertyPath: m_AnchoredPosition.y - value: -81.01452 + value: -80.99673 objectReference: {fileID: 0} - target: {fileID: 224330000714602946, guid: d1ba9546a2394a84a8392d5719b29294, type: 2} diff --git a/Dots-RTS-Development/Assets/Scripts/AI/AI_Helper.cs b/Dots-RTS-Development/Assets/Scripts/AI/AI_Helper.cs index df53470..202ae80 100644 --- a/Dots-RTS-Development/Assets/Scripts/AI/AI_Helper.cs +++ b/Dots-RTS-Development/Assets/Scripts/AI/AI_Helper.cs @@ -13,21 +13,21 @@ public static bool IsTargetOf(this Enemy_AI ai, Enemy_AI other) { } public static bool IsAllyOf(this Enemy_AI ai, Enemy_AI other) { - foreach (Enemy_AI temp in ai.getAllies) { - if (ai == other) { + foreach (Enemy_AI temp in other.getAllies) { + if (ai == temp) { return true; } } return false; + } - public static bool IsAllyOf(this Enemy_AI ai, Player player) { - foreach (Enemy_AI temp in ai.getAllies) { - if (ai.getCurrentAiTeam == player.theoreticalTeam) { - return true; - } - } - return false; + //public static bool IsAllyOf(this IAlly it, Player other) { + // return other.IsAllyOF(it); + //} + + public static bool IsAllyOf(this IAlly it, IAlly other) { + return other.IsAllyOF(it); } public static void AddAlly(this Enemy_AI ai, Enemy_AI ally) { diff --git a/Dots-RTS-Development/Assets/Scripts/AI/Enemy_AI.cs b/Dots-RTS-Development/Assets/Scripts/AI/Enemy_AI.cs index e0e5f17..d269236 100644 --- a/Dots-RTS-Development/Assets/Scripts/AI/Enemy_AI.cs +++ b/Dots-RTS-Development/Assets/Scripts/AI/Enemy_AI.cs @@ -2,8 +2,7 @@ using System.Collections.Generic; using UnityEngine; -public class Enemy_AI : MonoBehaviour { - +public class Enemy_AI : MonoBehaviour, IAlly { public bool isActive = true; @@ -478,6 +477,9 @@ private DataHolder GetCellInstances(CellBehaviour referenceCell, Enemy_AI ai) { /// Is the selected process addition or deletion -- not implemented /// The Ai to operate on, default points to the one specified in DataHolder private void ProcessData(DataHolder data, bool is_Adding, Enemy_AI ai = null) { + + this.IsAllyOf(ai); + if (ai == null) { ai = data.getAI; } @@ -534,6 +536,12 @@ private void ProcessData(DataHolder data, bool is_Adding, Enemy_AI ai = null) { } } + public bool IsAllyOF(IAlly other) { + // Enemy_AI ai = (Enemy_AI)other; + // print(ai.aiTeam); + return false; + } + #region Getters and Operators /// /// Get current AIs Team diff --git a/Dots-RTS-Development/Assets/Scripts/AI/Interfaces.cs b/Dots-RTS-Development/Assets/Scripts/AI/Interfaces.cs new file mode 100644 index 0000000..ab7dd27 --- /dev/null +++ b/Dots-RTS-Development/Assets/Scripts/AI/Interfaces.cs @@ -0,0 +1,23 @@ +using UnityEngine; +using System.Collections; +using System; +using System.Collections.Generic; + +public interface IAlly { + bool IsAllyOF(IAlly other); + +} + +public static class IAllyExtension { + public static bool IsAllyOf(this IAlly it, Player p ) { + return p.IsAllyOF(it); + } + + public static bool IsAllyOf(this Enemy_AI p, IAlly it) { + return p.IsAllyOF(it); + } + public static bool IsAllyOf(this IAlly it, IAlly p) { + return p.IsAllyOF(it); + } +} + diff --git a/Dots-RTS-Development/Assets/Scripts/AI/Interfaces.cs.meta b/Dots-RTS-Development/Assets/Scripts/AI/Interfaces.cs.meta new file mode 100644 index 0000000..dd56b67 --- /dev/null +++ b/Dots-RTS-Development/Assets/Scripts/AI/Interfaces.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c6c08c262a52e3645966569a493e330b +timeCreated: 1507315482 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Dots-RTS-Development/Assets/Scripts/Cell/Upgrades/Upgrade.cs b/Dots-RTS-Development/Assets/Scripts/Cell/Upgrades/Upgrade.cs index 5fe6818..2433886 100644 --- a/Dots-RTS-Development/Assets/Scripts/Cell/Upgrades/Upgrade.cs +++ b/Dots-RTS-Development/Assets/Scripts/Cell/Upgrades/Upgrade.cs @@ -134,7 +134,7 @@ public static async Task FillUpgradeSpriteDict() { for (int i = 0; i < values.Length; i++) { if(values[i] != -1) { - print(values[i]); + //print(values[i]); t[i] = GetSprite((Upgrades)values[i]); } } diff --git a/Dots-RTS-Development/Assets/BulkRename.meta b/Dots-RTS-Development/Assets/Scripts/Core Classes/Conversion Classes.meta similarity index 67% rename from Dots-RTS-Development/Assets/BulkRename.meta rename to Dots-RTS-Development/Assets/Scripts/Core Classes/Conversion Classes.meta index ccdb37b..4515cd5 100644 --- a/Dots-RTS-Development/Assets/BulkRename.meta +++ b/Dots-RTS-Development/Assets/Scripts/Core Classes/Conversion Classes.meta @@ -1,7 +1,7 @@ fileFormatVersion: 2 -guid: 15eedef553a4a5c4c9ac76d8104e5807 +guid: 586c9f86e092b7b448eb319ce5445709 folderAsset: yes -timeCreated: 1506764672 +timeCreated: 1507306952 licenseType: Free DefaultImporter: userData: diff --git a/Dots-RTS-Development/Assets/Scripts/Core Classes/Conversions.meta b/Dots-RTS-Development/Assets/Scripts/Core Classes/Conversions.meta new file mode 100644 index 0000000..4ddc084 --- /dev/null +++ b/Dots-RTS-Development/Assets/Scripts/Core Classes/Conversions.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: e917972e5e96bc148b9aa8d7b8238c97 +folderAsset: yes +timeCreated: 1507307784 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Dots-RTS-Development/Assets/Scripts/Core Classes/Conversions/Conversions.cs b/Dots-RTS-Development/Assets/Scripts/Core Classes/Conversions/Conversions.cs new file mode 100644 index 0000000..14714c6 --- /dev/null +++ b/Dots-RTS-Development/Assets/Scripts/Core Classes/Conversions/Conversions.cs @@ -0,0 +1,43 @@ +using UnityEngine; +using System.Collections; +using System.Collections.Generic; + +namespace Conversions { + + public static class BasicConversions { + + public static Vector2 PolarToCartesian(float angle, float r) { + return new Vector2(Mathf.Sin(angle) * (r), Mathf.Cos(angle) * (r)); + } + + public static List> CDToActualClans(Dictionary dict) { + + List> actualClans = new List>(); + + Dictionary.KeyCollection keys = dict.Keys; + foreach (Cell.enmTeam j in keys) { + AIHolder value; + dict.TryGetValue(j, out value); + List clanJ = new List(value.allies); + clanJ.Add(j); + clanJ.Sort(); + bool newClan = true; + foreach (List clan in actualClans) { + + if (clanJ.Contains(clan[0])) { + newClan = false; + break; + } + + } + if (newClan && clanJ.Count > 1) { + actualClans.Add(clanJ); + } + + } + return actualClans; + + } + + } +} \ No newline at end of file diff --git a/Dots-RTS-Development/Assets/Scripts/Core Classes/Conversions/Conversions.cs.meta b/Dots-RTS-Development/Assets/Scripts/Core Classes/Conversions/Conversions.cs.meta new file mode 100644 index 0000000..130ff3b --- /dev/null +++ b/Dots-RTS-Development/Assets/Scripts/Core Classes/Conversions/Conversions.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a5f5363ace712b24f8187bf9b5dbdbc0 +timeCreated: 1507307784 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Dots-RTS-Development/Assets/Scripts/Core Classes/Initialize_AI.cs b/Dots-RTS-Development/Assets/Scripts/Core Classes/Initialize_AI.cs index 3a2ca4e..c080c90 100644 --- a/Dots-RTS-Development/Assets/Scripts/Core Classes/Initialize_AI.cs +++ b/Dots-RTS-Development/Assets/Scripts/Core Classes/Initialize_AI.cs @@ -1,8 +1,10 @@ using System.Collections.Generic; using UnityEngine; +using Conversions; public class Initialize_AI : MonoBehaviour { + public static List> clanList = new List>(); public GameObject playerData; public bool[] initAIs = new bool[8] { false, false, false, false, false, false, false, false }; @@ -25,46 +27,10 @@ private void Start() { //Goes though all the cells and creates an AI for each team. public void StartAiInitialization(Dictionary clanDict) { + clanList = BasicConversions.CDToActualClans(clanDict); foreach (Cell c in PlayManager.cells) { - //If cell is enemy create ai for that enemy - Only once if ((int)c.cellTeam >= 2) { SetAis((int)c.cellTeam - 2, c.cellTeam); - - //print((int)c.cellTeam + " " + c.gameObject.name); - //switch ((int)c.cellTeam) { - // case 2: { - // SetAis(0, c.cellTeam); - // break; - // } - // case 3: { - // SetAis(1, c.cellTeam); - // break; - // } - // case 4: { - // SetAis(2, c.cellTeam); - // break; - // } - // case 5: { - // SetAis(3, c.cellTeam); - // break; - // } - // case 6: { - // SetAis(4, c.cellTeam); - // break; - // } - // case 7: { - // SetAis(5, c.cellTeam); - // break; - // } - // case 8: { - // SetAis(6, c.cellTeam); - // break; - // } - // case 9: { - // SetAis(7, c.cellTeam); - // break; - // } - //} } } diff --git a/Dots-RTS-Development/Assets/Scripts/Core Classes/Player.cs b/Dots-RTS-Development/Assets/Scripts/Core Classes/Player.cs index ace5f4e..7a8bb00 100644 --- a/Dots-RTS-Development/Assets/Scripts/Core Classes/Player.cs +++ b/Dots-RTS-Development/Assets/Scripts/Core Classes/Player.cs @@ -1,14 +1,61 @@ using UnityEngine; using System.Collections.Generic; +using System; -public class Player : MonoBehaviour { +public class Player : MonoBehaviour,IAlly { + //Cell.enmTeam playerTeam; + //List alliesOfPlayer; + //List targetsOfPlayer; + + public ExtraPlayer pl1; + public ExtraPlayer pl2; + public ExtraPlayer pl3; + public Player pl4; + + public List listOfAlly = new List(); public List playerCells = new List(); + //private void Start() { + // foreach (CellBehaviour cell in PlayManager.cells) { + // if (cell.cellTeam == Cell.enmTeam.ALLIED) { + // playerCells.Add(cell); + // } + // } + //} private void Start() { - foreach (CellBehaviour cell in PlayManager.cells) { - if(cell.cellTeam == Cell.enmTeam.ALLIED) { - playerCells.Add(cell); + listOfAlly.Add(pl1); + //listOfAlly.Add(pl2); + //listOfAlly.Add(pl3); + //listOfAlly.Add(pl4); + } + + + public bool IsAllyOF(IAlly other) { + //ExtraPlayer playah = (ExtraPlayer)other; + //playah.PRintCrap(); + foreach (IAlly ally in listOfAlly) { + + if (ally == other) { + try { + print(((Enemy_AI)other).name); + } + catch(Exception e) { + Debug.Log(e); + } + print(((ExtraPlayer)other).name); + + print("Found a match" + ally + " " + other); + return true; + } + else { + print("NOG"); } + } + return false; + } + + public void PRintCrap() { + //print("Stuff yaay"); } } \ No newline at end of file diff --git a/Dots-RTS-Development/Assets/Scripts/Debug/ExtraPlayer.cs b/Dots-RTS-Development/Assets/Scripts/Debug/ExtraPlayer.cs new file mode 100644 index 0000000..c7e11cd --- /dev/null +++ b/Dots-RTS-Development/Assets/Scripts/Debug/ExtraPlayer.cs @@ -0,0 +1,23 @@ +using UnityEngine; +using System.Collections; +using System; + +public class ExtraPlayer : MonoBehaviour, IAlly { + + public bool AMIANALLY; + public Player MATE; + private void Start() { + if (this.IsAllyOf(MATE)) { + print(this.name + " Is an Ally of " + MATE.name); + } + } + + public bool IsAllyOF(IAlly other) { + return AMIANALLY; + } + + + public void PRintCrap() { + //print("Stuff yaay"); + } +} diff --git a/Dots-RTS-Development/Assets/Scripts/Debug/ExtraPlayer.cs.meta b/Dots-RTS-Development/Assets/Scripts/Debug/ExtraPlayer.cs.meta new file mode 100644 index 0000000..da6fd1e --- /dev/null +++ b/Dots-RTS-Development/Assets/Scripts/Debug/ExtraPlayer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e97bbb31237b7014d9667ad9549a763e +timeCreated: 1507317373 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Dots-RTS-Development/Assets/Scripts/Debug/Testing.unity b/Dots-RTS-Development/Assets/Scripts/Debug/Testing.unity index c03dbe1..47a8cb9 100644 --- a/Dots-RTS-Development/Assets/Scripts/Debug/Testing.unity +++ b/Dots-RTS-Development/Assets/Scripts/Debug/Testing.unity @@ -214,6 +214,51 @@ BoxCollider2D: serializedVersion: 2 m_Size: {x: 100, y: 100} m_EdgeRadius: 0 +--- !u!1 &44057241 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 44057243} + - component: {fileID: 44057242} + m_Layer: 0 + m_Name: Player 1 Containing Extra 1 + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &44057242 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 44057241} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: af84bbf654dca3646be97ee7b9909054, type: 3} + m_Name: + m_EditorClassIdentifier: + pl1: {fileID: 1510027169} + pl2: {fileID: 0} + pl3: {fileID: 0} + pl4: {fileID: 0} + playerCells: [] +--- !u!4 &44057243 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 44057241} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 68.81429, y: 106.38462, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 5 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &199560451 GameObject: m_ObjectHideFlags: 0 @@ -397,7 +442,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!114 &356373696 MonoBehaviour: m_ObjectHideFlags: 0 @@ -869,6 +914,96 @@ CanvasRenderer: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 889168882} +--- !u!1 &1131969724 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 1131969726} + - component: {fileID: 1131969725} + m_Layer: 0 + m_Name: Player 3 Containing Extra 2 + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1131969725 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1131969724} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: af84bbf654dca3646be97ee7b9909054, type: 3} + m_Name: + m_EditorClassIdentifier: + pl1: {fileID: 1742728871} + pl2: {fileID: 0} + pl3: {fileID: 0} + pl4: {fileID: 0} + playerCells: [] +--- !u!4 &1131969726 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1131969724} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 68.81429, y: 106.38462, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 7 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1252788155 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 1252788157} + - component: {fileID: 1252788156} + m_Layer: 0 + m_Name: Player 2 Containing Extra 1 + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1252788156 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1252788155} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: af84bbf654dca3646be97ee7b9909054, type: 3} + m_Name: + m_EditorClassIdentifier: + pl1: {fileID: 1510027169} + pl2: {fileID: 0} + pl3: {fileID: 0} + pl4: {fileID: 0} + playerCells: [] +--- !u!4 &1252788157 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1252788155} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 68.81429, y: 106.38462, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 6 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1279106454 GameObject: m_ObjectHideFlags: 0 @@ -885,7 +1020,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!114 &1279106455 MonoBehaviour: m_ObjectHideFlags: 0 @@ -1111,6 +1246,48 @@ CanvasRenderer: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 1448316035} +--- !u!1 &1510027168 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 1510027170} + - component: {fileID: 1510027169} + m_Layer: 0 + m_Name: Extra 1 Containing Player 3 + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1510027169 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1510027168} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e97bbb31237b7014d9667ad9549a763e, type: 3} + m_Name: + m_EditorClassIdentifier: + AMIANALLY: 0 + MATE: {fileID: 1131969725} +--- !u!4 &1510027170 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1510027168} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 68.81429, y: 106.38462, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 8 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1719003458 GameObject: m_ObjectHideFlags: 0 @@ -1208,6 +1385,48 @@ RectTransform: m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0, y: 0} +--- !u!1 &1742728870 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 1742728872} + - component: {fileID: 1742728871} + m_Layer: 0 + m_Name: Extra 2 Containing Player 3 + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1742728871 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1742728870} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e97bbb31237b7014d9667ad9549a763e, type: 3} + m_Name: + m_EditorClassIdentifier: + AMIANALLY: 1 + MATE: {fileID: 1131969725} +--- !u!4 &1742728872 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1742728870} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 68.81429, y: 106.38462, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 9 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1762754327 GameObject: m_ObjectHideFlags: 0 @@ -1560,6 +1779,10 @@ Prefab: propertyPath: m_RootOrder value: 4 objectReference: {fileID: 0} + - target: {fileID: 1379150265939502, guid: 5cc6ffdc88999d84ebf6db30430568d1, type: 2} + propertyPath: m_IsActive + value: 0 + objectReference: {fileID: 0} m_RemovedComponents: [] m_ParentPrefab: {fileID: 100100000, guid: 5cc6ffdc88999d84ebf6db30430568d1, type: 2} m_IsPrefabParent: 0 diff --git a/Dots-RTS-Development/Assets/Scripts/LevelEditor/TeamSetup.cs b/Dots-RTS-Development/Assets/Scripts/LevelEditor/TeamSetup.cs index dd08d66..f96a1cc 100644 --- a/Dots-RTS-Development/Assets/Scripts/LevelEditor/TeamSetup.cs +++ b/Dots-RTS-Development/Assets/Scripts/LevelEditor/TeamSetup.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; +using Conversions; public class TeamSetup : MonoBehaviour { @@ -38,6 +39,7 @@ void OnEnable() { print(GameObject.Find("Canvas").GetComponent().scaleFactor); roundTableR = ((roundTable.rect.width * 0.5f)) - teamGOPrefab.GetComponent().sizeDelta.x; + for (int i = 0; i < core.teamList.Count; i++) { GameObject newTeamBox = Instantiate(teamGOPrefab, roundTable.transform); @@ -52,7 +54,7 @@ void OnEnable() { float nextAngle = 0; for (int i = 0; i < teamBoxes.Count; i++) { - teamBoxes[i].transform.localPosition = AngleToPos(nextAngle); + teamBoxes[i].transform.localPosition = BasicConversions.PolarToCartesian(nextAngle, roundTableR); teamBoxes[i].myAngle = (nextAngle); nextAngle += diffAngle; @@ -162,14 +164,7 @@ void BindTwo(Cell.enmTeam first, Cell.enmTeam second) { } } - bool AlreadyIsInAllyHolder(AIHolder list, Cell.enmTeam value) { - for (int i = 0; i < list.allies.Count; i++) { - if (list.allies[i] == value) { - return true; - } - } - return false; - } + void CheckAndAddOtherTeams(Cell.enmTeam firstTeam, Cell.enmTeam secondTeam) { AIHolder firstTeamFriends; @@ -209,57 +204,17 @@ static void DestroyAllInList(List list) { Destroy(list[i]); } } - List> CDToActualClans(Dictionary dict) { - List> actualClans = new List>(); - - Dictionary.KeyCollection keys = dict.Keys; - foreach (Cell.enmTeam j in keys) { - //print(j + " Key"); - AIHolder value; - clanDict.TryGetValue(j, out value); - List clanJ = new List(value.allies); - clanJ.Add(j); - clanJ.Sort(); - - - bool newClan = true; - foreach (List clan in actualClans) { - //print(" one clan with [0] = " + clan[0]); - if (clanJ.Contains(clan[0])) { - newClan = false; - break; - } - - } - if (newClan && clanJ.Count > 1) { - actualClans.Add(clanJ); - } - - } - return actualClans; - } public void UpdateRoundTableVisuals() { - //Dictionary.KeyCollection keysDebug = clanDict.Keys; - //foreach (Cell.enmTeam team in keysDebug) { - // AIHolder holder = new AIHolder(); - // clanDict.TryGetValue(team, out holder); - // string s = " "; - // foreach (Cell.enmTeam ally in holder.allies) { - // s += (ally + " "); - // } - // print("Team: " + team + " has allies" + s); - //} - - DestroyAllInList(bgList); List newList = new List(teamBoxes); float angle = 0; - List> actualClans = CDToActualClans(clanDict); + + List> actualClans = BasicConversions.CDToActualClans(clanDict); for (int i = 0; i < actualClans.Count; i++) { GameObject bg = Instantiate(clanBG, roundTable); bgList.Add(bg); @@ -278,7 +233,7 @@ public void UpdateRoundTableVisuals() { foreach (TeamBox t in teamBoxes) { if (t.team == j) { //Debug.Log(t.team); - t.transform.localPosition = AngleToPos(angle); + t.transform.localPosition = BasicConversions.PolarToCartesian(angle, roundTableR); t.myAngle = angle; t.AllThingsSet(); img.fillAmount += 1f / teamBoxes.Count; @@ -292,7 +247,7 @@ public void UpdateRoundTableVisuals() { } foreach (TeamBox t in newList) { - t.transform.localPosition = AngleToPos(angle); + t.transform.localPosition = BasicConversions.PolarToCartesian(angle, roundTableR); t.myAngle = angle; t.AllThingsSet(); angle += diffAngle; @@ -301,11 +256,18 @@ public void UpdateRoundTableVisuals() { } - Vector2 AngleToPos(float angle) { - return new Vector2(Mathf.Sin(angle) * (roundTableR), Mathf.Cos(angle) * (roundTableR)); + + public static bool AlreadyIsInAllyHolder(AIHolder list, Cell.enmTeam value) { + for (int i = 0; i < list.allies.Count; i++) { + if (list.allies[i] == value) { + return true; + } + } + return false; } + public int MySpawnsIndexFromTeam(Cell.enmTeam team) { int output = -1; for (int i = 0; i < teamBoxes.Count; i++) { @@ -320,6 +282,7 @@ public int MySpawnsIndexFromTeam(Cell.enmTeam team) { } return output; } + public int MySpawnsIndexFromAngle(float RawAngle) { float angle = RawAngle; if (Mathf.Round(angle * 10) / 10 >= Mathf.Round(2 * Mathf.PI * 10) / 10) { @@ -373,7 +336,7 @@ public int MySpawnsIndexFromAngle(float RawAngle) { newDict.Add(team, newAiHolder); } - + return newDict;