public bool AddStrike(Strike inputStrike) { if (inputStrike != null) { int totalNumberOfStrikes = _strikes.Length; Array.Resize(ref _strikes, totalNumberOfStrikes + 1); _strikes[totalNumberOfStrikes] = inputStrike; return(true); } else { return(false); } }
public int MakeStrike(int inputPlayerId, int inputAngle, int inputVecity) { double myAngleRadians = (Math.PI / 180) * Convert.ToDouble(inputAngle); double myDistance = Math.Pow(inputVecity, 2) / _gravity * Math.Sin(2 * myAngleRadians); int myIntDistance = Convert.ToInt32(myDistance); Strike myNewStrike = new Strike(Indexer.NextStrikeId(), myIntDistance); Player theActivePlayer = FindPlayerById(inputPlayerId); theActivePlayer.AddStrike(myNewStrike); theActivePlayer.LengthToGo = Math.Abs(theActivePlayer.LengthToGo) - myIntDistance; // BEWARE => if length to go now is Zero the player is _done = true. return(myIntDistance); }