Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMejmun committed Jan 22, 2017
2 parents e2e6b67 + d23d0bc commit ff99731
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 21 deletions.
Binary file modified GGJ17/Assets/Prefab/BuildingBlocks/Building_Barracks.prefab
Binary file not shown.
Binary file modified GGJ17/Assets/Scene/Marky.unity
Binary file not shown.
7 changes: 4 additions & 3 deletions GGJ17/Assets/Script/AttackBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ void Start () {
public void startAttack(Transform target)
{
this.target = target;
lr.enabled = true;
}

void Update()
{
lr.enabled = target != null;
{

if (lr.enabled)
if (lr.enabled && target)
{
Vector3[] positions = new Vector3[2];

Expand All @@ -43,6 +43,7 @@ void Update()

public void stopAttack()
{
lr.enabled = false;
target = null;
}

Expand Down
8 changes: 2 additions & 6 deletions GGJ17/Assets/Script/Blocks/Building/Building_Barracks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,9 @@ public IEnumerator Sonar()
{
if (!isAlerted)
{
StartCoroutine(Engaging());
IsAlerted = true;
StartCoroutine(Engaging());
}
clearTicks = 0;
}
else if(++clearTicks == ticksToLeaveAlert)
{
IsAlerted = false;
}
yield return new WaitForSeconds(sonarPulseIntervall);
}
Expand All @@ -121,5 +116,6 @@ public IEnumerator Engaging()
ousiaRay.enabled = false;
}
}
IsAlerted = false;
}
}
23 changes: 12 additions & 11 deletions GGJ17/Assets/Script/KingBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ public class KingBehaviour : MonoBehaviour {
public GameObject soldierPre;
public int size;

private List<Transform> possibleTargets;

private List<MyPhysics> army;

private MyPhysics my;
Expand All @@ -24,7 +22,6 @@ void Awake () {
mySeek = GetComponent<SeekBehaviour>();

army = new List<MyPhysics>();
possibleTargets = new List<Transform>();

state = KingState.Seeking;

Expand Down Expand Up @@ -78,6 +75,8 @@ IEnumerator scanForTarget()
{
yield return new WaitUntil(() => state == KingState.Seeking);

List<Transform> possibleTargets = new List<Transform>();

foreach (AbstractBaseBuilding a in FindObjectsOfType<AbstractBaseBuilding>())
{
if (a.neighbors[AbstractBuildingBlock.down] && a.neighbors[AbstractBuildingBlock.down].tag == "Ground")
Expand All @@ -92,7 +91,6 @@ IEnumerator scanForTarget()
else
{
Debug.DrawLine(my.pos, a.transform.position, Color.blue);
if (possibleTargets.Contains(a.transform)) possibleTargets.Remove(a.transform);
}
}
}
Expand Down Expand Up @@ -141,15 +139,18 @@ IEnumerator stateMachineManager()
case KingState.Seeking:
if (!mySeek.target) break;

if (Mathf.Abs(my.pos.x - mySeek.target.position.x) <= attackRange || Mathf.Abs(my.pos.z - mySeek.target.position.z) <= attackRange)
if (Mathf.Abs(my.pos.x - mySeek.target.position.x) <= attackRange && Mathf.Abs(my.pos.z - mySeek.target.position.z) <= attackRange)
{
state = KingState.Attack;
mySeek.stop();

foreach(MyPhysics soldier in army)
{
AttackBehaviour ah = soldier.GetComponent<AttackBehaviour>();
if (ah) ah.startAttack(mySeek.target);
if (soldier)
{
AttackBehaviour ah = soldier.GetComponent<AttackBehaviour>();
if (ah) ah.startAttack(mySeek.target);
}
}

}
Expand All @@ -158,14 +159,14 @@ IEnumerator stateMachineManager()
case KingState.Attack:
if (!mySeek.target)
{
state = KingState.Seeking;
mySeek.start();

foreach (MyPhysics soldier in army)
{
AttackBehaviour ah = soldier.GetComponent<AttackBehaviour>();
if (ah) ah.startAttack(mySeek.target);
if (ah) ah.stopAttack();
}
mySeek.start();
state = KingState.Seeking;
Debug.Log("Destroyed");
}

break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class LairCannon : MonoBehaviour {

void OnParticleCollision(GameObject go)
{
if (go.tag.Equals("Ground"))
if (go.tag == "Ground")
{
Building_EnemyLair lair = GetComponentInParent<Building_EnemyLair>();
GameObject obj = Instantiate(lair.spawnPrefab);
Expand Down
File renamed without changes.
Binary file modified GGJ17/ProjectSettings/TagManager.asset
Binary file not shown.

0 comments on commit ff99731

Please sign in to comment.