virtual public void OnMouseUpAsButton() { if (attacking == true) { print(this.gameObject + " attacking!"); target = this; unit.Attack(); attacking = false; } else { print("chosen" + this.gameObject.name); attacking = true; unit = this; } }
void Spawn(int n, float angle = 0, float _x = 0, float _y = 0, float _z = 0) { if (!running) { return; } Vector3 v = new Vector3(_x, _y, _z); for (int i = 0; i < n; i++) { if (scatter) { v = Random.insideUnitSphere * radius; } GameObject obj = PoolObjs[0]; PoolObjs.Remove(PoolObjs[0]); obj.transform.position = transform.position + v; obj.transform.rotation = Quaternion.Euler(0, angle, 0); obj.SetActive(true); Vector3 r = Random.insideUnitSphere * radius; if (obj.GetComponent <Rigidbody>()) { obj.GetComponent <Rigidbody>().AddTorque(r); } if (spawnAtAngle) { obj.transform.rotation = Quaternion.Euler(0, Random.Range(-180, 180), 0); } obj.transform.localScale = new Vector3(1, 1, 1) * Random.Range(1f, scaleMax); if (spawnToAxis) { obj.transform.parent = axis; } if (cube) { Cube c = obj.GetComponent <Cube>(); c.homing = true; c.Attack(player, cubeEnergy); } } _nextTimer = Random.Range(0, 1) * (frequency); StartCoroutine(Timer(frequency)); }