public void createAttack(DataMetricAttack attack) { if (_currLevel != null) { _currLevel.addAttack(attack); } }
public void addAttack(DataMetricAttack attack) { //Debug.Log("added attack..."); attacks.Add(attack); }
void GravitationalPull() { pullableObjects = GameObject.FindGameObjectsWithTag("PullableObject"); if (Input.GetButtonDown(usePowerButtonName) && !pulling) { pulling = true; DataMetricAttack dbAttack = new DataMetricAttack(); dbAttack.attackTime = Time.timeSinceLevelLoad; dbAttack.type = DataMetricAttack.Type.Telekinesis; DataCollector inst = DataCollector.getInstance(); inst.createAttack(dbAttack); return; } foreach (GameObject pullObj in pullableObjects) { if (pullObj.GetComponent <Rigidbody2D>() == null) { continue; } if (currentPower != 0) { pullObj.GetComponent <Rigidbody2D>().isKinematic = false; pulling = false; tempPull = null; continue; } float distance = Vector2.Distance(transform.position, pullObj.transform.position); if (distance < radiusBorder && distance > radiusStart) { if (pulling) { if (tempPull == null) { tempPull = pullObj; } if (tempPull == pullObj) { if (!humming) { playSound(pullHum); humming = true; } Vector3 objVelocity = (transform.position - pullObj.transform.position) * Time.deltaTime * pullSpeed; pullObj.transform.position += objVelocity; pullObj.GetComponent <Rigidbody2D>().isKinematic = true; if (Input.GetButtonDown(usePowerButtonName)) { pullObj.GetComponent <Rigidbody2D>().isKinematic = false; pullObj.GetComponent <Rigidbody2D>().velocity = GlobalGuide.AimTowardsMouse(pullObj.transform.position) * pushPower; tempPull = null; pulling = false; } } } } else { if (pullObj == tempPull) { pulling = false; tempPull = null; } pullObj.GetComponent <Rigidbody2D>().isKinematic = false; } } if (tempPull == null) { pulling = false; } if (!pulling) { humming = false; GetComponent <AudioSource>().Stop(); } }