예제 #1
0
		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));
			}
		}
예제 #2
0
 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;
		}
예제 #4
0
		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));
		}
예제 #5
0
파일: Game.cs 프로젝트: psmon/chessgo
    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());
    }
예제 #6
0
파일: PlayDol.cs 프로젝트: psmon/chessgo
    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);
        }
    }
예제 #7
0
 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;
         }
     }
 }
예제 #8
0
        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;
            }
        }
예제 #9
0
    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);
    }
예제 #10
0
    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;
    }
예제 #11
0
    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;
        }
    }
예제 #12
0
 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());
     }
 }
예제 #13
0
    public void CheckWin(TurnInfo thisPlayer)
    {
        player = thisPlayer;

        InvasionWin();
        ExpansionWin();
        DiplomaticWin();
        EconomicWin();
        ScientificWin();
        PointWin();

        if (winPlayer != null)
        {
            Debug.Log(winPlayer + " | " + winCondition);
        }
    }
예제 #14
0
    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);
    }
예제 #15
0
		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;
		}
예제 #16
0
    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);
            }
        }
    }
예제 #17
0
    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;
            }
        }
    }
예제 #18
0
		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;
		}
예제 #19
0
    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);
    }
예제 #20
0
    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);
    }
예제 #21
0
        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));
        }
예제 #22
0
    //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;
        }
    }
예제 #23
0
		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;
		}
예제 #24
0
    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;
            }
        }
    }
예제 #25
0
    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;
                }
            }
        }
    }
예제 #26
0
        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);
            }
        }
예제 #27
0
    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);
        }
    }
예제 #28
0
    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;
    }
예제 #29
0
    //ターンが終わってステージに戻る
    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");
    }
예제 #30
0
    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);
    }
예제 #31
0
    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);
    }
예제 #32
0
        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);
        }
예제 #33
0
    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;
        }
    }
예제 #34
0
        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;
            }
        }
예제 #35
0
    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);
    }
예제 #36
0
    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();
    }
예제 #37
0
    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);
            }
        }
    }
예제 #38
0
		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;
		}
예제 #39
0
    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;
    }
예제 #40
0
        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;
        }
예제 #41
0
 void Start()
 {
     currentTurnInfo = new TurnInfo();
     gameManager = GetComponent<GameManager>();
 }
예제 #42
0
 public void resetCurrentTurnInfo()
 {
     currentTurnInfo = new TurnInfo();
 }
예제 #43
0
		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;
		}
예제 #44
0
		private bool InitiativeIsOurs(TurnInfo turn)
		{
			var closestPlayer = turn.Ball.Owner ?? turn.CatchUps.First().Player;
			return turn.Own.Players.Contains(closestPlayer);
		}