ODDA36T4D3TGJS44ZBETQAT7PTIPIDSPVOHGW4K2CCCB6PUQ3FYQC
fileFormatVersion: 2
guid: 8bfd2649a97be2c45b604a36f9309fad
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 500eca3840d24134cafb0fa090840dfa
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b9a946ca18962744d9ee6415c5f8551d, type: 3}
m_Name: UnitManager
m_EditorClassIdentifier:
fileFormatVersion: 2
guid: b9a946ca18962744d9ee6415c5f8551d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: -10
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class UnitManager : MonoBehaviour
{
public static UnitManager Instance {get; private set;}
private List<Unit> unitList;
private List<Unit> enemyUnitList;
private List<Unit> friendlyUnitList;
private void Start() {
Unit.OnAnyUnitDead += Unit_OnAnyUnitDead;
Unit.OnAnyUnitSpawned += Unit_OnAnyUnitSpawned;
}
private void Awake() {
if (Instance != null)
{
Debug.LogError("There's more than one UnitActionSystem" + transform + " - " + Instance);
Destroy(gameObject);
return;
}
Instance = this;
unitList = new List<Unit>();
enemyUnitList = new List<Unit>();
friendlyUnitList = new List<Unit>();
}
private void Unit_OnAnyUnitSpawned(object sender, EventArgs empty) {
Unit unit = sender as Unit;
if (unit.IsEnemy()) {
enemyUnitList.Add(unit);
} else {
friendlyUnitList.Add(unit);
}
unitList.Add(unit);
}
private void Unit_OnAnyUnitDead(object sender, EventArgs empty) {
Unit unit = sender as Unit;
if (unit.IsEnemy()) {
enemyUnitList.Remove(unit);
} else {
friendlyUnitList.Remove(unit);
}
unitList.Remove(unit);
}
public List<Unit> GetUnitList() {
return unitList;
}
public List<Unit> GetEnemyUnitList() {
return enemyUnitList;
}
public List<Unit> GetFriendlyUnitList() {
return friendlyUnitList;
}
}
fileFormatVersion: 2
guid: 70db6889caa5ebf4fad46968df4c7e51
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: b9a946ca18962744d9ee6415c5f8551d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: -50
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName = "New UnitManager", menuName = "ScriptableObjects/UnitManager")]
public class UnitManager : ScriptableObject
{
private List<Unit> unitList;
private List<Unit> enemyUnitList;
private List<Unit> friendlyUnitList;
private void Awake() {
unitList = new List<Unit>();
enemyUnitList = new List<Unit>();
friendlyUnitList = new List<Unit>();
}
private void OnEnable() {
Unit.OnAnyUnitDead += Unit_OnAnyUnitDead;
Unit.OnAnyUnitSpawned += Unit_OnAnyUnitSpawned;
}
private void OnDisable() {
Unit.OnAnyUnitDead -= Unit_OnAnyUnitDead;
Unit.OnAnyUnitSpawned -= Unit_OnAnyUnitSpawned;
}
private void Unit_OnAnyUnitSpawned(object sender, EventArgs empty) {
Unit unit = sender as Unit;
if (unit.IsEnemy()) {
enemyUnitList.Add(unit);
} else {
friendlyUnitList.Add(unit);
}
unitList.Add(unit);
}
private void Unit_OnAnyUnitDead(object sender, EventArgs empty) {
Debug.Log("UnitManager Unit_OnAnyUnitDead");
Unit unit = sender as Unit;
if (unit.IsEnemy()) {
enemyUnitList.Remove(unit);
} else {
friendlyUnitList.Remove(unit);
}
unitList.Remove(unit);
}
public List<Unit> GetUnitList() {
return unitList;
}
public List<Unit> GetEnemyUnitList() {
return enemyUnitList;
}
public List<Unit> GetFriendlyUnitList() {
return friendlyUnitList;
}
}
--- !u!1 &1522129062
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1522129064}
- component: {fileID: 1522129063}
m_Layer: 0
m_Name: UnitManager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1522129063
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1522129062}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b9a946ca18962744d9ee6415c5f8551d, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &1522129064
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1522129062}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 21
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}