private void DumbAttack(TurnInfo turn) { var path = BallPath.Create(turn); var sortedPlayers = turn.Own.Players.OrderByDescending(p => p.Position.X); foreach (Player player in turn.Own.Players) { if (turn.Ball.Owner == player) { if (turn.Ball.GetDistanceTo(Field.EnemyGoal.Center) < 50) { player.ActionShootGoal(); } else if (player == sortedPlayers.First()) { player.ActionGo(Field.EnemyGoal.Center); } else { player.ActionShoot(sortedPlayers.First()); } } else { //player.ActionGo(turn.Ball); player.ActionGo(path[10]); if (player.CanPickUpBall(turn.Ball)) { player.ActionPickUpBall(); } } //player.ActionGo(new Vector(50, 50)); } }
TurnInfo saveTurn(Entity selectedEntity, int action, Point2 tileSelected, AIMapInfo mapInfo) { TurnInfo turnInfo = new TurnInfo(); List<Point2> affectedTiles = selectedEntity.getEntityActionManager().actions[action].getAffectedTiles(selectedEntity.getCurrentLocation(), tileSelected, mapInfo); foreach (Point2 p in affectedTiles) { turnInfo.addAffectedTile(mapInfo.getTile(p)); } return turnInfo; }
public Player Apply(TurnInfo turn, IEnumerable<Player> queue) { if (turn.Ball.Owner == null) { return null; } var tackler = queue.FirstOrDefault(player => player.CanTackle(turn.Ball.Owner)); if (tackler != null) { tackler.ActionTackle(turn.Ball.Owner); } return tackler; }
private void SmartDefense(TurnInfo turn) { var unassigned = new List<Player>(turn.Own.Players); unassigned.Remove(_ballOwner.Apply(turn, unassigned)); unassigned.Remove(_pickup.Apply(turn, unassigned)); unassigned.Remove(_catchUp.Apply(turn, unassigned)); unassigned.Remove(_keeper.Apply(turn, unassigned)); unassigned.Remove(_sweeper.Apply(turn, unassigned)); unassigned.Remove(_defender.Apply(turn, unassigned)); unassigned.Remove(_defender.Apply(turn, unassigned)); unassigned.Remove(_defender.Apply(turn, unassigned)); }
public void startLocalGame() { pannelHelp.enabled = false; txtHelp.enabled = false; dols.CleanDols(); dols.offLineInit(); TurnInfo turnInfo = new TurnInfo(); turnInfo.isMe = true; turnInfo.isBlack = false; local_turn = 1; sendLocalData("TurnInfo", turnInfo.ToString()); }
void onMoveDol() { if (Game.selectedDol != null && Game.targetDol != null && mydolType == 0) { Game.lastMovedDol = Game.selectedDol; Debug.Log(string.Format("Bound - SwapDol:{0} {1}", Game.selectedDol.name, Game.targetDol.name)); //SwapDolPos(ref Game.selectedDol, ref Game.targetDol); MoveInfoReq moveInfoReq = new MoveInfoReq(); moveInfoReq.source.setPos(Game.selectedDol.dolPos); moveInfoReq.target.setPos(Game.targetDol.dolPos); if (Game.isOffLineMode == false) { Game.send(moveInfoReq.ToString()); } else { MoveInfoRes moveInfoRes = new MoveInfoRes(); moveInfoRes.source.setPos(Game.selectedDol.dolPos); moveInfoRes.target.setPos(Game.targetDol.dolPos); Game.sendLocalData("MoveInfoRes", moveInfoRes.ToString()); TurnInfo turnInfo = new TurnInfo(); if (Game.local_turn == Game.selectedDol.GetMyDolType()) { turnInfo.isMe = false; } else { turnInfo.isMe = true; } turnInfo.isBlack = Game.selectedDol.GetMyDolType() == 1 ? true : false; Game.sendLocalData("TurnInfo", turnInfo.ToString()); Game.local_turn = Game.local_turn == 2 ? 1 : 2; Game.isMyDolColorBlack = Game.selectedDol.GetMyDolType() == 1 ? true : false; } Game.selectedDol = null; Game.targetDol = null; Dols.SetOffAllCanMove(); indicator.SetActive(false); } }
public void RemoveAttack(TurnInfo givenInfo) { //goes over full list and removes all abilities made by this player foreach (TurnInfo info in MovesThisRound) { if (info.player == givenInfo.player) { numOfTurns++; MovesThisRound.Remove(info); contUi.SetInteractable(); break; } } }
private void Client_OnMessageReceived(object sender, SocketMessageEventArgs e) { dynamic data = Json.Decode(e.Content); var type = data.Type; var payload = data.Payload; switch (type) { case "end": OnGameEnd?.Invoke(payload.winner, payload.rounds); break; case "error": OnError?.Invoke(payload.error, payload.data); break; case "joined": Arena = new ClientArena() { Size = payload.size, Capacity = payload.capacity }; foreach (var obstacle in payload.obstacles) { Arena.Obstacles.Add(WorldObject.FromDynamic(obstacle)); } Arena.ClientBot = Bot.FromDynamic(payload.clientBot); break; case "ready": Token = payload; OnReady?.Invoke(); break; case "state": Arena.Turn = payload.turn; Arena.NextTurn = payload.nextTurn; Arena.PlayersRemaining = payload.playersRemaining; Arena.ClientBot = Bot.FromDynamic(payload.clientBot); var turn = (TurnInfo)TurnInfo.FromDynamic(payload); foreach (var obj in turn.DestroyedObjects) { Arena.Obstacles.RemoveAll(o => o.ID == obj); } var response = new TurnResponse(); OnTurn?.Invoke(turn, response, Arena.ClientBot); SendMessage("turn", response.GetObject(Arena.NextTurn)); break; } }
public int CheckDiplomaticStateOfAllPlayers(TurnInfo thisPlayer, string state) { int noOfPlayersInState = 0; for (int i = 0; i < MasterScript.diplomacyScript.relationsList.Count; ++i) { if (MasterScript.diplomacyScript.relationsList[i].playerOne.playerRace == thisPlayer.playerRace || MasterScript.diplomacyScript.relationsList[i].playerTwo.playerRace == thisPlayer.playerRace) { MasterScript.diplomacyScript.relationsList[i].diplomaticState = state; ++noOfPlayersInState; } } return(noOfPlayersInState); }
public static int CalculateTapPenalty(Card card, TurnInfo turnInfo) { if (card.Is().Land) { if (card.Controller.IsActive) { if (turnInfo.Step == Step.Upkeep) return 10; return 2; } } return 1; }
public void addMoves(TurnInfo other) { for (int i = 0; i < other.moves.Count; i++) { moves.Add(other.moves [i]); } //debugResultingBoard = other.debugResultingBoard; //we only care about the final board state so all evaluation should be transfered over if (moves.Count > 0) { val = other.val; } }
public override bool CanBePlaced(TurnInfo TI, CardZoneType CZ) { if (TI.IsDeployment()) { return(false); } if (mIsShared) { return(CZ.getType() == ZoneType.SharedEffect); } else { return(CZ.getType() == ZoneType.Effect && CZ.getOwnerIndex() == GetOwnerIndex()); } }
public void CheckWin(TurnInfo thisPlayer) { player = thisPlayer; InvasionWin(); ExpansionWin(); DiplomaticWin(); EconomicWin(); ScientificWin(); PointWin(); if (winPlayer != null) { Debug.Log(winPlayer + " | " + winCondition); } }
public virtual TurnInfo TakeTurn() { if (tree != null) { var turnsCanTakeVar = (SharedInt)tree.GetVariable("turnsCanTake"); turnsCanTakeVar.Value = turnsCanTake; BehaviorManager.instance.Tick(); } var info = new TurnInfo(this) { turnInMotion = false, blockPlayerMovement = false, turnTaken = false }; return(info); }
public Player Apply(TurnInfo turn, IEnumerable<Player> queue) { if(turn.Own.Players.Contains(turn.Ball.Owner) || turn.Own.Players.Any(p => p.CanPickUpBall(turn.Ball))) { return null; } var ourCatchup = turn.CatchUps.FirstOrDefault(c => turn.Own.Players.Contains(c.Player)); if(ourCatchup != null) { ourCatchup.Player.ActionGo(ourCatchup.Position); return ourCatchup.Player; } return null; }
public void CheckToImprovePlanet(TurnInfo thisPlayer) { for (int i = 0; i < MasterScript.turnInfoScript.mostPowerfulPlanets.Count - 1; i++) { if (thisPlayer.power < 0.8f && thisPlayer.wealth < 1.0f) { break; } int j = MasterScript.RefreshCurrentSystem(MasterScript.turnInfoScript.mostPowerfulPlanets[i].system); if (MasterScript.systemListConstructor.systemList[j].systemOwnedBy == thisPlayer.playerRace) { ImprovePlanet(MasterScript.turnInfoScript.mostPowerfulPlanets[i].planetPosition, j, thisPlayer); } } }
public void CheckIfCanHire(TurnInfo player, string heroType) { if (player.wealth >= 50 && player.playerOwnedHeroes.Count < 7) { int i = MasterScript.RefreshCurrentSystem(GameObject.Find(player.homeSystem)); GameObject instantiatedHero = (GameObject)Instantiate(MasterScript.heroGUI.heroObject, MasterScript.systemListConstructor.systemList[i].systemObject.transform.position, MasterScript.systemListConstructor.systemList[i].systemObject.transform.rotation); instantiatedHero.name = "Basic Hero_" + heroCounter; HeroScriptParent tempHero = instantiatedHero.GetComponent <HeroScriptParent>(); tempHero.heroType = heroType; tempHero.heroLocation = MasterScript.systemListConstructor.systemList[i].systemObject; tempHero.heroOwnedBy = player.playerRace; HeroMovement tempMove = instantiatedHero.GetComponent <HeroMovement>(); instantiatedHero.transform.position = tempMove.HeroPositionAroundStar(tempHero.heroLocation); ++heroCounter; player.wealth -= 50; player.playerOwnedHeroes.Add(instantiatedHero); switch (tempHero.heroType) { case "Soldier": tempHero.classModifier = 1.75f; break; case "Infiltrator": tempHero.classModifier = 1f; break; case "Diplomat": tempHero.classModifier = 1.5f; break; } } }
public static TurnInfo Create(Team myTeam, Team enemyTeam, Ball ball, MatchInfo matchInfo) { var info = new TurnInfo() { Own = myTeam, Other = enemyTeam, Ball = ball, Match = matchInfo, }; info.Path = BallPath.Create(info); info.CatchUps = info.Path.GetCatchUp(info.Players).OrderBy(c => c.Turn).ToList(); info.HasPossession = myTeam.Players.Contains(ball.Owner) || myTeam.Players.Any(p => p.CanPickUpBall(ball)) || (info.CatchUps.Any() && myTeam.Players.Contains(info.CatchUps[0].Player)); return info; }
private int CheckNumberOfPlanetsWithImprovement(int improvementNo, TurnInfo thisPlayer, ImprovementsBasic improvements) { int currentPlanets = 0; for (int i = 0; i < MasterScript.systemListConstructor.mapSize; ++i) { if (MasterScript.systemListConstructor.systemList[i].systemOwnedBy == null || MasterScript.systemListConstructor.systemList[i].systemOwnedBy == thisPlayer.playerRace) { continue; } if (improvements.listOfImprovements[improvementNo].hasBeenBuilt == true) { ++currentPlanets; } } return(currentPlanets); }
public override TurnInfo TakeTurn() { TurnInfo info = new TurnInfo(this); //check any objects that are here, and if they have playerInput (better player check?) //push em. List <GridElement> itemsHereNow = new List <GridElement>(gridElement.tileNode.itemsHere); //clone the list becuase we may modify it when we move things that are in the lsit foreach (GridElement ge in itemsHereNow) { if (ge.GetComponent <Agent>() != null) { Debug.Log("floor trap on " + ge.gameObject.name); ge.GetComponent <Agent>().Move(GridUtility.DirToV2(pushDirection), false); //false is not using up a turn when pushing } } return(info); }
public ActionResult Turn([FromBody] TurnInfo turn) { var game = db.GameStates.SingleOrDefault(g => g.Id == turn.Id); if (game == null) { Response.StatusCode = 404; return(Content("Game doesn't exist")); } var field = new Field(game.GameField); if (field.Turn(turn.X, turn.Y)) { game.GameField = field.ToString(); db.GameStates.Update(game); db.SaveChanges(); } return(Json(game.GameField)); }
//public void StartPVPGame(string me, string enemy, string firstTurnNamePlayer) //{ // Client.instance.StartCommand = false; // GameControllerComponent.UiViewComponent.FirstPlayerName = me; // GameControllerComponent.UiViewComponent.SecondPlayerName = enemy; // //GameControllerComponent.ChooseMode(GameMode.PVP); // //if (me.Equals(firstTurnNamePlayer)) // //{ // // GameControllerComponent.BoardViewCompoennt.SetColorPlayer(UserColor.White); // // Client.instance.connectedClient.currentUser.UserColor = UserColor.White; // //} // //else // //{ // // GameControllerComponent.BoardViewCompoennt.SetColorPlayer(UserColor.Black); // // Client.instance.connectedClient.currentUser.UserColor = UserColor.Black; // // if (GameControllerComponent._moveCoroutine != null) // // StopCoroutine(GameControllerComponent._moveCoroutine); // // GameControllerComponent._moveCoroutine = GameControllerComponent.CoreInstance.SecondPlayerMove(); // // StartCoroutine(GameControllerComponent._moveCoroutine); // //} //} //public void StartMiningGame(string me) //{ // //Client.instance.StartCommand = false; // //GameControllerComponent.UiViewComponent.FirstPlayerName = me; // ////GameControllerComponent.ChooseMode(GameMode.Mining); // //GameControllerComponent.BoardViewCompoennt.SetColorPlayer(UserColor.White); // ////Client.instance.connectedClient.currentUser.UserColor = UserColor.White; //} public void TurnCheckerFromServer(TurnInfo turnInfo) { TurnCommand = false; var square = GameControllerComponent.CoreInstance._squaresData[turnInfo.Square.Id]; var checker = GameControllerComponent.CoreInstance._checkersData[turnInfo.Checker.Id]; Square intermediateSquare = null; if (turnInfo.IntermediateSquare != null) { intermediateSquare = GameControllerComponent.CoreInstance._squaresData[turnInfo.IntermediateSquare.Id]; } GameControllerComponent.CoreInstance.TryToMoveChekerAsync(checker, square, intermediateSquare); //Если мой ход if (GameControllerComponent.CoreInstance.CurrentMoveColor != checker.Color) { //if (turnInfo.Username.Equals(Client.instance.connectedClient.currentUser.Name)) //{ // if (GameControllerComponent._moveCoroutine != null) // StopCoroutine(GameControllerComponent._moveCoroutine); // GameControllerComponent._moveCoroutine = GameControllerComponent.CoreInstance.SecondPlayerMove(); // StartCoroutine(GameControllerComponent._moveCoroutine); //} //else //{ // GameControllerComponent.CoreInstance.IsBeatProcessActive = false; // GameControllerComponent.CoreInstance.IsEnemyMove = false; //} } else { GameControllerComponent.CoreInstance.IsBeatProcessActive = false; GameControllerComponent.CoreInstance.IsEnemyMove = false; } }
public Player Apply(TurnInfo turn, IEnumerable<Player> queue) { var enemyInfo = EnemyDistanceToGoal(turn.Other.Players).OrderBy(c => c.Distance).FirstOrDefault(); if (enemyInfo.Distance < CloseToTheGoal) { var playerInfo = PlayerDistanceToEnemy(queue, enemyInfo.Player).OrderBy(c => c.Distance).FirstOrDefault(); if (playerInfo.Distance < TackleDistance) { playerInfo.Player.ActionTackle(enemyInfo.Player); } else { playerInfo.Player.ActionGo(enemyInfo.Player.Position); } return playerInfo.Player; } return null; }
void Update() { if (PhotonNetwork.playerList.Length == 2 && PhotonNetwork.isMasterClient) { if (police == null) { police = new TurnInfo(); mafia = new TurnInfo(); PlaceGuys(); } if (police.isReady && mafia.isReady) { Debug.Log("Turn made!"); MoveGuys(); police.isReady = false; mafia.isReady = false; } } }
public void RacialBonus(TurnInfo player) { if (player.playerRace == "Humans") { if (player.systemsColonisedThisTurn > 0f) { ambitionCounter += player.systemsColonisedThisTurn * 4f * (60 / MasterScript.systemListConstructor.mapSize); } if (player.planetsColonisedThisTurn > 0f) { ambitionCounter += (player.planetsColonisedThisTurn - player.systemsColonisedThisTurn) * 2f * (60 / MasterScript.systemListConstructor.mapSize); } if (player.systemsColonisedThisTurn == 0 && player.planetsColonisedThisTurn == 0) { ambitionCounter -= 0.25f; } if (ambitionCounter < -100f) { ambitionCounter = -100f; } if (ambitionCounter > 100f) { ambitionCounter = 100f; } } if (player.playerRace == "Nereides") { player.researchCostModifier += elationStacks.Count; for (int i = 0; i < elationStacks.Count; ++i) { if (elationStacks[i].creationTime + elationStacks[i].maxAge < Time.time) { elationStacks.RemoveAt(i); i = -1; ++stacksDissolvedSinceLastUpdate; } } } }
public void sendTurnInfo() { var turnInfo = new TurnInfo(); if (isNowPlayerBlack == false) { turnInfo.isBlack = false; turnInfo.isMe = true; whitePlayer.sendData("TurnInfo", turnInfo); turnInfo.isMe = false; blackPlayer.sendData("TurnInfo", turnInfo); } else { turnInfo.isBlack = true; turnInfo.isMe = true; blackPlayer.sendData("TurnInfo", turnInfo); turnInfo.isMe = false; whitePlayer.sendData("TurnInfo", turnInfo); } }
public void DiplomatFunctions(int links, TurnInfo thisPlayer) { CheckTradeRoutesAreValid(thisPlayer); for (int i = 0; i < links; ++i) { ActivateCurrentTradeRoutes(i, thisPlayer); if (i >= allTradeRoutes.Count) { MakeNewTradeRoutes(thisPlayer); } } if (heroScript.heroOwnedBy == thisPlayer.playerRace) { systemSIMData = heroScript.heroLocation.GetComponent <SystemSIMData>(); systemSIMData.totalSystemPower += systemSIMData.totalSystemPower * (0.2f + thisPlayer.racePower); systemSIMData.totalSystemKnowledge += systemSIMData.totalSystemKnowledge * (0.2f + thisPlayer.raceKnowledge); } }
public void SystemSIMCounter(TurnInfo player) //This functions is used to add up all resources outputted by planets within a system, with improvement and tech modifiers applied { float tempTotalSci = 0.0f, tempTotalInd = 0.0f; secRecPowerMod = 1f; secRecKnowledgeMod = 1f; secRecPopulationMod = 1f; thisPlayer = player; CheckFrontLineBonus(); CheckSecRecBonus(thisSystem); CalculateSystemModifierValues(); int planetsColonised = 0; for (int j = 0; j < MasterScript.systemListConstructor.systemList[thisSystem].systemSize; ++j) { if (MasterScript.systemListConstructor.systemList[thisSystem].planetsInSystem[j].planetColonised == true) { ++planetsColonised; CheckForSecondaryResourceIncrease(j, player); tempTotalSci += CheckPlanetValues(j, "Knowledge"); tempTotalInd += CheckPlanetValues(j, "Power"); } } totalSystemWealth = player.raceWealth * planetsColonised * MasterScript.turnInfoScript.expansionPenaltyModifier; totalSystemKnowledge = (tempTotalSci + knowledgeUnitBonus) * MasterScript.turnInfoScript.expansionPenaltyModifier; totalSystemPower = (tempTotalInd + powerUnitBonus) * MasterScript.turnInfoScript.expansionPenaltyModifier; if (thisPlayer.playerRace == "Selkies") { MasterScript.racialTraitScript.IncreaseAmber(thisSystem); } IncreasePopulation(); totalSystemWealth -= improvementsBasic.upkeepWealth * improvementsBasic.upkeepModifier; totalSystemPower -= improvementsBasic.upkeepPower * improvementsBasic.upkeepModifier; totalSystemWealth += improvementsBasic.wealthBonus; player.wealth += totalSystemWealth; }
//ターンが終わってステージに戻る private void OnTriggerExitMethod(Collider other) { var rootTransform = other.GetComponentInParent <BaseCore>().transform; if (rootTransform == null) { return; } //入るときのコライダーを出たとき TurnInfo info = null; foreach (var item in turnList) { if (item.RotationTransform == rootTransform) { info = item; if (item.CanExit) { break; } return; } } if (info == null) { return; } info.Rotation.isActive = true; turnList.Remove(info); if (info.RotationTransform.tag == "Player") { outOfAreaUI.SetActive(false); } //print("exit"); }
public float CheckThroughPlanets(TurnInfo thisPlayer) { highestSIM = 0; for (int i = 0; i < MasterScript.systemListConstructor.mapSize; ++i) { if (MasterScript.systemListConstructor.systemList[i].systemOwnedBy == thisPlayer.playerRace) { systemDefence = MasterScript.systemListConstructor.systemList [i].systemObject.GetComponent <SystemDefence> (); if (systemDefence.underInvasion == true) { continue; } for (int j = 0; j < MasterScript.systemListConstructor.systemList[i].systemSize; ++j) { if (MasterScript.systemListConstructor.systemList[i].planetsInSystem[j].planetColonised == true || MasterScript.systemListConstructor.systemList[i].planetsInSystem[j].planetImprovementLevel == 3) { continue; } tempSIM = (MasterScript.systemListConstructor.systemList[i].planetsInSystem[j].planetKnowledge + MasterScript.systemListConstructor.systemList[i].planetsInSystem[j].planetPower) * (MasterScript.systemListConstructor.systemList[i].planetsInSystem[j].currentImprovementSlots * 1.5f); if (tempSIM > highestSIM) { highestSIM = tempSIM; tempPlanet = j; tempSystem = i; } } } } return(highestSIM); }
public void CharTurnEnd() { if (!OrderManager.instance.IsEmptyStack()) { return; } if (playerTurn) { battleHubControl.SetTurnEndButton(false); CancelTarget(); } OrderManager.instance.AddOrder(new sysOrder.TurnEndOrder()); OrderManager.instance.AddOrder(new sysOrder.WaitOrder(0.35f)); TurnInfo tif = TriggerManager.instance.GetTriggerInfo <TurnInfo>(); tif.SetInfo(currentActionCharacter); tif.GoTrigger(TriggerType.TurnEnding); tif.GoTrigger(TriggerType.TurnEndBefore); }
public Error GetTurnInfo(string gameId, int slot, out TurnInfo turnInfo) { turnInfo = null; var err = ludoService.GetIngame(gameId, out var ingame); if (err) { return(err); } if (!ingame.IsValidSlot(slot)) { return(Error.Codes.E10InvalidSlotIndex); } if (ingame.Slots[slot] == null) { return(Error.Codes.E16SlotIsEmpty); } turnInfo = ingame.TryGetTurnInfo(slot); return(turnInfo == null ? Error.Codes.E15NotYourTurn : Error.Codes.E00NoError); }
private void ActivateCurrentTradeRoutes(int i, TurnInfo thisPlayer) { if (i < allTradeRoutes.Count) { int pSys = allTradeRoutes[i].playerSystem; int eSys = allTradeRoutes[i].enemySystem; SystemSIMData playerSystemData = MasterScript.systemListConstructor.systemList[pSys].systemObject.GetComponent <SystemSIMData>(); SystemSIMData enemySystemData = MasterScript.systemListConstructor.systemList[eSys].systemObject.GetComponent <SystemSIMData>(); float playerPowerTransfer = playerSystemData.totalSystemPower / 2; float playerKnowledgeTransfer = playerSystemData.totalSystemKnowledge / 2; float enemyPowerTransfer = enemySystemData.totalSystemPower / 2; float enemyKnowledgeTransfer = enemySystemData.totalSystemKnowledge / 2; playerSystemData.totalSystemPower += playerPowerTransfer; playerSystemData.totalSystemKnowledge += playerKnowledgeTransfer; enemySystemData.totalSystemPower += enemyPowerTransfer; enemySystemData.totalSystemKnowledge += enemyKnowledgeTransfer; } }
protected override string RunPart1Solution(List <string> inputs, Dictionary <string, string> variables) { List <int> numbers = inputs[0].Split(",").Select(int.Parse).ToList(); Dictionary <long, TurnInfo> turns = new Dictionary <long, TurnInfo>(); long index = 1; long prevNumber = 0; foreach (int number in numbers) { turns[number] = new TurnInfo { Index = index++, PrevIndex = -1 }; prevNumber = number; } while (true) { TurnInfo turnInfo = turns[prevNumber]; long curNumber = turnInfo.GetNext(); if (index == 2020) { return(curNumber.ToString()); } if (!turns.ContainsKey(curNumber)) { turns[curNumber] = new TurnInfo { Index = index++, PrevIndex = -1 }; } else { turns[curNumber].Bump(index++); } prevNumber = curNumber; } }
public void SendTurn(Checker checker, Square square, Square target = null) { var CheckerDto = new NetMessaging.Turns.Checker { Id = checker.Id, IsSuperChecker = checker.IsSuperChecker }; var SquareDto = new NetMessaging.Turns.Square { Id = square.Id, Position = new NetMessaging.Turns.Position { X = square.Position.X, Y = square.Position.Y } }; CheckerColor checkerColor; if (NetworkController.instance.GameControllerComponent.CoreInstance.CurrentMoveColor == CheckerColor.White) { checkerColor = CheckerColor.White; } else { checkerColor = CheckerColor.Black; } var turnInfo = new TurnInfo { LobbyId = Client.instance.lobbyInfo.Id, Token = currentUser.Token, Checker = CheckerDto, CheckerColor = checkerColor, Square = SquareDto, IntermediateSquare = target != null ? new NetMessaging.Turns.Square { Id = target.Id } : null }; var message = Client.MakeJsonMessage(nameof(TurnInfo), turnInfo); Send(message); }
public static void BeginTurn() { CurrentGooseIndex++; if (CurrentGooseIndex >= Gooses.Length) { CurrentGooseIndex = 0; } AGoose currentGoose = Gooses[CurrentGooseIndex]; currentGooseRenderer.sprite = goosesSprites[CurrentGooseIndex]; //Refresh current goose sprite OnBeginTurn(currentGoose); //If a gooze must pass its turn if (currentGoose.TurnInfo.NbTurnToPass > 0) { currentGoose.TurnInfo = TurnInfo.Builder().NbTurnToPass(currentGoose.TurnInfo.NbTurnToPass - 1).Build(); EndTurn(); return; } currentGoose.TakeTurn(); }
private void CheckTradeRoutesAreValid(TurnInfo thisPlayer) { for (int i = 0; i < allTradeRoutes.Count; ++i) //For all existing trade routes { int playerSystem = allTradeRoutes[i].playerSystem; //Get the player system int enemySystem = allTradeRoutes[i].enemySystem; bool invalidRoute = false; if (MasterScript.systemListConstructor.systemList[playerSystem].systemOwnedBy != thisPlayer.playerRace) //If this system is not owned by this player { invalidRoute = true; //This trade route is invalidated } if (MasterScript.systemListConstructor.systemList[enemySystem].systemOwnedBy != allTradeRoutes[i].enemySystemOwner) //Or the enemy system has changed owned { invalidRoute = true; //This trade route is invalidated } if (invalidRoute == true) //If the trade route is no longer valid { GameObject.Destroy(allTradeRoutes[i].connectorObject); //Destroy it allTradeRoutes.RemoveAt(i); } } }
public Player Apply(TurnInfo turn, IEnumerable<Player> queue) { var keeper = GetClosestBy(queue); if (keeper != null) { var catchup = turn.CatchUps.FirstOrDefault(); // give it just a best try. if (catchup == null) { keeper.ActionWait(); } else { var vector = (catchup.Position - Field.MyGoal.Center); vector.Normalize(); var target = Field.MyGoal.Center + vector * 150; keeper.ActionGo(target); } } return keeper; }
private TurnInfo RenderPlayers(GameDTO game) { var turn = new TurnInfo(); MyTeam.Children.Clear(); OtherTeam.Children.Clear(); bool meBlue = game.TeamOne.Any(p => (p as PlayerParticipant)?.AccountId == Session.Current.Account.AccountID); foreach (var thing in game.TeamOne.Concat(game.TeamTwo)) { var player = thing as PlayerParticipant; var bot = thing as BotParticipant; var obfusc = thing as ObfuscatedParticipant; bool blue = game.TeamOne.Contains(thing); UserControl control; if (player != null) { var selection = game.PlayerChampionSelections?.FirstOrDefault(c => c.SummonerInternalName == player.SummonerInternalName); control = new ChampSelectPlayer(player, selection); if (player.PickTurn == game.PickTurn) { if (player.SummonerId == Session.Current.Account.SummonerID) { turn.IsMyTurn = turn.IsOurTurn = true; } else if (meBlue == blue) { turn.IsOurTurn = true; } } } else if (bot != null) { control = new ChampSelectPlayer(bot); } else if (obfusc != null) { control = new ChampSelectPlayer(obfusc, null); } else { Session.Log(thing.GetType().Name); control = null; } if (blue == meBlue) { MyTeam.Children.Add(control); } else { OtherTeam.Children.Add(control); } } if (OtherTeam.Children.Count == 0) OtherTeam.Visibility = Visibility.Collapsed; Ban1.Source = Ban2.Source = Ban3.Source = Ban4.Source = Ban5.Source = Ban6.Source = null; Image[] blueBans, redBans; if (meBlue) { blueBans = new[] { Ban1, Ban2, Ban3 }; redBans = new[] { Ban4, Ban5, Ban6 }; } else { blueBans = new[] { Ban4, Ban5, Ban6 }; redBans = new[] { Ban1, Ban2, Ban3 }; } foreach (var thing in game.BannedChampions) { var champ = DataDragon.GetChampData(thing.ChampionId); var image = DataDragon.GetChampIconImage(champ); int index = thing.PickTurn - 1; if (index % 2 == 0) { //0, 2, 4: Blue team's bans blueBans[thing.PickTurn / 2].Source = image.Load(); } else { //1, 3, 5: Red team's bans redBans[thing.PickTurn / 2].Source = image.Load(); } } //Dispatcher.BeginInvoke((Action) (() => MyTeam.Height = OtherTeam.Height = Math.Max(MyTeam.ActualHeight, OtherTeam.ActualHeight)), System.Windows.Threading.DispatcherPriority.Input); return turn; }
void Start() { currentTurnInfo = new TurnInfo(); gameManager = GetComponent<GameManager>(); }
public void resetCurrentTurnInfo() { currentTurnInfo = new TurnInfo(); }
public Player Apply(TurnInfo info, IEnumerable<Player> queue) { var owner = queue.FirstOrDefault(p => p == info.Ball.Owner); // We are not the owner. if (owner == null) { return null; } var ownerDistanceToGoal2 = (Field.EnemyGoal.Center - owner.Position).LengthSquared; if(!info.Other.Players.Any(p => (p.Position - Field.EnemyGoal.Center).LengthSquared < ownerDistanceToGoal2)) { if (ownerDistanceToGoal2 < 150 * 150) { owner.ActionShootGoal(); } else { owner.ActionGo(Field.EnemyGoal.Center); } return owner; } var shotOnGoalTop = Field.EnemyGoal.Top - owner.Position; var shotOnGoalCen = Field.EnemyGoal.Center - owner.Position; var shotOnGoalBot = Field.EnemyGoal.Bottom - owner.Position; var accuracy = Statistics.GetAccuracy(10, 0.75f); var shotAngle = Theta.Create(shotOnGoalTop, shotOnGoalBot); if (shotAngle > 2f * accuracy) { if (!info.Other.Players.Any(oppo => MightCatch(oppo.Position - owner.Position, shotOnGoalCen, 10, 0.75f))) { owner.ActionShootGoal(); return owner; } } var passCandidates = info.Own.Players .Where(p => p != owner && IsCandidate(owner, p, ownerDistanceToGoal2)) .OrderBy(p => (Field.EnemyGoal.Center - p.Position).LengthSquared) .ToList(); if (!passCandidates.Any()) { owner.ActionGo(Field.EnemyGoal.Center); return owner; } var oppos = info.Other.Players.Where(p => p.Position.X > owner.Position.X).ToList(); foreach (var z in PassingZs) { foreach (var power in PassingPowers) { var safe = new List<Player>(); foreach (var candidate in passCandidates) { if (!info.Other.Players.Any(oppo => MightCatch(oppo.Position - owner.Position, candidate.Position - owner.Position, power, z))) { safe.Add(candidate); } } if (safe.Any()) { var target = safe.OrderBy(s => (s.Position - Field.EnemyGoal.Center).LengthSquared).FirstOrDefault(); owner.ActionShoot(target, PassingPower); return owner; } } } // else run. owner.ActionGo(Field.EnemyGoal.Center); return owner; }
private bool InitiativeIsOurs(TurnInfo turn) { var closestPlayer = turn.Ball.Owner ?? turn.CatchUps.First().Player; return turn.Own.Players.Contains(closestPlayer); }