Skip to content

Commit 55f6acf

Browse files
committed
ADD: AI will send its first three units to capture the near resource points
Closes #22
1 parent af67973 commit 55f6acf

4 files changed

Lines changed: 40 additions & 1361 deletions

File tree

Assets/Scripts/Controller/AIController.cs

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections;
23
using System.Collections.Generic;
34
using Health;
45
using UnityEngine;
@@ -23,9 +24,47 @@ public class AIController : MonoBehaviour
2324
public List<ResourcePoint> nearResourcePoints;
2425
public List<ResourcePoint> farResourcePoints;
2526

27+
private bool _firstCommandsPassed = false;
28+
29+
private void Start()
30+
{
31+
StartCoroutine(FirstCommands());
32+
}
33+
34+
private IEnumerator FirstCommands()
35+
{
36+
yield return new WaitForSeconds(1);
37+
while (ownUnits.Count < 3)
38+
{
39+
// Do nothing
40+
}
41+
ownUnits[0].destPoint = nearResourcePoints[1].transform.position;
42+
ownUnits[1].destPoint = nearResourcePoints[2].transform.position;
43+
ownUnits[2].destPoint = nearResourcePoints[0].transform.position;
44+
45+
// TODO: Here could be the lines to make the AI send all it units to the middle until all three beginning points are captured, but I think this version of the AI will simply be to strong to have a fund gaming experience.
46+
47+
yield return new WaitForSeconds(7);
48+
_firstCommandsPassed = true;
49+
}
50+
51+
private bool AreNearPointsCaptured()
52+
{
53+
bool result = true;
54+
foreach (var point in nearResourcePoints)
55+
{
56+
if (point.ownerTeam != 2) result = false;
57+
}
58+
59+
return result;
60+
}
61+
2662
private void Update()
2763
{
28-
DecisionMaking();
64+
if (_firstCommandsPassed)
65+
{
66+
DecisionMaking();
67+
}
2968
UnitBuilding();
3069
}
3170

Logs/AssetImportWorker0-prev.log

Lines changed: 0 additions & 139 deletions
This file was deleted.

0 commit comments

Comments
 (0)