Esempio n. 1
0
        public void UpdatePlatforms()
        {
            // We need to duplicate everything to control updates of the launch data manually.
            LaunchingSegment = new TurnData(_currentTurn.CurrentTurn.Turn, _currentTurn.CurrentTurn.Impulse);

            LaunchingUnitPosition = _hexVectorUtility.CloneHexVector <HexGridCoordinate>(_launchingUnit.Position);
            TargetUnitPosition    = _hexVectorUtility.CloneHexVector <HexGridCoordinate>(_targetUnit.Position);

            LaunchingUnitVelocity = _hexVectorUtility.CloneHexVector <RawHexVector>(_launchingUnit.Vectors);
            TargetUnitVelocity    = _hexVectorUtility.CloneHexVector <RawHexVector>(_targetUnit.Vectors);

            CrossingVector = _hexGridCalculator.GetCrossingVector(LaunchingUnitVelocity, TargetUnitVelocity);

            TargetDistance = _hexGridCalculator.GetDistance(LaunchingUnitPosition, TargetUnitPosition);
            CourseOffset   = 0;
            if (AvidVector.IsNullOrZero(TargetDistance))
            {
                TargetDistance = _hexGridCalculator.GetVectorFromBacktracking(LaunchingUnitVelocity, TargetUnitVelocity);
                OnVerificationRequired();
            }
            else
            {
                SubmitBearingVerificationResult(TargetDistance);
            }
        }
    private void nextTurn()
    {
        slider.value = 0;
        gameData.player.UpdateEffects();
        enemy.UpdateEffects();

        //Player never clicked - auto lose
        if (!hasClicked)
        {
            //log this?
            ResolveBattle(Outcome.Lose, Accuracy.Fail);
        }

        CheckHealth();

        //Reset for next turn
        LogValue();
        EnemyDmgText.text  = "";
        PlayerDmgText.text = "";
        isCooldown         = !isCooldown;
        hasClicked         = false;
        hasClickedItem     = false;

        currentTurnData = enemy.getNextTurnData();
        HighlightCurrentTurnInfo();

        totalTurnTimer = currentTurnData.duration;
        cooldownTimer  = 0;
        turnTimer      = 0;
        ClickValue     = 0;
        turnText.text  = "";
        roundCount++;

        UpdateStats();
    }
        private static void CreateLoadSitRepMappings()
        {
            Mapper.CreateMap <HexVectorComponentSto, HexVectorComponent>()
            .ForMember(hvc => hvc.Direction, ac => ac.MapFrom(vcs => Enum.Parse(typeof(HexAxis), vcs.Direction)))
            .ForMember(hvc => hvc.Magnitude, ac => ac.MapFrom(vcs => vcs.Value));

            Mapper.CreateMap <HexVectorSto, RawHexVector>()
            .ForMember(hvc => hvc.Components, ac => ac.Ignore())
            .AfterMap((hvs, rhv) => rhv.AddComponents(Mapper.Map <IEnumerable <HexVectorComponentSto>, IEnumerable <HexVectorComponent> >(hvs.Components)));

            Mapper.CreateMap <ImpulseRecordSto, ImpulseTrackElement>()
            .ForMember(ite => ite.Impulse, ac => ac.MapFrom(irs => TurnData.Parse(irs.Impulse)));

            Mapper.CreateMap <ShellstarSto, ShellstarInfo>();

            Mapper.CreateMap <UnitSto, UnitModel>()
            .ForMember(um => um.Position, ac => ac.MapFrom(uns => HexGridCoordinate.Parse(uns.Position)))
            .ForMember(um => um.Vectors, ac => ac.MapFrom(uns => uns.Velocity))
            .AfterMap((uns, um) => uns.IncomingProjectiles.ForEach(st =>
            {
                var evasionInfo    = new EvasionInfoModel(AvidWindow.Parse(st.EvasionInfo.ImpactWindow), AvidWindow.Parse(st.EvasionInfo.EvasionUp).Direction);
                var shellstarModel = new ShellstarModel(Mapper.Map <ShellstarSto, ShellstarInfo>(st), TurnData.Parse(st.SegmentOfLaunch), evasionInfo);
                shellstarModel.Tag = st.Tag;
                um.AttachShellstar(shellstarModel);
            }));
        }
Esempio n. 4
0
        void Loggable.addTurn(Player player, Point point)
        {
            TurnData CurrentMove = new TurnData(player, point);

            stack.Push(CurrentMove);
            return;
        }
    public void RestartGame()
    {
        ClearItemButtons();
        ClearTurnInfo();
        turnTimer      = 0;
        cooldownTimer  = 0;
        hasClicked     = false;
        hasClickedItem = false;
        ClickValue     = 0;
        isCooldown     = false;
        isPaused       = true;
        isStart        = false;
        startTimer     = 3;

        this.enemy = EnemyFactory.GenerateEnemy(gameData.player.Level, UnityEngine.Random.Range(-1f, 1f), gameData.assetData);
        this.enemy.AttachGameController(this);

        currentTurnData    = enemy.getNextTurnData();
        EnemyDmgText.text  = "";
        PlayerDmgText.text = "";
        roundCount         = 1;
        logText.text       = "";

        LoadPlayerItemButtons();

        UpdateStats();

        InitTurnInfoPanel();
        splashScreenScript.Show();
    }
Esempio n. 6
0
 private ActionPlan checkDeath(TurnData t)
 {
     for (int i = 255; i >= 0; --i)
         if (engine.getPlayerCells()[i].isDead())
             Death(i);
     return null;
 }
Esempio n. 7
0
    private TurnData MakeTurnData(WTurnData turn)
    {
        List <StatsUpdateData> stDataList = new List <StatsUpdateData>();

        for (int i = 0; i < turn.status_update_data.Length; i++)
        {
            StatsUpdateData stData = new StatsUpdateData();

            stData.ownerID           = turn.status_update_data[i].owner_id;
            stData.finalStats        = MakeBattleObject(turn.status_update_data[i].final_stats);
            stData.singleStatChanges = MakeSingleStatChangeList(turn.status_update_data[i].single_stat_changes);

            stDataList.Add(stData);
        }

        var turnData = new TurnData(
            turn.turn_id,
            new List <int>(turn.eligible_spells),
            new List <int>(turn.eligible_secrets),
            new List <CoolDownData>(), //Spells
            new List <CoolDownData>(), //Secret
            turn.ap[0],
            turn.ap[1],
            stDataList);

        return(turnData);
    }
Esempio n. 8
0
 public TurnDataWrapper(string room_id, string user_id, TurnData turnData, string room_name = "", string turnType = "normalPawn")
 {
     this.room_name = room_name;
     this.room_id   = room_id;
     this.user_id   = user_id;
     this.turnData  = turnData;
     this.turnType  = turnType;
 }
Esempio n. 9
0
        public ShellstarModel(ShellstarInfo shellstar, TurnData timeOfLaunch, IEvasionInfoModel evasionInfo)
        {
            ValidateShellstar(shellstar);
            _shellstar = shellstar;
            _counterfire = new List<ShellstarInfo>();
            _evasionInfo = evasionInfo;

            TimeOfLaunch = timeOfLaunch;
        }
Esempio n. 10
0
        public ShellstarModel(ShellstarInfo shellstar, TurnData timeOfLaunch, IEvasionInfoModel evasionInfo)
        {
            ValidateShellstar(shellstar);
            _shellstar   = shellstar;
            _counterfire = new List <ShellstarInfo>();
            _evasionInfo = evasionInfo;

            TimeOfLaunch = timeOfLaunch;
        }
Esempio n. 11
0
        private void AssignImpulseInformation(ShellstarInfo shellstarInfo, TurnData startingImpulse)
        {
            // Need to advance it, so we make a copy.
            var currentImpulse = startingImpulse.DeepCopy();

            for (int i = 0; i < shellstarInfo.ImpulseTrack.Count; i++)
            {
                shellstarInfo.ImpulseTrack[i].Impulse = currentImpulse;
                currentImpulse = currentImpulse.GetNextImpulse();
            }
        }
Esempio n. 12
0
    public Turn(Match match)
    {
        this.match = match;

        data = new TurnData();

        firstTurnPlayed[match.player1.id] = false;
        firstTurnPlayed[match.player2.id] = false;

        PickFirstPlayer();
    }
Esempio n. 13
0
 void OnTurnEnd(ClickScript cs, TurnData data)
 {
     if (data.type == TurnType.dungeon)
     {
         if (cs.hp.current < 3)
         {
             cs.hp.current += 1;
             cs.OnHealthChanged(1);
         }
     }
 }
Esempio n. 14
0
    public void PrepareSparepawnData(string targetSquareId)
    {
        GridData        from            = new GridData("", "", "");
        GridData        to              = new GridData(targetSquareId, "", "");
        TurnData        turnData        = new TurnData(from, to);
        TurnDataWrapper turnDataWrapper = new TurnDataWrapper(Database.GetString(Database.Key.ROOM_ID), Database.GetString(Database.Key.PLAYER_ID), turnData, Database.GetString(Database.Key.ROOM_NAME), "sparePawn");
        string          data            = JsonUtility.ToJson(turnDataWrapper);

        socket.EmitJson(GameEmits.sparePawnTurn.ToString(), data);
        GameManager.instance.currentGameState = GameManager.GAMESTATE.NONE;
    }
Esempio n. 15
0
        async Task IGamePlayService.MakeMoveAsync(MoveModel move, CancellationToken cancellationToken)
        {
            var game = await ValidateMoveInternalAsync(move, cancellationToken : cancellationToken);

            var turns = await _turnRepository.GetTurnsByGameIdAsync(game.Id, cancellationToken : cancellationToken);

            var currentTurn = turns
                              .Where(x => !x.EndTime.HasValue)
                              .OrderByDescending(x => x.StartTime)
                              .FirstOrDefault();

            var turnUpdate = new TurnUpdateData
            {
                EndTime = DateTime.UtcNow,
            };

            await _turnRepository.UpdateTurnAsync(currentTurn.Id, turnUpdate, cancellationToken : cancellationToken);

            var currentMove = new MoveData
            {
                GameDeckCardCollectionId = move.GameDeckCardCollectionId,
                Column = move.Column,
                Row    = move.Row,
                TurnId = currentTurn.Id,
            };

            await _moveRepository.AddMoveAsync(currentMove, cancellationToken : cancellationToken);

            var nextUserId = game.UserIds
                             .SkipWhile(x => x != move.UserId)
                             .Skip(1)
                             .FirstOrDefault();

            if (nextUserId == default)
            {
                nextUserId = game.UserIds.First();
            }

            var newTurn = new TurnData
            {
                CurrentUserId = nextUserId,
                GameId        = game.Id,
                StartTime     = DateTime.UtcNow,
            };

            await _turnRepository.AddTurnAsync(newTurn, cancellationToken : cancellationToken);

            var gameUpdate = new GameUpdateData
            {
                CurrentUserId = nextUserId,
            };
            await _gameRepository.UpdateGameAsync(game.Id, gameUpdate, cancellationToken : cancellationToken);
        }
Esempio n. 16
0
    public void PrepareTurnData(GridData f, GridData t, string turnType = "normalType")
    {
        TurnData        turnData        = new TurnData(f, t);
        TurnDataWrapper turnDataWrapper = new TurnDataWrapper(Database.GetString(Database.Key.ROOM_ID), Database.GetString(Database.Key.PLAYER_ID), turnData, Database.GetString(Database.Key.ROOM_NAME), turnType);
        string          data            = JsonUtility.ToJson(turnDataWrapper);

        Debug.Log("Turn Submitted: " + data);
        socket.EmitJson(GameEmits.turnSubmited.ToString(), data);
        if (turnType == "normalType")
        {
            GameManager.instance.currentGameState = GameManager.GAMESTATE.NONE;
        }
    }
Esempio n. 17
0
    private void OnTurnChanged(TurnData turnData)
    {
        DivineDebug.Log("Turn Changed Num of update Stats: " + turnData.updatedStats.Count +
                        " Char: " + GetCharacterWithID(turnData.turnId).moniker, DivineLogType.Warn);
        DivineDebug.Log("Eligible Spells: " + turnData.eligibleSpells.Count);

        for (int i = 0; i < _parties.Length; i++)
        {
            if (_parties[i].side == PartySide.Player)
            {
                _parties[i].SetActionPoint(turnData.allyReceivedActionPoints, true);
            }
            else
            {
                _parties[i].SetActionPoint(turnData.enemyReceivedActionPoints, true);
            }
        }

        for (int i = 0; i < turnData.updatedStats.Count; i++)
        {
            DivineDebug.Log("UpdateStat: Char: " + FindCharacter(turnData.updatedStats[i].ownerID) +
                            " FinalHP: " + turnData.updatedStats[i].finalStats.hp +
                            "Shield: " + turnData.updatedStats[i].finalStats.shield +
                            "flag: " + turnData.updatedStats[i].finalStats.flags.ToString());

            for (int j = 0; j < turnData.updatedStats[i].singleStatChanges.Count; j++)
            {
                DivineDebug.Log("singleStatChange: type: " +
                                turnData.updatedStats[i].singleStatChanges[j].charStatChangeType.ToString() + " intval: "
                                + turnData.updatedStats[i].singleStatChanges[j].intVal);
            }

            if (_parties[0].ContainCharacter(turnData.updatedStats[i].ownerID))
            {
                _parties[0].UpdateCharacterStats(turnData.updatedStats[i]);
            }
            else
            {
                _parties[1].UpdateCharacterStats(turnData.updatedStats[i]);
            }
        }

        _waitingCharacterIDToSelect      = turnData.turnId;
        _waitingEligibleSpellsForSelect  = turnData.eligibleSpells;
        _waitingEligibleSecretsForSelect = turnData.eligibleSecrets;

        _waitingCooldownSpells  = turnData.coolDownSpells;
        _waitingCooldownSecrets = turnData.coolDownSecrets;

        TryToStartNextTurn();
    }
Esempio n. 18
0
        public override void TurnSimulate(int turn, Dictionary <string, TurnData> turnDatas)
        {
            // setting turn data.
            foreach (KeyValuePair <string, TurnData> p in turnDatas)
            {
                string   uuid     = p.Key;
                TurnData turnData = p.Value;
                foreach (IInputCommand command in turnData.Commands)
                {
                    Debug.Log($"{uuid} - {command}");
                }
            }

            // generate render command.
        }
    private void OnBattleTurnChanged(Divine.BattleTurnData turn)
    {
        var updateStats = analyzer_.ChangeTurn(turn.StatUpdate);
        var turnData    = new TurnData(
            turn.Turn, turn.EligibleSpell.ToList(), turn.EligibleSecret.ToList(),
            turn.CoolDownSpell.Select(ToCoolDownData).ToList(),
            turn.CoolDownSecret.Select(ToCoolDownData).ToList(),
            turn.GeneratedActionPoint[0], turn.GeneratedActionPoint[1],
            updateStats);

        if (TurnChanged != null)
        {
            TurnChanged(turnData);
        }
    }
    private void UpdateSendTurnPacket()
    {
        mSubTurnNumber++;
        if (mSubTurnNumber == kSubTurnPerTurn)
        {
            TurnData data = new TurnData(mPlayerId, CustomRandom.mInstance.GetValue_v2(), InputManager.mIntance.GetCommandList(), ComputeCRC());

            OutputMemoryBitStream output = new OutputMemoryBitStream();
            output.Write(kTurnCC);
            output.Write(mTurnNumber + 2);
            output.Write(mPlayerId);
            data.Write(ref output);

            foreach (var pair in mPlayerIdToEndpointDic)
            {
                SendPacket(output, pair.Value);
            }
            if (mTurnData.ContainsKey(mTurnNumber + 2))
            {
                try
                {
                    mTurnData[mTurnNumber + 2].Add(mPlayerId, data);
                }
                catch (ArgumentException ex)
                {
                    mTurnData[mTurnNumber + 2][mPlayerId] = data;
                }
            }
            else
            {
                mTurnData.Add(mTurnNumber + 2, new Dictionary <int, TurnData>());
                mTurnData[mTurnNumber + 2].Add(mPlayerId, data);
            }
            //Debug.Log("send " + (mTurnNumber + 2) + " " + mPlayerId);
            //Debug.Log((mTurnNumber + 2) + " " + data.GetCommandList().GetCount());
            InputManager.mIntance.NewCommandList();

            if (mTurnNumber >= 0)
            {
                TryAdvanceTurn();
            }
            else
            {
                mTurnNumber++;
                mSubTurnNumber = 0;
            }
        }
    }
Esempio n. 21
0
        public static async Task TakeTurn(int whoIsTurn, int pos, int beforeSign, string opponentId)
        {
            var turnData = new TurnData
            {
                WhoTurn = whoIsTurn,
                CurrentPositionSelect = pos,
                BeforeSign            = beforeSign
            };

            var dataToSend = JsonConvert.SerializeObject(turnData);

            if (GameService.GSLive.IsTurnBasedAvailable())
            {
                await GameService.GSLive.TurnBased().TakeTurn(dataToSend, opponentId);
            }
        }
    public void Save()
    {
        BinaryFormatter bf   = new BinaryFormatter();
        FileStream      file = File.Create(Application.persistentDataPath + "/turnData.nut");
        TurnData        data = new TurnData();

        //<<<-------------SAVING DATA--------------->>>
        data.firstEncounter = firstEncounter;
        data.turnNumber     = turnNumber;
        loadedTurnNum       = turnNumber;
        //<<<-------------END OF SAVING DATA--------------->>>

        //need a different file for each data
        bf.Serialize(file, data);
        file.Close();
    }
Esempio n. 23
0
        /// <summary>
        /// Sauvegarde des données avant le l'affichage
        /// </summary>
        private void saveData()
        {
            TableData tableData;
            TurnData  turnData = new TurnData();

            foreach (Table table in lstTable)
            {
                tableData = new TableData(table);
                if (table.PlayerPro != null)
                {
                    tableData.setPlayerPro(table.PlayerPro);
                }
                turnData.addTableData(tableData);
            }
            turnData.setPlayerPro(playerPro);
            gameData.addTurnData(turnData);
        }
Esempio n. 24
0
        async Task <TurnData> ITurnRepository.AddTurnAsync(TurnData turn, CancellationToken cancellationToken)
        {
            var newTurn = new Turn
            {
                CurrentGameUserFk = turn.CurrentGameUserId,
                GameFk            = turn.GameId,
                StartTime         = DateTime.UtcNow,
            };

            _context.Turn.Add(newTurn);
            await _context.SaveChangesAsync(cancellationToken : cancellationToken);

            turn.Id        = newTurn.TurnPk;
            turn.StartTime = newTurn.StartTime;

            return(turn);
        }
        /// <summary>
        /// Serialises all body properties. The output will be a dictionary containing the
        /// body of the request in a form that can easily be converted to Json. Will return
        /// an empty dictionary if there is no body.
        /// </summary>
        ///
        /// <returns>The body Json in dictionary form.</returns>
        public IDictionary <string, object> SerialiseBody()
        {
            var dictionary = new Dictionary <string, object>();

            // Match Id
            dictionary.Add("MatchID", MatchId);

            // State Data
            if (StateData != null)
            {
                dictionary.Add("StateData", StateData.Serialise());
            }

            // Turn Data
            if (TurnData != null)
            {
                dictionary.Add("TurnData", TurnData.Serialise());
            }

            // Write Lock
            if (WriteLock != null)
            {
                dictionary.Add("WriteLock", WriteLock);
            }

            // Completed
            if (Completed != null)
            {
                dictionary.Add("Completed", Completed);
            }

            // Outcome Data
            if (OutcomeData != null)
            {
                dictionary.Add("OutcomeData", OutcomeData.Serialise());
            }

            // Outcome Attachment
            if (OutcomeAttachment != null)
            {
                dictionary.Add("OutcomeAttachment", OutcomeAttachment);
            }

            return(dictionary);
        }
    public void Load()
    {
        if (File.Exists(Application.persistentDataPath + "/turnData.nut"))
        {
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Open(Application.persistentDataPath + "/turnData.nut", FileMode.Open);
            TurnData        data = (TurnData)bf.Deserialize(file);

            //<<<-------------LOADING DATA--------------->>>
            loadedFromTurnNumber = turnNumber;
            turnNumber           = data.turnNumber;
            firstEncounter       = data.firstEncounter;
            turnCount.GetComponentInChildren <Text>().text = "Day: " + turnNumber;
            //<<<-------------END OF LOADING DATA--------------->>>

            file.Close();
        }
    }
    private void HandleTurnPacket(ref InputMemoryBitStream input, EndPoint _inEndpoint)
    {
        if (mEndpointToPlayerIdDic.ContainsKey(_inEndpoint))
        {
            int id       = mEndpointToPlayerIdDic[_inEndpoint];
            int playerid = -1;
            int turnNum  = -1;
            input.Read(ref turnNum);
            input.Read(ref playerid);

            if (id != playerid)
            {
                return;
            }
            TurnData data = new TurnData();
            data.Read(ref input);
            //Debug.Log(turnNum + " " + playerid + " " + data.GetCommandList().GetCount());
            if (mTurnData.ContainsKey(turnNum))
            {
                try
                {
                    mTurnData[turnNum].Add(playerid, data);
                }
                catch (ArgumentException ex)
                {
                    mTurnData[turnNum][playerid] = data;
                }
            }
            else
            {
                mTurnData.Add(turnNum, new Dictionary <int, TurnData>());
                mTurnData[turnNum].Add(playerid, data);
            }
            //try
            //{
            //    mTurnData[turnNum].Add(playerid, data);
            //}
            //catch (ArgumentException)
            //{
            //    mTurnData[turnNum][playerid] = data;
            //}
        }
    }
Esempio n. 28
0
        public void AddPly(string notation)
        {
            TurnData data;
            bool     addedp2 = false;

            if (_turnData.Count == 0 || _turnData[_turnData.Count - 1].P2Notation != null)
            {
                data            = new TurnData();
                data.MoveNumber = _turnData.Count + 1;
                data.P1Notation = notation;
                _turnData.Add(data);
            }
            else
            {
                data            = _turnData[_turnData.Count - 1];
                data.P2Notation = notation;
                addedp2         = true;
            }
            this.SelectedPly = _turnData.Count * 2 - (addedp2 ? 1 : 2);
        }
Esempio n. 29
0
        /// <summary>
        /// Serialises all properties. The output will be a dictionary containing the
        /// objects properties in a form that can easily be converted to Json.
        /// </summary>
        ///
        /// <returns>The serialised object in dictionary form.</returns>
        public IDictionary <string, object> Serialise()
        {
            var dictionary = new Dictionary <string, object>();

            // Turn Data
            if (TurnData != null)
            {
                dictionary.Add("TurnData", TurnData.Serialise());
            }

            // Player
            if (Player != null)
            {
                dictionary.Add("Player", Player.Serialise());
            }

            // Date Submitted
            dictionary.Add("DateSubmitted", JsonSerialisation.Serialise(DateSubmitted));

            return(dictionary);
        }
Esempio n. 30
0
        private async Task PrepareGameForPlayAsync(int id, int[] userIds, CancellationToken cancellationToken)
        {
            var randomUserIds = userIds.OrderBy(x => RandomNumberGenerator.GetInt32(int.MinValue, int.MaxValue)).ToArray();
            var currentUserId = randomUserIds[0];

            var updateGame = new GameUpdateData
            {
                CurrentUserId = currentUserId,
            };

            await _gameRepository.UpdateGameAsync(id, updateGame, cancellationToken : cancellationToken);

            await _gameRepository.UpdateGameUsersOrderAsync(id, randomUserIds, cancellationToken : cancellationToken);

            var newTurn = new TurnData
            {
                CurrentUserId = currentUserId,
                GameId        = id,
            };
            await _turnRepository.AddTurnAsync(newTurn, cancellationToken : cancellationToken);
        }
Esempio n. 31
0
    void ReplayTurn(TurnData turnData)
    {
        Piece piece;
        int   i;

        // red moves
        for (i = 0; i < turnData.RM.Count; i++)
        {
            piece = _redTeam.LookupPiece(turnData.RM[i].ID);
            if (piece != null)
            {
                piece.SetReplayPosition(new Vector2(turnData.RM[i].X, turnData.RM[i].Y), turnData.RM[i].T, turnData.RM[i].S);
                if (turnData.RM[i].F)
                {
                    _blueFlag.SetPosition(new Vector2(turnData.RM[i].X, turnData.RM[i].Y));
                }
            }
        }
        // blue moves
        for (i = 0; i < turnData.BM.Count; i++)
        {
            piece = _blueTeam.LookupPiece(turnData.BM[i].ID);
            if (piece != null)
            {
                piece.SetReplayPosition(new Vector2(turnData.BM[i].X, turnData.BM[i].Y), turnData.BM[i].T, turnData.BM[i].S);
                if (turnData.BM[i].F)
                {
                    _redFlag.SetPosition(new Vector2(turnData.BM[i].X, turnData.BM[i].Y));
                }
            }
        }
        // throws
        for (i = 0; i < turnData.T.Count; i++)
        {
            Throw data = turnData.T[i];
            ThrowBalloon((TeamColor)data.C, new Vector3(data.SX, data.SY, 0.0f), new Vector3(data.TX, data.TY, 0.0f), (AmmoType)data.T);
        }
    }
Esempio n. 32
0
        public ShellstarInfo BuildShellstarInfo(int targetDistance, TurnData startingImpulse, FiringSolution firingSolution, MissileAccelerationData missileAcceleration)
        {
            if (firingSolution == null)
            {
                throw new ArgumentNullException("firingSolution", "Firing solution is needed to calculate shellstar data.");
            }

            int dmg50,
                dmg100,
                dmg200;

            _projectileDamageTable.GetDamages(firingSolution.RoC, out dmg50, out dmg100, out dmg200);

            var result = new ShellstarInfo
            {
                RoC    = firingSolution.RoC,
                Dmg50  = dmg50,
                Dmg100 = dmg100,
                Dmg200 = dmg200,
            };

            float inertialFlightDistance = (missileAcceleration != null) ?
                                           // Burnout range rounded down.
                                           (float)Math.Floor(targetDistance - missileAcceleration.BurnDistance) :
                                           targetDistance;

            BuildInertialSegments(result, inertialFlightDistance, firingSolution, missileAcceleration != null);

            if (missileAcceleration != null)
            {
                BuildAccelerationSegments(result, targetDistance, missileAcceleration);
            }

            result.ImpulseTrack.Reverse();
            AssignImpulseInformation(result, startingImpulse);

            return(result);
        }
Esempio n. 33
0
        public ShellstarInfo BuildShellstarInfo(int targetDistance, TurnData startingImpulse, FiringSolution firingSolution, MissileAccelerationData missileAcceleration)
        {
            if (firingSolution == null)
            {
                throw new ArgumentNullException("firingSolution", "Firing solution is needed to calculate shellstar data.");
            }

            int dmg50,
                dmg100,
                dmg200;

            _projectileDamageTable.GetDamages(firingSolution.RoC, out dmg50, out dmg100, out dmg200);

            var result = new ShellstarInfo
            {
                RoC = firingSolution.RoC,
                Dmg50 = dmg50,
                Dmg100 = dmg100,
                Dmg200 = dmg200,
            };

            float inertialFlightDistance = (missileAcceleration != null) ?
                // Burnout range rounded down.
                (float)Math.Floor(targetDistance - missileAcceleration.BurnDistance) :
                targetDistance;

            BuildInertialSegments(result, inertialFlightDistance, firingSolution, missileAcceleration != null);

            if (missileAcceleration != null)
            {
                BuildAccelerationSegments(result, targetDistance, missileAcceleration);
            }

            result.ImpulseTrack.Reverse();
            AssignImpulseInformation(result, startingImpulse);

            return result;
        }
Esempio n. 34
0
 public CurrentTurnModel()
 {
     CurrentTurn = new TurnData();
 }
Esempio n. 35
0
        private void onTableClick(DOMEvent evt) {
            if (_turnClientId == ClientId) {
                var el = evt.target.As<HtmlElement>();
                if (el is HtmlTableCellElement) {
                    var cell = el.As<HtmlTableCellElement>();
                    var row = cell.parentNode.As<HtmlTableRowElement>();
                    //el.innerHTML = _figure;

                    TurnData data = new TurnData(ClientId);
                    data.x = cell.cellIndex;
                    data.y = JsContext.parseInt(row.getAttribute("rowIdx"), 10);
                    data.figure = _figure;
                    
                    Server.Send(data);
                }
            }
        }
Esempio n. 36
0
	// Update is called once per frame
	void Update () {
        if (current_turnholder == null)
        {
            var teams = GetTeamCount();
            if (!teams.ContainsKey(0))
                gm.defeat.SetActive(true);
            if (!teams.ContainsKey(1))
                gm.victory.SetActive(true);

            var nume = order.GetEnumerator();
            while (nume.MoveNext())
            {
                var nume2 = nume.Current.Value.GetEnumerator();
                while (nume2.MoveNext())
                {
                    if (nume2.Current.Hold())
                    {
                        on_hold.Add(nume2.Current);
                    }
                    else
                    {
                        current_turnholder = nume2.Current;
                        float time_to_advance = nume.Current.Key;
                        while (nume2.MoveNext())
                        {
                            if (!new_order.ContainsKey(0.0f))
                                new_order.Add(0.0f, new List<ClickScript>());
                            new_order[0.0f].Add(nume2.Current);
                        }
                        while (nume.MoveNext())
                            new_order.Add(nume.Current.Key - time_to_advance, nume.Current.Value);
                        current_turnholder.my_turn = true;
                        current_turnholder.advance = 0.0f;
                    }
                }
            }
        }
        if (current_turnholder != null)
        {
            cam.target = current_turnholder;
            while (current_turnholder.advance>0.0f)
            {
                TurnData data = new TurnData();
                data.time = current_turnholder.advance;
                data.type = TurnType.battle;
                current_turnholder.OnTurnEnd(data);
                if (current_turnholder.advance>0.0f)
                {
                    current_turnholder.my_turn = false;
                    if (!new_order.ContainsKey(current_turnholder.advance))
                        new_order.Add(current_turnholder.advance, new List<ClickScript>());
                    new_order[current_turnholder.advance].Add(current_turnholder);
                    order = new_order;
                    new_order = new Dictionary<float, List<ClickScript>>();
                    current_turnholder = null;
                    break;
                }
            }
        }
	}
Esempio n. 37
0
 public void Turn(TurnData data) {
     Client.inst.onTurn(data);
 }
Esempio n. 38
0
 public void SetTime(string newTime)
 {
     CurrentTurn = TurnData.Parse(newTime);
     OnTimeChanged();
 }
Esempio n. 39
0
 public CurrentTurnModel()
 {
     CurrentTurn = new TurnData();
 }
Esempio n. 40
0
        public void UpdatePlatforms()
        {
            // We need to duplicate everything to control updates of the launch data manually.
            LaunchingSegment = new TurnData(_currentTurn.CurrentTurn.Turn, _currentTurn.CurrentTurn.Impulse);

            LaunchingUnitPosition = _hexVectorUtility.CloneHexVector<HexGridCoordinate>(_launchingUnit.Position);
            TargetUnitPosition = _hexVectorUtility.CloneHexVector<HexGridCoordinate>(_targetUnit.Position);

            LaunchingUnitVelocity = _hexVectorUtility.CloneHexVector<RawHexVector>(_launchingUnit.Vectors);
            TargetUnitVelocity = _hexVectorUtility.CloneHexVector<RawHexVector>(_targetUnit.Vectors);

            CrossingVector = _hexGridCalculator.GetCrossingVector(LaunchingUnitVelocity, TargetUnitVelocity);

            TargetDistance = _hexGridCalculator.GetDistance(LaunchingUnitPosition, TargetUnitPosition);
            CourseOffset = 0;
            if (AvidVector.IsNullOrZero(TargetDistance))
            {
                TargetDistance = _hexGridCalculator.GetVectorFromBacktracking(LaunchingUnitVelocity, TargetUnitVelocity);
                OnVerificationRequired();
            }
            else
            {
                SubmitBearingVerificationResult(TargetDistance);
            }
        }
Esempio n. 41
0
 private void renderFigure(TurnData data) {
     var row = _table.rows[data.y].As<HtmlTableRowElement>();
     var cell = row.cells[data.x].As<HtmlTableCellElement>();
     if ((data.figure == EState.blue)) {
         js.addClass(cell, "tableCellX");
     }
     else {
         js.addClass(cell, "tableCell0");
     }
 }
Esempio n. 42
0
        private void AssignImpulseInformation(ShellstarInfo shellstarInfo, TurnData startingImpulse)
        {
            // Need to advance it, so we make a copy.
            var currentImpulse = startingImpulse.DeepCopy();

            for (int i = 0; i < shellstarInfo.ImpulseTrack.Count; i++)
            {
                shellstarInfo.ImpulseTrack[i].Impulse = currentImpulse;
                currentImpulse = currentImpulse.GetNextImpulse();
            }
        }
Esempio n. 43
0
 public ShellstarModel(ShellstarInfo shellstar, TurnData timeOfLaunch)
     :this(shellstar, timeOfLaunch, new EvasionInfoModel())
 { }
Esempio n. 44
0
	void OnTurnEnd(ClickScript cs, TurnData data)
	{
		if (data.type == TurnType.battle)
			bonus = 0;
	}
Esempio n. 45
0
 public HexGridCoordinate GetMapPosition(HexGridCoordinate targetPosition, TurnData turnData)
 {
     throw new NotImplementedException();
 }
Esempio n. 46
0
        public void onTurn(TurnData turnData) {
            JsString message = turnData.message;
            if (turnData.message == "") {
                renderFigure(turnData);

                _turnClientId = turnData.nextClientId;
                RefreshTurn();
            }
            else if (turnData.message == "turn again") {
            }
            else if (message.indexOf("winn") == 0) {
                js.addClass(_table, turnData.message);

                renderFigure(turnData);

                if (turnData.ClientId == ClientId) {
                    HtmlContext.window.alert("You winn");
                }
                else {
                    HtmlContext.window.alert("You loss");
                }

                ResetGameData resetGameData = new ResetGameData(ClientId);
                resetGameData.GameId = turnData.GameId;
                Server.Send(resetGameData);
            }
            else if (turnData.message == "equal") {
                renderFigure(turnData);

                HtmlContext.window.alert("equal");
            }
        }