Exemplo n.º 1
0
        public int AnalystRiskOption(int jobType, GameBattle gameBattle, int riskId)
        {
            var riskOptionId = 0;

            if (jobType == (int)JobType.ExpertSpecialist)
            {
                if (gameBattle != null)
                {
                    //Opportunity to expert Specialist Thinking
                    var expertSpecialistRandomLevel = CommonFunction.RandomNumber(1, 10);
                    if (expertSpecialistRandomLevel > 4) // random 5-10 จะได้ option ที่ถูก
                    {
                        riskOptionId = gameBattle.RiskOptionId;
                    }
                    else
                    {
                        // ถ้า random 0-4 จะต้องมาสุ่มเลือกว่าจะเลือก level 0 - 2
                        var randomLevel   = CommonFunction.RandomNumber(0, 2);
                        var allRiskOption = _service.Risk().GetAllRiskOptionByRiskId(riskId, randomLevel);
                        if (allRiskOption.Any())
                        {
                            riskOptionId = allRiskOption.FirstOrDefault().RiskOptionId;
                        }
                    }
                }
                else
                {
                    // ถ้าหาไม่เจอ ให้ลองเสี่ยง 0 - 1
                    var expertRandomLevelIgnore = CommonFunction.RandomNumber(0, 1);
                    var allRiskOption           = _service.Risk().GetAllRiskOptionByRiskId(riskId, expertRandomLevelIgnore);
                    if (allRiskOption.Any())
                    {
                        riskOptionId = allRiskOption.FirstOrDefault().RiskOptionId;
                    }
                }
            }
            else if (jobType == (int)JobType.Newbies)
            {
                var newbiesRandomLevel = CommonFunction.RandomNumber(0, 1);
                var allRiskOption      = _service.Risk().GetAllRiskOptionByRiskId(riskId, newbiesRandomLevel);
                if (allRiskOption.Any())
                {
                    riskOptionId = allRiskOption.FirstOrDefault().RiskOptionId;
                }
            }
            return(riskOptionId);
        }
 public GameStateGameload(GameBattle battle) : base(battle)
 {
     // Debug.Log("Game State: GameLoad");
 }
Exemplo n.º 3
0
 public BattleLoadingStage(GameBattle battle)
     : base(battle)
 {
     
 }
Exemplo n.º 4
0
 public GameStateLevelload(GameBattle battle) : base(battle)
 {
 }
Exemplo n.º 5
0
 public GameStateLobby(GameBattle battle) : base(battle)
 {
 }
Exemplo n.º 6
0
 private RhodesGame()
 {
     battle   = new GameBattle();
     stateMgr = new GameStateMgr(battle);
 }
Exemplo n.º 7
0
    public BattleRoundPlayingStage(GameBattle battle)
        : base(battle)
    {

    }
 public GameStateBase(GameBattle battle)
 {
     _battle = battle;
 }
Exemplo n.º 9
0
        private List <GameBattle> GenerateWorkProcess(int gameRoomId, List <Risk> risks, int turn)
        {
            var gameBattleList = new List <GameBattle>();

            if (risks.Any())
            {
                var maxRisk    = risks.Count > 15 ? 15 : risks.Count;
                var randomTake = CommonFunction.RandomNumber(1, maxRisk);
                foreach (var risk in risks.OrderBy(x => Guid.NewGuid()).Take(randomTake))
                {
                    var isProbability = true;
                    if (risk.RiskType == (int)RiskType.General)
                    {
                        isProbability = CommonFunction.IsProbability(risk.RiskProbability);
                    }

                    if (isProbability)
                    {
                        var randomRiskOptionLevel = CommonFunction.RandomNumber(1, 3);
                        var riskOption            = risk.RiskOptions.FirstOrDefault(x => x.RiskLevel == randomRiskOptionLevel);
                        if (riskOption != null)
                        {
                            int?riskNewsId = null;
                            var riskNews   = GetRandomRiskNews(risk.RiskId, risk.RiskProbability.GetValueOrDefault());
                            if (riskNews != null)
                            {
                                riskNewsId = riskNews.RiskNewsId;
                            }

                            var game = new GameBattle
                            {
                                GameRoomId        = gameRoomId,
                                RiskId            = risk.RiskId,
                                RiskOptionId      = riskOption.RiskOptionId,
                                Ratio             = CommonFunction.RandomNumber(1, 3),
                                Turn              = turn,
                                ActionEffectType  = riskOption.ActionEffectType,
                                ActionEffectValue = riskOption.ActionEffectValue,
                                RiskNewsId        = riskNewsId
                            };
                            gameBattleList.Add(game);
                        }
                    }
                }

                if (!gameBattleList.Any())
                {
                    var defaultRisk = risks.OrderBy(x => Guid.NewGuid()).LastOrDefault();
                    var riskOption  = defaultRisk.RiskOptions.FirstOrDefault(x => x.RiskLevel == (int)RiskGameLevel.FirstLevel);
                    var game        = new GameBattle
                    {
                        GameRoomId        = gameRoomId,
                        RiskId            = defaultRisk.RiskId,
                        RiskOptionId      = riskOption.RiskOptionId,
                        Ratio             = CommonFunction.RandomNumber(1, 3),
                        Turn              = turn,
                        ActionEffectType  = riskOption.ActionEffectType,
                        ActionEffectValue = riskOption.ActionEffectValue
                                            // no news
                    };
                    gameBattleList.Add(game);
                }

                return(gameBattleList);
            }
            return(null);
        }
Exemplo n.º 10
0
 public void AddGameBattle(GameBattle entity)
 {
     _gameBattle.Add(entity);
 }
Exemplo n.º 11
0
    public static void HandleBattle(this PhotonController controller, EventData eventData, GameStatus type)
    {
        SubCode subCode = (SubCode)eventData[(byte)ParameterCode.SubCode];

        //Debug.Log("subCode " + subCode);
        switch (subCode)
        {
        case SubCode.Invite:
        {
            //int senderID = (int)eventData[(byte)ParameterCode.UserId];

            //GameUser inviterBattle = (GameUser)GameManager.ZoneUsers[senderID];
            //UIInviterManager.Instance.AddInviter(inviterBattle);
        }
        break;

        case SubCode.Refuse:
        {
            MessageBox.CloseDialog();
            MessageBox.ShowDialog(GameManager.localization.GetText("Dialog_Refuse"), UINoticeManager.NoticeType.Message);
        }
        break;

        case SubCode.Begin:
        {
            GameplayManager.battleStatus = GameplayManager.BattleStatus.Start;

            byte[] rolesData  = (byte[])eventData[(byte)ParameterCode.BattleRoles];
            byte[] battleData = (byte[])eventData[(byte)ParameterCode.BattleData];

            battleTime = (float)eventData[(byte)ParameterCode.BattleTime];



            GameBattle gameBattle = Serialization.Load <GameBattle>(battleData);


            if (gameBattle.User01.Id != GameManager.GameUser.Id)
            {
                GameManager.EnemyUser         = gameBattle.User01;
                GameManager.GameUser.Position = gameBattle.User02.Position;
            }
            else
            {
                GameManager.GameUser.Position = gameBattle.User01.Position;
                GameManager.EnemyUser         = gameBattle.User02;
            }

            GameObjCollection battleRoles = Serialization.Load <GameObjCollection>(rolesData, true);

            GameplayManager.InitRoles(battleRoles);

            MessageBox.CloseDialog();

            GameScenes.ChangeScense(GameScenes.previousSence, GameScenes.MyScene.Battle);

            GameManager.Status = type;
            battleType         = gameBattle.Mode;
        }
        break;
        }
    }
Exemplo n.º 12
0
 public void SaveGameBattleAsync(GameBattle gameBattle)
 {
     _gameBattle.AddAsync(gameBattle);
 }
 public GameStateBattle(GameBattle battle) : base(battle)
 {
     this._battle = battle;
 }
Exemplo n.º 14
0
    public BattleRoundStartStage(GameBattle battle)
        : base(battle)
    {

    }
Exemplo n.º 15
0
 public BattleStageBase(GameBattle battle)
 {
     theBattle = battle;
 }
Exemplo n.º 16
0
    public BattleStartupStage(GameBattle battle)
        : base(battle)
    {

    }