public static BattleFieldModel GetBattleField(int gameId) { var context = new BattleGameEntities(); using (context) { Game game = GetGame(gameId, context); ValidateGameInProgressStatus(game, context); var redUnitModels = GetUserUnits(game.RedUser, game); var blueUnitModels = GetUserUnits(game.BlueUser, game); var gameField = new BattleFieldModel() { GameId = (int)game.Id, Title = game.Title, Red = new UserInGameModel() { Nickname = game.RedUser.Nickname, Units = redUnitModels }, Blue = new UserInGameModel() { Nickname = game.BlueUser.Nickname, Units = blueUnitModels }, Turn = game.Turn, PlayerInTurn = (game.UserInTurn == game.RedUser.Id) ? "red" : "blue" }; return(gameField); } }
public GameObject BuildObject(int width, int height) { GameObject prefab = Resources.Load <GameObject>("BattleField"); BattleFieldModel p = prefab.GetComponent <BattleFieldModel>(); p.areaWidth = width; p.areaHeight = height; return(prefab); }
public override void OnEnterState() { role = BattleStateMechine.Instance.CurrentRole; battleModel = BattleManager.Instance.GetModel(); //显示移动范围 BattleboxHelper.Instance.ShowBlocks(BattleStateMechine.Instance.CurrentMoveList); //显示技能动作面板 Jyx2_UIManager.Instance.ShowUI("BattleActionUIPanel", role, BattleManager.BattleViewStates.SelectMove); }
public HttpResponseMessage GetBattleField(string sessionKey, int gameId) { var responseMsg = this.PerformOperation(() => { UserDataPersister.LoginUser(sessionKey); BattleFieldModel gameField = GameDataPersister.GetBattleField(gameId); return gameField; }); return responseMsg; }
public void StartBattle(BattleStartParams customParams) { Debug.Log("StartBattle called"); if (IsInBattle) { return; } if (!BattleboxHelper.Instance.CanEnterBattle(_player.View.transform.position)) { return; } IsInBattle = true; m_battleParams = customParams; //初始化战斗model BattleModel = new BattleFieldModel(); //初始化范围逻辑 rangeLogic = new RangeLogic(BattleboxHelper.Instance.IsBlockExists, BattleModel.BlockHasRole); //状态初始化 HSUtilsEx.CallWithDelay(this, () => { Debug.Log("-----------HSUtilsEx.CallWithDelay"); BattleboxHelper.Instance.EnterBattle(_player.View.transform.position); //地图上所有单位进入战斗 foreach (var item in m_battleParams.roles) { if (item.View.m_Behavior == MapRoleBehavior.Enemy) { item.EnterBattle(1); } else { item.EnterBattle(0); } } BattleModel.InitBattleModel(); //战场初始化 行动顺序排序这些 BattleStateMechine.Instance.StartStateMechine(OnBattleEnd); //交给战场状态机接管 状态机完成会回调回来 //提示UI Jyx2_UIManager.Instance.ShowUI("CommonTipsUIPanel", TipsType.MiddleTop, "战斗开始"); Jyx2_UIManager.Instance.ShowUI("BattleMainUIPanel", BattleMainUIState.ShowHUD);//展示角色血条 }, 0.5f); var brain = Camera.main.GetComponent <CinemachineBrain>(); if (brain != null) { brain.m_DefaultBlend = new CinemachineBlendDefinition(CinemachineBlendDefinition.Style.Cut, 0); } }
public override void OnEnterState() { model = BattleManager.Instance.GetModel(); if (BattleStateMechine.Instance.CurrentRole != null) { BattleStateMechine.Instance.CurrentRole.View.Idle();//上一个播放Idle动画 model.OnActioned(BattleStateMechine.Instance.CurrentRole); } BattleStateMechine.Instance.BindRole(null);//先清除绑定 if (model == null) { GameUtil.LogError("状态错误,BattleFieldModel数据不存在"); return; } var result = model.GetBattleResult(); if (result != BattleResult.InProgress) { BattleStateMechine.Instance.StopStateMechine(result); return; } }
private void Awake() { model = GetComponent <BattleFieldModel>(); view = GetComponent <BattleFieldView>(); }
public override void OnLeaveState() { model = null; }