void Awake() { myFlock = this; goalPos = this.transform.position; for (int i = 0; i < numFish; i++) { Vector3 pos = this.transform.position + new Vector3(Random.Range(-swimLimits.x, swimLimits.x), Random.Range(-swimLimits.y, swimLimits.y), Random.Range(-swimLimits.z, swimLimits.z)); allFish[i] = (GameObject)Instantiate(fishPrefab, pos, Quaternion.identity); allFish[i].transform.parent = GameObject.Find("Drone_Manager").transform; allFish[i].GetComponent <Flock>().myManager = this; } FishSpeed(0.5f); }
void Start() { AllFishes = new GameObject[NumFishes]; MyFlock = this; GoalPos = this.transform.position; for (int i = 0; i < NumFishes; i++) { Vector3 pos = this.transform.position + new Vector3(Random.Range(-SwimLimit.x, SwimLimit.x), Random.Range(-SwimLimit.y, SwimLimit.y), Random.Range(-SwimLimit.z, SwimLimit.z)); int Index = Random.Range(0, FishPrefabs.Count); AllFishes [i] = (GameObject)Instantiate(FishPrefabs[Index], pos, Quaternion.identity); AllFishes [i].GetComponent <Flock>().MyManager = this; } }
//used for collision with fire void OnTriggerStay(Collider c) { //added this in there cuz other take damage metho had it if (!isServer) { return; } //checks so it only takes damage if it collided with the fire if (c.gameObject.tag == "Fire") { timerDMG -= Time.deltaTime; if (timerDMG <= 0) { currentHealth -= 1; timerDMG = 0.5f; } } if (currentHealth <= 0) { if (destroyOnDeath) { int z = Random.Range(1, 10); if (z <= 5) { int i = (Random.Range(0, 4)); GameObject powerup = (GameObject)Instantiate(powerups[i], gameObject.transform.position, gameObject.transform.rotation); NetworkServer.Spawn(powerup); Destroy(powerup, 10); } GlobalFlock.removeEnemy(); Destroy(gameObject); } else { currentHealth = maxHealth; RpcRespawn(); } } }
void ApplyRules() { GameObject[] gos = GlobalFlock.allFish; Vector3 vcentre = Vector3.zero; Vector3 vavoid = Vector3.zero; float gSpeed = 0.1f; Vector3 goalpos = GlobalFlock.goalPos; float dist; int groupsize = 0; for (int z = 0; z < GlobalFlock.numberOfEnemies(); z++) { if (gos[z] != gameObject) { dist = Vector3.Distance(gos[z].transform.position, transform.position); if (dist <= neighbourDistance) { vcentre += gos[z].transform.position; groupsize++; if (dist < 1.0f) { vavoid = vavoid + (transform.position - gos[z].transform.position); } Flock anotherflock = gos[z].GetComponent <Flock>(); gSpeed = gSpeed + anotherflock.speed; } } } if (groupsize > 0) { vcentre = vcentre / groupsize + (goalpos - this.transform.position); speed = gSpeed / groupsize; Vector3 direction = (vcentre + vavoid) - transform.position; if (direction != Vector3.zero) { transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(direction), rotationSpeed * Time.deltaTime); } } }
public void Init(GlobalFlock gf) { m_FlockManager = gf; }
private void Start() { global = transform.parent.GetComponent <GlobalFlock>(); }
void Start() { speedOrigine = speed; speed = Random.Range(1.0f, speedOrigine); global = transform.parent.GetComponent <GlobalFlock>(); }
// Use this for initialization void Start() { gf = GameObject.FindWithTag(controllerTag).GetComponent <GlobalFlock>(); speed = Random.Range(0.1f, maxSpeed); }
// Use this for initialization void Start() { fishManager = GameObject.Find("FishManager"); globalFlock = fishManager.GetComponent <GlobalFlock>(); allFish = GlobalFlock.allFish; }
void Start() { gf = GetComponent <GlobalFlock>(); }
// Use this for initialization void Start() { parentPos = transform.parent.transform.position; GlobalFlock = transform.parent.GetComponent <GlobalFlock>(); speed = Random.Range(0.5f, 1); }