//TODO: make this not pass in a SquareMovement but rather an interface exposing only position //TODO: pass an "attack" object in here, to trigger public Projectile(Targeter targeter, SquareMovement source, GameObject visualPrefab) { if (targeter == null) throw new ArgumentNullException("targeter"); if (targeter.IsVisible) throw new ArgumentException("The given targeter must not already be active."); this.targeter = targeter; this.targeter.Selected += HandleTargetSelected; this.visualPrefab = visualPrefab; this.source = source; }
//TODO: make this not pass in a SquareMovement but rather an interface exposing only position //TODO: pass an "attack" object in here, to trigger public Projectile(Targeter targeter, SquareMovement source, GameObject visualPrefab) { if (targeter == null) { throw new ArgumentNullException("targeter"); } if (targeter.IsVisible) { throw new ArgumentException("The given targeter must not already be active."); } this.targeter = targeter; this.targeter.Selected += HandleTargetSelected; this.visualPrefab = visualPrefab; this.source = source; }
public void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag == "square") { float x = collision.bounds.center.x; float y = collision.bounds.center.y; SquareMovement movement = collision.gameObject.GetComponent <SquareMovement>(); int axis = movement.axis; int moveDirection = movement.moveDirection; if ((axis == 0 && ((y > 0 && moveDirection == 0) || (y < 0 && moveDirection == 1))) || (axis == 1 && ((x > 0 && moveDirection == 0) || (x < 0 && moveDirection == 1)))) { Destroy(collision.gameObject); return; } } }
void Start() { if (Target == null) { Destroy(this.gameObject); return; } SquareMovement moveController = this.GetComponentForce <SquareMovement>(); moveController.SetPosition(StartSquare); moveController.LongMoveFinished += (s) => FireFinished(); moveController.StartMove(Target, speed); if (shouldRotate) { this.transform.Rotate(0, 0, moveController.Rotation); } }
// Use this for initialization void Start() { moveControl = this.GetComponentForce<SquareMovement>(); moveControl.SetPosition(startX, startY); }
// Use this for initialization void Start() { moveControl = this.GetComponentForce <SquareMovement>(); moveControl.SetPosition(startX, startY); }