Add random point moving.
This commit is contained in:
8
Assets/Scripts/Bots/Behaviours.meta
generated
8
Assets/Scripts/Bots/Behaviours.meta
generated
@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9fbac871417fccb40831b0f935247a29
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,17 +0,0 @@
|
||||
using Unity;
|
||||
using UnityEngine;
|
||||
public abstract class BaseBehaviour
|
||||
{
|
||||
protected NPC thisNPC;
|
||||
protected IDoActivity DoActivity;
|
||||
|
||||
protected BaseBehaviour(NPC npc)
|
||||
{
|
||||
thisNPC = npc;
|
||||
}
|
||||
|
||||
public void DoAction()
|
||||
{
|
||||
DoActivity?.DoActivity();
|
||||
}
|
||||
}
|
11
Assets/Scripts/Bots/Behaviours/BaseBehaviour.cs.meta
generated
11
Assets/Scripts/Bots/Behaviours/BaseBehaviour.cs.meta
generated
@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 60bdb2d866ca9324cbe3639e7c47ae23
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 362d340e6754883459f3dc89c9ddc476
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,8 +0,0 @@
|
||||
public class DumbAttacker : BaseBehaviour
|
||||
{
|
||||
public DumbAttacker(NPC npc) : base(npc)
|
||||
{
|
||||
DoActivity = new DumbAttackerBehaviour();
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 138d13d4fe8a06444acb1da6bfc55aa7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,7 +0,0 @@
|
||||
public class DumbDefender : BaseBehaviour
|
||||
{
|
||||
public DumbDefender(NPC npc) : base(npc)
|
||||
{
|
||||
DoActivity = new DumbDefenderBehaviour();
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 64552bae354dc614d8012f07511a51e8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,7 +0,0 @@
|
||||
public class Human : BaseBehaviour
|
||||
{
|
||||
public Human(NPC npc) : base(npc)
|
||||
{
|
||||
DoActivity = new HumanBehaviour();
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 59d3d253756147e469e418971625a04c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 93364cc95c8c9764e83d70fcce9da482
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,9 +0,0 @@
|
||||
using UnityEngine;
|
||||
class DumbAttackerBehaviour : IDoActivity
|
||||
{
|
||||
public void DoActivity()
|
||||
{
|
||||
Debug.Log("I do attackers things!");
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d2cc7b0640887454e96d42f6bd066750
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,9 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
class DumbDefenderBehaviour : IDoActivity
|
||||
{
|
||||
public void DoActivity()
|
||||
{
|
||||
Debug.Log("I do defenders things!");
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 27106553be3f26b4da5220e39a3098c3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,8 +0,0 @@
|
||||
class HumanBehaviour : IDoActivity
|
||||
{
|
||||
public void DoActivity()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d207d14aaf634504e84f3e3bd8b52428
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,4 +0,0 @@
|
||||
public interface IDoActivity
|
||||
{
|
||||
void DoActivity();
|
||||
}
|
11
Assets/Scripts/Bots/Behaviours/IDoActivity.cs.meta
generated
11
Assets/Scripts/Bots/Behaviours/IDoActivity.cs.meta
generated
@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8e7275817852aa941963daa476581224
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/Bots/CharacterFactory.meta
generated
8
Assets/Scripts/Bots/CharacterFactory.meta
generated
@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 93133f9c3db1b944d9120ea789988f9b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,45 +0,0 @@
|
||||
public abstract class AbstractCharacterFactory
|
||||
{
|
||||
protected IDoActivity behaviour;
|
||||
protected AbstractCharacterFactory() { }
|
||||
public abstract BaseBehaviour CreateCharacterBehaviour(NPC npc);
|
||||
}
|
||||
|
||||
public class DumbDefenderFactory : AbstractCharacterFactory
|
||||
{
|
||||
public DumbDefenderFactory()
|
||||
{
|
||||
behaviour = new DumbDefenderBehaviour();
|
||||
}
|
||||
|
||||
public override BaseBehaviour CreateCharacterBehaviour(NPC npc)
|
||||
{
|
||||
return new DumbDefender(npc);
|
||||
}
|
||||
}
|
||||
|
||||
public class DumbAttackerFactory : AbstractCharacterFactory
|
||||
{
|
||||
public DumbAttackerFactory()
|
||||
{
|
||||
behaviour = new DumbAttackerBehaviour();
|
||||
}
|
||||
|
||||
public override BaseBehaviour CreateCharacterBehaviour(NPC npc)
|
||||
{
|
||||
return new DumbAttacker(npc);
|
||||
}
|
||||
}
|
||||
|
||||
public class HumanFactory : AbstractCharacterFactory
|
||||
{
|
||||
public HumanFactory()
|
||||
{
|
||||
behaviour = new HumanBehaviour();
|
||||
}
|
||||
|
||||
public override BaseBehaviour CreateCharacterBehaviour(NPC npc)
|
||||
{
|
||||
return new Human(npc);
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4f973f98c4f699745a605d09e2c1e46e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,55 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class CharacterSpawner : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject botPrefab;
|
||||
[SerializeField] private List<NavPoint> defendersSpawnPoints;
|
||||
[SerializeField] private List<NavPoint> attackersSpawnPoints;
|
||||
private static Dictionary<(TypeAI, Team), Func<NPC, BaseBehaviour>> behaviourDictionary;
|
||||
private static System.Random random;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
behaviourDictionary = new Dictionary<(TypeAI, Team), Func<NPC, BaseBehaviour>>()
|
||||
{
|
||||
{ (TypeAI.DumbAlgorithm, Team.Attackers), new Func<NPC,BaseBehaviour>( npc => new DumbAttacker(npc))},
|
||||
{ (TypeAI.DumbAlgorithm, Team.Defenders), new Func<NPC,BaseBehaviour>( npc => new DumbDefender(npc)) },
|
||||
{ (TypeAI.HumanAI, Team.Defenders), new Func<NPC,BaseBehaviour>( npc => new Human(npc))},
|
||||
{ (TypeAI.HumanAI, Team.Attackers), new Func<NPC,BaseBehaviour>( npc => new Human(npc))},
|
||||
//And Other behaviours
|
||||
};
|
||||
|
||||
if (SettingsReader.Instance.GetSettings.hasHumanAttacker && SettingsReader.Instance.GetSettings.hasHumanDefender)
|
||||
throw new System.Exception("Not allowed to have two players");
|
||||
else if (SettingsReader.Instance.GetSettings.hasHumanAttacker == true)
|
||||
{
|
||||
spawnCharacter(behaviourDictionary[(TypeAI.HumanAI, Team.Attackers)], Team.Attackers);
|
||||
}
|
||||
else if (SettingsReader.Instance.GetSettings.hasHumanDefender == true)
|
||||
{
|
||||
spawnCharacter(behaviourDictionary[(TypeAI.HumanAI, Team.Defenders)], Team.Defenders);
|
||||
}
|
||||
|
||||
for (int i = 0; i < SettingsReader.Instance.GetSettings.numOfAttackers - (SettingsReader.Instance.GetSettings.hasHumanAttacker ? 1 : 0); i++)
|
||||
{
|
||||
spawnCharacter(behaviourDictionary[(SettingsReader.Instance.GetSettings.atcTeamAI, Team.Attackers)], Team.Attackers);
|
||||
}
|
||||
for (int i = 0; i < SettingsReader.Instance.GetSettings.numOfAttackers - (SettingsReader.Instance.GetSettings.hasHumanDefender ? 1 : 0); i++)
|
||||
{
|
||||
spawnCharacter(behaviourDictionary[(SettingsReader.Instance.GetSettings.defTeamAI, Team.Defenders)], Team.Defenders);
|
||||
}
|
||||
}
|
||||
|
||||
private void spawnCharacter(Func<NPC, BaseBehaviour> behaviourFunc, Team team)
|
||||
{
|
||||
var spawnPoint = team == Team.Defenders ?
|
||||
defendersSpawnPoints[random.Next(0, defendersSpawnPoints.Count)].position :
|
||||
attackersSpawnPoints[random.Next(0, attackersSpawnPoints.Count)].position;
|
||||
var entity = Instantiate(botPrefab, spawnPoint, Quaternion.identity);
|
||||
var npc = entity.GetComponent<NPC>();
|
||||
npc.SetBehaviour(behaviourFunc(npc));
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 672f5411fc3ccb74d8a17a6efdee9df4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user