Пример #1
0
    public static SpaceshipRig RigForBattle(int playerId, int battleId)
    {
        List <int> rigIdsInBattles = new List <int>();
        var        battles         = Battle.BattlesForPlayer(playerId, true);

        foreach (var battle in battles)
        {
            rigIdsInBattles.Add(battle.RigId);
        }
        BattleSceneType     sceneType = BattleSceneType.SceneById(battleId);
        List <SpaceshipRig> rigList   = PlayerRigs(playerId);

        foreach (var rig in rigList)
        {
            if (rig.ForBattleId == battleId)
            {
                return(rig);
            }
            if (sceneType.AssembleShip == 1)
            {
                if (!rigIdsInBattles.Contains(rig.Id))
                {
                    return(rig);
                }
            }
        }
        return(null);
    }
Пример #2
0
    /// <summary>
    /// Когда надо продолжить сражение
    /// </summary>
    /// <param name="battle"></param>
    public BattleScene(Battle battle)
    {
        SceneType       = BattleSceneType.SceneById(battle.BattleSceneTypeId);
        CycleToComplete = SceneType.CycleToComplete;

        //Starting with 5 cycles and then add some more
        Cycles = new List <Cycle>();
        for (int i = 1; i <= 20; i++)
        {
            Cycle curCycle = new Cycle(SceneType, i, battle.MaxOpenedCycle, battle.MaxOpenedStage);
            Cycles.Add(curCycle);
        }
    }
Пример #3
0
        public HttpResponseMessage ContinueBattle(int battleSceneId)
        {
            string steamId  = User.Identity.Name;
            int    playerId = PlayerDataSql.PlayerId(steamId);

            Battle      battle  = Battle.BattleByTypeId(playerId, battleSceneId);
            BattleScene tBattle = new BattleScene(BattleSceneType.SceneById(battleSceneId));

            battle.battleScene = new UnityBattleScene(tBattle);
            battle.Rig         = SpaceshipRig.RigById(battle.RigId);

            string serializedElement = JsonConvert.SerializeObject(battle);

            serializedElement = CommonFunctions.Compress(serializedElement);
            var response = new HttpResponseMessage(HttpStatusCode.OK);

            response.Content = new StringContent(serializedElement);
            return(response);
        }
Пример #4
0
    /// <summary>
    /// Запуск нового экземпляра сражения
    /// </summary>
    public static Battle CreateBattle(int playerId, int battleSceneId, int rigId, bool forceCreate)
    {
        List <Battle> playerBattles = BattlesForPlayer(playerId, true);
        Battle        curBattle     = new Battle();

        curBattle.PlayerId          = playerId;
        curBattle.Ongoing           = 1;
        curBattle.BattleSceneTypeId = battleSceneId;
        curBattle.RigId             = rigId;
        curBattle.DateStart         = DateTime.Now;
        curBattle.Successfull       = 0;
        curBattle.CurrentCycle      = 1;
        curBattle.CurrentStage      = 1;
        curBattle.MaxOpenedCycle    = 1;
        curBattle.MaxOpenedStage    = 1;
        curBattle.ShipExperience    = 0;
        curBattle.ShipOpenedSkills  = "";
        BattleScene tBattle = new BattleScene(BattleSceneType.SceneById(curBattle.BattleSceneTypeId));

        curBattle.battleScene     = new UnityBattleScene(tBattle);
        curBattle.GainedResources = new PlayerResources();
        curBattle.SaveData();
        return(curBattle);
    }