/// <summary> /// occurs when player collides with a storm /// decreases health and fuel /// </summary> /// <param name="play"></param> public void ResolveStorm(Player play, Random rand) { if (available == true) { play.changeFuel(-5f); play.changeHealth(rand.Next(-30, -10)); this.available = false; } }
public void ResolvePirate(Player play) { Random rand = new Random(); if(available) { play.changeHealth(rand.Next((int)Math.Ceiling(play.Health / 5f), (int)Math.Ceiling((play.Health / 3f)))* -1); int num = play.changeCrew(rand.Next((int)Math.Ceiling(play.Crew / 6f), (int)Math.Ceiling((play.Crew / 2f)))* -1); if (num != -1) play.Crew -= num; this.available = false; } }
public void UpdatePlayer(Player play, SoundEffectInstance sound) { sound.Play(); //fuel if (changeValue == ChangeValue.fuel) { if (play.changeCurrency(int.Parse(this.UserInput) * -1) != -1) { this.NumError = true; if (this.UserInput == "0") this.NumError = false; } else { int diff = play.changeFuel(float.Parse(this.UserInput)); play.changeCurrency(diff * 1); } this.ReturnValue = false; } //health if(changeValue == ChangeValue.health) { if (play.changeCurrency(int.Parse(this.UserInput) * -1) != -1) { this.NumError = true; if (this.UserInput == "0") this.NumError = false; } else { int diff = play.changeHealth(int.Parse(this.UserInput)); play.changeCurrency(diff * 1); } this.ReturnValue = false; } //inventory buy if(changeValue == ChangeValue.inventoryBuy) { if (play.changeCurrency((int.Parse(this.UserInput)*inventoryItem.BuyPrice) * -1) != -1) { this.NumError = true; if (this.UserInput == "0") this.NumError = false; } else { int difference = play.Inventory.AddItem(this.inventoryItem, int.Parse(this.UserInput)); if(difference != -1) play.changeCurrency(difference * inventoryItem.BuyPrice); } this.ReturnValue = false; } //inventory sell if(changeValue == ChangeValue.inventorySell) { int difference = play.Inventory.DecrementItem(this.inventoryItem, int.Parse(this.UserInput)); play.changeCurrency(int.Parse(this.UserInput) * inventoryItem.SellPrice); if (difference != -1) { play.changeCurrency((difference * inventoryItem.SellPrice) * -1); } this.ReturnValue = false; } //crew if(changeValue == ChangeValue.crew) { if (this.label.Contains("Sell")) { int difference = play.changeCrew(int.Parse(this.UserInput) * -1); play.changeCurrency(int.Parse(this.UserInput) * 1); if(difference != -1) { play.changeCurrency(difference * -1); this.NumError = true; if (this.UserInput == "0") this.NumError = false; } this.ReturnValue = false; } else { if (play.changeCurrency(int.Parse(this.UserInput) * -1) != -1) { this.NumError = true; if (this.UserInput == "0") this.NumError = false; } else { play.changeCrew(int.Parse(this.UserInput)); } this.ReturnValue = false; } } }