Skip to content

Instantly share code, notes, and snippets.

@IronMonk-UK
IronMonk-UK / AIUnit.cs
Created April 16, 2016 12:16
Scripts relating to the current AI
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class AIUnit : Unit {
Renderer rend;
GameManager gm;
Pathfinding path;
@IronMonk-UK
IronMonk-UK / AIUnit.cs
Created April 25, 2016 17:48
All code towards the project up to 25/04/16
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class AIUnit : Unit {
GameManager gm;
Pathfinding path;
Grid grid;
Renderer rend;
@IronMonk-UK
IronMonk-UK / AIUnit.cs
Created May 10, 2016 20:06
Classes changed in the latest implementation
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class AIUnit : Unit {
GameManager gm;
Pathfinding path;
Grid grid;
Renderer rend;
// Method to add in forest tiles to the map
void AddForests() {
// A for loop is run, with i starting at 0, and increasing until it has reached a sixth
// of the total tiles, calculated by multiplying the X and Y map lengths, and dividing
// the result by 6
for (int i = 0; i < Mathf.RoundToInt((worldSize.x * worldSize.y) / 6); i++) {
// Random X and Y variables are generated
int x = Mathf.RoundToInt(Random.Range(0, worldSize.x));
int y = Mathf.RoundToInt(Random.Range(0, worldSize.y));
// If the forest bool of the tile attached to the node with the random
// Makes tiles populated by units unwalkable, so they cannot be moved to, or stopped on
void BlockUnitTiles() {
// If the current unit is a User unit, and moving
if (userUnits.Contains(units[currentUnitIndex]) && units[currentUnitIndex].moving) {
// For every unit
foreach(Unit u in units) {
// If the unit is not the current unit
if(u != units[currentUnitIndex])
// Set the walkable bool on the node of the populated tile to false
@IronMonk-UK
IronMonk-UK / AIUnit.cs
Created May 11, 2016 19:36
The final collection of classes for my Final Project
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class AIUnit : Unit {
GameManager gm;
Pathfinding path;
Grid grid;
Renderer rend;