float EvalThisQuarter(QuarterState quarterState) { int guardCount = (int)(quarterState.OwnershipDuration.TotalSeconds / game.Player.GuardAddTimeout.TotalSeconds); if (guardCount > TownQuarter.MaxGuardCount) { guardCount = TownQuarter.MaxGuardCount; } int multiplier; switch (quarterState.Ownership) { case QuarterOwnership.My: multiplier = 1; break; case QuarterOwnership.His: multiplier = -1; break; default: multiplier = 0; break; } return(((float)guardCount / TownQuarter.MaxGuardCount) * multiplier); }
/// <summary> /// Creates copy of this state into a new object. /// </summary> /// <returns>The copy of this state</returns> public GameState Copy() { QuarterState[] qs = new QuarterState[QuarterStates.Length]; Array.Copy(QuarterStates, qs, qs.Length); GameState gs = new GameState(game) { Damage = Damage, Health = Health, Position = Position, QuarterStates = qs }; return(gs); }
GameState GetCurrentGameState(GameTime gameTime) { QuarterState[] qStates = new QuarterState[Game.Town.Quarters.Length]; for (int i = 0; i < qStates.Length; i++) { qStates[i] = new QuarterState(); if (Game.Town.Quarters[i].Owner == this) { qStates[i].Ownership = QuarterOwnership.My; } else if (Game.Town.Quarters[i].Owner == Game.Player) { qStates[i].Ownership = QuarterOwnership.His; } else { qStates[i].Ownership = QuarterOwnership.Empty; } qStates[i].OwnershipDuration = gameTime.TotalGameTime - Game.Town.Quarters[i].OwnershipBeginTime; } float damage = 0; foreach (Tool tool in Tools) { if (tool is Gun) { Gun gun = (Gun)tool; float gunUtility = gun.Type.Damage * gun.Bullets; damage += gunUtility; } } return new GameState(Game) { QuarterStates = qStates, Damage = damage, Position = Position, Health = Health }; }