public override ActionResult Execute(RAIN.Core.AI ai) { //MonoBehaviour.Destroy(ai.Body); ai.Body.gameObject.SendMessage("DestroyCar"); SpawnAI spawnAI = ai.Body.GetComponentInChildren <SpawnAI>(); spawnAI.Remove(); /*Spawner myScript = GameObject.Find ("Spawner_01").GetComponentInChildren<Spawner>(); * if (myScript.totalUnits > 0) { * myScript.RemoveUnit (); * //return ActionResult.SUCCESS; * } * * myScript = GameObject.Find ("Spawner_02").GetComponentInChildren<Spawner>(); * if (myScript.totalUnits > 0) { * myScript.RemoveUnit (); * //return ActionResult.SUCCESS; * } * * myScript = GameObject.Find ("Spawner_03").GetComponentInChildren<Spawner>(); * if (myScript.totalUnits > 0) { * myScript.RemoveUnit (); * //return ActionResult.SUCCESS; * } * * myScript = GameObject.Find ("Spawner_04").GetComponentInChildren<Spawner>(); * if (myScript.totalUnits > 0) { * myScript.RemoveUnit (); * //return ActionResult.SUCCESS; * }*/ return(ActionResult.SUCCESS); }
private IEnumerator spawnSpawnable() { while (true) { yield return(new WaitForSeconds(spawnInterval)); if (spawns.Count < maxSpawn) { int numSpawn = CalculateNumToSpawn(); for (int x = 0; x < numSpawn; x++) { Vector3 spawnLocation = this.gameObject.transform.position; //We need to lightly scatter spawnables which are all spawning at once if (spawnImmediate) { spawnLocation.x += x; spawnLocation.z += x; } GameObject go = Instantiate(spawnable, spawnLocation, Quaternion.identity) as GameObject; go.GetComponent <Renderer>().material = spawnMaterial; SpawnAI spawned = go.GetComponent <SpawnAI>(); //Some items assigned don't immediately fixate if (fixate != null) { /* * Vector3 targetDir = fixate.transform.position - go.transform.position; * float step = spawned.speed * Time.deltaTime; * Vector3 newDir = Vector3.RotateTowards (go.transform.forward, targetDir, step, 0.0f); * Debug.DrawRay (go.transform.position, newDir, Color.red); * go.transform.rotation = Quaternion.LookRotation (newDir); */ go.transform.LookAt(fixate.transform); spawned.target = fixate; //Quaternion rotation = Quaternion.LookRotation (fixate.transform.position - go.transform.position); //go.transform.rotation = Quaternion.Slerp (go.transform.rotation, rotation, Time.deltaTime * 2); } spawned.health = spawned.health * factor; spawned.team = this.team; spawned.parent = this; spawned.drop = drop; spawned.damage = spawned.damage * factor; go.transform.localScale += getFactorScale(); spawns.Add(spawned); } } } }
void OnTriggerEnter(Collider other) { if (other.GetComponent <SpawnAI>() != null) { SpawnAI ai = other.GetComponent <SpawnAI>(); if (ai.team != this.team) { ai.TakeDamage(200); } } }
public float startFightTimer = 0; //If this reach a given number, start a fight // Use this for initialization void Start() { spawn = this; marineShips = new GameObject[maxMarines]; //Sets the array length equal to the maximum ammount of marines we want in the game availableIndes = new bool[maxMarines]; //Does the same with this array for (int i = 0; i < marineShips.Length; i++) //Cleans out the arrays { marineShips[i] = null; availableIndes[i] = true; } waitBeforeNewSpawn(); //Start the marine spawn timer waitBeforeCargoSpawn(); //Start the cargo spawn timer }
void OnTriggerEnter(Collider other) { //If I'm already in combat with someone don't get a new target if (inCombat) { return; } SpawnAI ai = other.gameObject.GetComponent <SpawnAI>(); if (ai != null && ai.team != this.team) { if (anim != null) { anim.SetTrigger(sthAttack); } canAttack = false; inCombat = true; combatWith = other.gameObject; ai.TakeDamage(); StartCoroutine(WaitForCooldown()); } }
void Start() { ai = gameObject.GetComponent<SpawnAI>(); Set(); }
//Eventually this should be better than constantly instancing stuff public void RemoveFromSpawnList(SpawnAI spawn) { spawns.Remove(spawn); }
void Start() { ai = gameObject.GetComponent <SpawnAI>(); Set(); }
void Awake() { spawnAI = FindObjectOfType <SpawnAI>(); pickups = GameObject.FindGameObjectsWithTag("Pickups"); audioManager = GameObject.FindObjectOfType <AudioManager> (); }
// Use this for initialization void Start() { spawn = this; marineShips = new GameObject[maxMarines]; //Sets the array length equal to the maximum ammount of marines we want in the game availableIndes = new bool[maxMarines]; //Does the same with this array for(int i = 0; i < marineShips.Length; i++) //Cleans out the arrays { marineShips[i] = null; availableIndes[i] = true; } waitBeforeNewSpawn(); //Start the marine spawn timer waitBeforeCargoSpawn(); //Start the cargo spawn timer }