internal override void ExecuteOrder() { List <string> result = new List <string>(); result.Add(string.Format("Attempting to execute order: {0}", this.ToString())); if (TargetPosition == CurrentShip.Position) // already at target location { result.Add("Already at target location!"); OnMessageResult?.Invoke(this, new MessageEventArgs(result)); } else if (CurrentShip.MP.Current < 1) // no remaining MP { result.Add("No remaining MP!! [[BAD CODE!! BAD!! NO BISCUT!!]]"); OnMessageResult?.Invoke(this, new MessageEventArgs(result)); } else if (!CurrentShip.Position.IsAdjacent(TargetPosition)) // invalid movement location { result.Add("Target Position is not an adjacent location!! [[BAD CODE!! BAD!! GO TO YOUR ROOM!!]]"); OnMessageResult?.Invoke(this, new MessageEventArgs(result)); } else if (Simulation.Features.Any(x => x.Position == TargetPosition && x.IsBlocking) || Simulation.Ships.Any(x => x.Position == TargetPosition && x.ID != CurrentShip.ID)) // trying to move into blocking feature or ship { result.Add("ABORT ORDER, IMMINENT COLLISION!! [[BAD CODE!! BAD!! DO THAT OUTSIDE!!]]"); OnMessageResult?.Invoke(this, new MessageEventArgs(result)); } else { CurrentShip.Position = TargetPosition; result.Add(string.Format("Moved to {0}", TargetPosition.ToString())); OnShipMoved?.Invoke(this, new ShipMovedEventArgs(CurrentShip.ID, TargetPosition, result)); } }
private void FixedUpdate() { if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow)) { GetComponent <Rigidbody2D>().AddForce(transform.up * speed); OnShipMoved?.Invoke(); GetComponent <ParticleSystem>().Play(); } float rotation = -Input.GetAxis("Horizontal") * rotationSpeed; transform.Rotate(0, 0, rotation); }