public void Insert(PirateModel pirate) { SqlConnection connection = new SqlConnection(GetConnectionString()); try { connection.Open(); SqlCommand command = new SqlCommand(); command.Connection = connection; command.CommandType = System.Data.CommandType.StoredProcedure; command.CommandText = "Pirates_Insert"; command.Parameters.AddWithValue("@Name", pirate.name); command.Parameters.AddWithValue("@BeardColor", pirate.beardColor); command.Parameters.AddWithValue("@CatchPhrase", pirate.catchPhrase); command.Parameters.AddWithValue("@HasHat", pirate.hasHat); command.Parameters.AddWithValue("@HasEyepatch", pirate.hasEyepatch); command.Parameters.AddWithValue("@NumLegs", pirate.numLegs); command.ExecuteNonQuery(); } catch (Exception ex) { } finally { connection.Close(); } }
public void SpawnPirate(SpaceModel spawnPoint) { //If the pirate is dead check type and create a new one if (pirateModel == null && !spawnPoint.Occupied()) { switch (pirateType) { case PirateModel.PirateType.Scout: pirateModel = PirateModel.CreateScoutPirate(spawnPoint, this); break; case PirateModel.PirateType.Frigate: pirateModel = PirateModel.CreateFrigatePirate(spawnPoint, this); break; case PirateModel.PirateType.Platform: pirateModel = PirateModel.CreatePlatformPirate(spawnPoint, this); break; case PirateModel.PirateType.Dreadnought: pirateModel = PirateModel.CreateDreadnaughtPirate(spawnPoint, this); break; case PirateModel.PirateType.Destroyer: pirateModel = PirateModel.CreateDestroyerPirate(spawnPoint, this); break; } Dispatcher.InvokeAsync(() => { modelLink.CreatePirateView(pirateModel); spawnPoint.OccupySpace(pirateModel); }); } }
private void Update() { if (moving && currentDestination.x > -9999) { // add some distance distanceMoved += speed * Time.deltaTime; //move along according to speed; shipView.transform.position = Vector2.Lerp(currentLocation, currentDestination, distanceMoved); //check if we've reached the goal point if (distanceMoved >= 1) { destinations[destinationIndex].GetMovementEffects(shipModel); distanceMoved = 0; destinationIndex += 1; // check if we're done moving if (destinationIndex >= destinations.Count) { moving = false; if (pirateMoving != null) { pirateMoving.FinishedAnimatingMovement(); } else { shipModel.FinishedAnimatingMovement(); } if (playerToShootOnFinish != null) { pirateMoving.Shoot(playerToShootOnFinish); pirateMoving = null; playerToShootOnFinish = null; } } else { currentLocation = currentDestination; currentDestination = destinations[destinationIndex].GetController().GetPosition(); FlipShip(currentLocation.x < currentDestination.x); } } } else if (!(currentDestination.x > -9999)) { if (pirateMoving != null) { pirateMoving.FinishedAnimatingMovement(); } if (playerToShootOnFinish != null) { pirateMoving.Shoot(playerToShootOnFinish); shipModel.soundController.SwitchMusic(SoundController.Sound.battle); pirateMoving = null; playerToShootOnFinish = null; } } }
public IActionResult Insert(PirateModel pirate) { if (!ModelState.IsValid) { return(View("Create", pirate)); } //Insert pirate yarrrr pirateRepository.Insert(pirate); return(RedirectToAction("Index", "Pirate")); }
public IActionResult Create() { PirateModel pirate = new PirateModel(); IConfigurationBuilder builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json"); var configuration = builder.Build(); pirate.name = configuration["DefaultPirateName"]; return(View(pirate)); }
// Same as above for a Space GameObject public void CreatePirateView(PirateModel pirateModel) { // Creates the player GameObject in the correct position. GameObject pirateView = UnityEngine.Object.Instantiate(GameController.GetPirateView(), pirateModel.GetSpace().GetController().GetPosition(), Quaternion.identity, MapContainer); // Gets the controller from the GameObject. PirateController pirateController = pirateView.GetComponentInChildren <PirateController>(); // Lets the Controller access the GameObject pirateController.SetShipView(pirateView); // Lets the Controller access the Model pirateController.SetModel(pirateModel, GameController.soundController); // Lets the Model access the Controller, as a callback pirateModel.SetController(pirateController); }
public void SetHealth(int health) { int originalHealth = shipHealth; shipHealth = Math.Min(maxHealth, health); // update health bar shipController.UpdateHealth(shipHealth, maxHealth); if (shipHealth <= 0) { // die Die(); if (this is PirateModel && originalHealth - shipHealth <= 1) { //do nothing; } else if (this is PirateModel) { soundController.PlaySound(SoundController.Sound.destroy, 0.4f); } } else { PirateModel sub = this as PirateModel; PlayerModel sub2 = this as PlayerModel; if (sub != null) { if (originalHealth - shipHealth > 1) { soundController.PlaySound(SoundController.Sound.damage, 0.3f); } } if (sub2 != null) { if (originalHealth > shipHealth) { soundController.PlaySound(SoundController.Sound.damage, 0.3f); } } } }
public void MoveShip(List <SpaceModel> destinations, PirateModel pirateMoving, PlayerModel playerToShootOnFinish) { moving = true; this.destinations = destinations; this.pirateMoving = pirateMoving; this.playerToShootOnFinish = playerToShootOnFinish; distanceMoved = 0; destinationIndex = 0; currentLocation = shipView.transform.position; if (destinations.Count != 0) { currentDestination = destinations[destinationIndex].GetController().GetPosition(); FlipShip(currentLocation.x < currentDestination.x); } else { currentDestination = new Vector2(-9999, -9999); } }
public void Insert(PirateModel pirate) { throw new NotImplementedException(); }
public void Delete(PirateModel pirate) { throw new NotImplementedException(); }
public virtual void NullPirate() { pirateModel = null; }
public void SetModel(PirateModel pirateModel, SoundController soundController) { this.pirateModel = pirateModel; // The superclass sometimes needs access to the model base.SetModel(pirateModel, soundController); }