FieldRegion[ ,] rightTeamRegions() { // right team region is counter clock wise FieldRegion[,] regions = new FieldRegion[3, 3]; int i = 0; int j = 0; for (float y = leftTop.y - 1; y > leftTop.y - height; y = y - height / 3.0f) { j = 0; for (float x = leftTop.x + width - 1.5f; x > leftTop.x + width / 2; x = x - 2) { FieldRegion fr = new FieldRegion(); fr.leftTop = new Vector3(x, y, 0); fr.width = 0.5f; fr.height = 0.5f; //print(string.Format("region[{0},{1}]: {2}", i, j, fr.leftTop)); regions[i, j] = fr; j++; if (j == 3) { break; } } i++; if (i == 3) { break; } } return(regions); }
public ActorFieldSide(CardGameControllerBase cardGameController, ParameterScope parentScope = null) : base(ParameterScopeLevel.Actor, parentScope ?? cardGameController) { Deck = new FieldRegion <TCard, TCardDefinition>(cardGameController, this); Hand = new FieldRegion <TCard, TCardDefinition>(cardGameController, this); DiscardPile = new FieldRegion <TCard, TCardDefinition>(cardGameController, this); }
FieldRegion[ , ] leftTeamRegions() { // left team regions are clockwize. goal keeper at [0,1] FieldRegion[,] regions = new FieldRegion[3, 3]; int i = 0; int j = 0; for (float y = leftTop.y - 1.5f; y > leftTop.y - height; y = y - height / 3.0f) { j = 0; for (float x = leftTop.x + 1f; x < leftTop.x + width / 2; x = x + 2) { FieldRegion fr = new FieldRegion(); fr.leftTop = new Vector3(x, y, 0); fr.width = 0.5f; fr.height = 0.5f; //print(string.Format("region[{0},{1}]: {2}", i, j, fr.leftTop)); regions[i, j] = fr; j++; if (j == 3) { break; } } i++; if (i == 3) { break; } } return(regions); }
public float GetValue <TCard, TCardDefinition>(FieldRegion <TCard, TCardDefinition> fieldRegion) where TCard : CardBase <TCardDefinition> where TCardDefinition : CardDefinitionBase { var cards = fieldRegion.FindCards(cardDefinition: cardDefinition as TCardDefinition); var weight = weighting.Evaluate(fieldRegion); return((useCounters ? cards.Sum(c => c.Counters) : cards.Count) * weight); }
public float GetValue <TCard, TCardDefinition>(FieldRegion <TCard, TCardDefinition> fieldRegion) where TCard : CardBase <TCardDefinition> where TCardDefinition : CardDefinitionBase { return(factors.Sum(f => f.GetValue(fieldRegion))); }
public bool TestAboveThreshold <TCard, TCardDefinition>(FieldRegion <TCard, TCardDefinition> fieldRegion, ParameterScope scope, CompositeValueThreshold modifier = null) where TCard : CardBase <TCardDefinition> where TCardDefinition : CardDefinitionBase { return(CompositeValue.GetValue(fieldRegion) >= GetThresholdValue(scope) + (modifier?.GetThresholdValue(scope) ?? 0)); }
public override void Execute(BotBase bot) { if (bot.FieldPosition == FieldPosition.Defender) { // Too far - go home. if (Vector3.Distance(bot.HomePosition, bot.GetBallPosition()) > BotConstants.DefenderChaseDistance) { bot.ChangeState(BotState_GoHome.Instance); return; } // We got the ball! if (bot.GetBallOwner() == bot) { bot.ChangeState(BotState_Dribble.Instance); return; } // Someone else from our team got it - go home. if (bot.GetBallTeamOwner() == bot.Team) { bot.ChangeState(BotState_GoHome.Instance); return; } } else if (bot.FieldPosition == FieldPosition.Attacker) { // We got the ball! BotBase ballOwner = bot.GetBallOwner(); if (ballOwner == bot) { bot.ChangeState(BotState_Dribble.Instance); return; } Vector3 ballPosition = bot.GetBallPosition(); FieldRegion fieldRegion = bot.TeamBase.GetFieldRegion(ballPosition); // Ignore - defender will get it. if (fieldRegion == FieldRegion.Backfield) { bot.ChangeState(BotState_Idle.Instance); return; } // Ball in defender region and other team has control. if (fieldRegion == FieldRegion.Forwardfield) { if (ballOwner != null && ballOwner.Team != bot.Team) { bot.ChangeState(BotState_GoHome.Instance); return; } } // Someone else from our team has the ball. if (bot.GetBallTeamOwner() == bot.Team) { bot.ChangeState(BotState_Pressure.Instance); return; } } bot.Steering.CurrentTarget = bot.GetBallPosition(); bot.Steering.CurrentEvaderVelocity = bot.GetBallVelocity(); }
public override void Execute(BotBase bot) { if (bot.FieldPosition == FieldPosition.Defender) { if (bot.GetBallTeamOwner() == bot.Team) { // If a teammate already has it, do nothing. } else { if (Vector3.Distance(bot.HomePosition, bot.GetBallPosition()) <= BotConstants.DefenderChaseDistance) { bot.ChangeState(BotState_ChaseBall.Instance); return; } } } else if (bot.FieldPosition == FieldPosition.Attacker) { // Teammate forward has the ball, let's help him. BotBase owner = bot.GetBallOwner(); if (owner != null && owner.Team == bot.Team && owner != bot && owner.FieldPosition == FieldPosition.Attacker) { bot.ChangeState(BotState_Pressure.Instance); return; } Vector3 ballPosition = bot.GetBallPosition(); FieldRegion fieldRegion = bot.TeamBase.GetFieldRegion(ballPosition); // Get ball. if (fieldRegion == FieldRegion.Midfield) { // Attempt to stay in bot's vertical half of the field (top/bottom). float verticalOffset = Mathf.Abs(bot.HomePosition.y - bot.GetBallPosition().y); float checkHeight = Main.FieldController.GetFieldSize().y * 0.333333f; if (verticalOffset < checkHeight) { bot.ChangeState(BotState_ChaseBall.Instance); return; } } // Ball is loose in forward region - get it. if (fieldRegion == FieldRegion.Forwardfield) { if (bot.GetBallOwner() == null) { bot.ChangeState(BotState_ChaseBall.Instance); return; } } } if (bot.FieldPosition != FieldPosition.Keeper) { bot.ChangeState(BotState_Roam.Instance); } }
private void MoveCardFromRegionToRegion(FieldRegion <TCard, TCardDefinition> sourceRegion, FieldRegion <TCard, TCardDefinition> destinationRegion, TCard card) { }
public void Initialise(FieldRegion <TCard, TCardDefinition> region) { fieldRegion = region; fieldRegion.OnCardAdded += UpdateDisplay; // TECH DEBT - should this be a generic on change? UpdateDisplay(); }