private IEnumerator DeleteChess(List <Chess> seekChessList, Chess touchChess) { int x = touchChess.data.XPos; int y = touchChess.data.YPos; int count = seekChessList.Count; for (int i = 0; i < seekChessList.Count; i++) { Destroy(seekChessList[i].gameObject); seekChessList[i] = null; } if (touchChess.data.ChessTypeEnum == ChessTypeEnum.None && count >= 3) { ChessData chessData = new ChessData(); chessData.XPos = x; chessData.YPos = y; chessData.id = GetID(); chessData.ChessColorTypeEnum = touchChess.data.ChessColorTypeEnum; SpawnSkill(chessData, count); } score += count; UIMgr.instance.UpdateScore(score); fillIng = true; yield return(new WaitForSeconds(0.2f)); CheckoutBoard(); yield return(new WaitForSeconds(0.5f)); fillIng = false; }
private void SpawnSkill(ChessData chessData, int count) { ChessTypeEnum chessTypeEnum = ChessTypeEnum.None; if (count >= 7) { //同色消除 chessTypeEnum = ChessTypeEnum.Color; } else if (count >= 5) { chessData.ChessColorTypeEnum = ChessColorTypeEnum.None; //行消除或列消除 if (Random.Range(0, 2) == 0) { chessTypeEnum = ChessTypeEnum.Column; } else { chessTypeEnum = ChessTypeEnum.Line; } } else if (count >= 3) { chessData.ChessColorTypeEnum = ChessColorTypeEnum.None; chessTypeEnum = ChessTypeEnum.Nine; //三宫格消除 } chessData.ChessTypeEnum = chessTypeEnum; Chess chess = SpawnSkillChess(chessData); chess.transform.position = new Vector3(chessData.XPos + GameConfig.Xlen, chessData.YPos + GameConfig.Ylen, 0); }
private Chess SpawnSkillChess(ChessData chessData) { GameObject chessModel = Instantiate(chessObj, transform); Chess chess = chessModel.GetComponent <Chess>(); chess.InitSkill(chessData); chessList[chessData.XPos, chessData.YPos] = chess; return(chess); }
public virtual void InitData(ChessData data, UChessBoard board) { this.name = data.name; this.campType = data.campType; this.point = data.point; this.prefab = data.prefab; this.chessType = data.chessType; _chessboard = board; }
ChessData ChessHeroDataToChessData(PlayerInfo playerInfo, ChessHeroData chessHero) { ChessData chessData = new ChessData(); chessData.ChessRemoteId = chessHero.remoteId; chessData.Belong = playerInfo.ZoneId + "/" + playerInfo.UserId; chessData.Group = (int)chessHero.group; chessData.Point = chessHero.point.ParseToRpc(); return(chessData); }
public HistoryStep BuildHistoryStep(int counter, ChessData source, ChessData target, ChessDataPath path, int result) { HistoryStep re = new HistoryStep(); re.Counter = counter; re.Source = source; re.Target = target; re.Path = path; re.Result = result; return(re); }
public HistoryStep BuildHistoryStep(int counter, ChessHeroData source, ChessPoint targetPoint, ChessDataPath path, int result) { ChessData s = new ChessData(); s.ChessRemoteId = source.remoteId; s.Belong = source.belong; s.ChessType = source.realChessType; s.Point = source.point.ParseToRpc(); ChessData t = new ChessData(); t.Point = targetPoint.ParseToRpc(); return(BuildHistoryStep(counter, s, t, path, result)); }
/// <summary> /// 生成单个棋子 /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <returns></returns> private Chess SpawnChess(int x, int y) { GameObject chessModel = Instantiate(chessObj, transform); Chess chess = chessModel.GetComponent <Chess>(); ChessData chessData = new ChessData(); chessData.id = GetID(); chessData.ChessColorTypeEnum = (ChessColorTypeEnum)Random.Range(0, 4); chessData.XPos = x; chessData.YPos = y; chess.Init(chessData); chessList[x, y] = chess; return(chess); }
private void initWithChessData(ChessData cd) { GameObject [] go = GameObject.FindGameObjectsWithTag("chess"); foreach (GameObject obj in go) { Destroy(obj); } for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { gameBoard [i, j] = cd.gameBoard [i, j]; } } isChecked = false; state = cd.state; whiteCount = cd.whiteCount; blackCount = cd.blackCount; initTurnTitle(); for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (gameBoard [i, j] == 0) { chessManArray [i, j] = null; } else { GameObject chessMan = null; if (gameBoard [i, j] == 1) { chessMan = GameObject.Instantiate(chessWhite, transform.position, Quaternion.identity) as GameObject; } else { chessMan = GameObject.Instantiate(chessBlack, transform.position, Quaternion.identity) as GameObject; } chessMan.transform.SetParent(this.transform); chessMan.transform.SetSiblingIndex(0); chessMan.transform.localScale = new Vector3(1, 1, 1); chessMan.GetComponent <BoardCell> ().setPosition(i, j); chessManArray [i, j] = chessMan; } } } checkedCell.GetComponent <Image> ().enabled = true; checkedCell.GetComponent <BoardCell> ().setPosition(cd.checkedY, cd.checkedX); }
/// <summary> /// /// </summary> /// <param name="chessData"></param> /// <param name="forceTrans">是否强制坐标转换</param> /// <returns></returns> ChessHeroData ChessDataToChessHeroData(ChessData chessData, bool forceTrans = false) { ChessHeroData chess = new ChessHeroData(); chess.group = App.Package.ChessGame.GetGroup(chessData.Belong); chess.heroTypeId = chessData.ChessType; chess.realChessType = chess.heroTypeId; chess.remoteId = chessData.ChessRemoteId; chess.point = ChessPoint.ParseFromRpc(chessData.Point); chess.belong = chessData.Belong; if (chess.group != ChessHeroGroup.Myself || forceTrans) { chess.point.x = 4 - chess.point.x; chess.point.y = 11 - chess.point.y; } return(chess); }
/// <summary> /// 補血超過該角色上限時觸發 /// <param name="org">補血者</param> /// <param name="target">被補血者</param> /// <param name="over">超過數值</param> /// <param name="tType">被補血者陣營</param> public void OverRecovery(int org, int target, int over, string[] tType) { mainOrgIdx = org; mainTargetIdx = target; mainTarget = tType.ToString().Split('_'); targetSkills = mainTarget[1] == "P" ? playerTriggerSkill : enemyTriggerSkill; if (targetSkills.ContainsKey(mainOrgIdx)) { foreach (RuleLargeData data in playerTriggerSkill[mainOrgIdx].ruleData) { if (data.rule [0] == (int)Rule.Over) { mainOrgData = fightController.GetChessData(mainTarget[0], mainOrgIdx); OnEffectTarget(AddParameter(false, data, over)); } } } }
public List <ChessData> GetChessData(ChessHeroGroup group) { List <ChessData> list = new List <ChessData>(); foreach (var item in m_ChessData) { if (item.Value.group == group) { ChessData chess = new ChessData(); chess.ChessRemoteId = item.Value.remoteId; chess.Group = (int)item.Value.group; chess.Point = item.Value.point.ParseToRpc(); chess.ChessType = item.Value.heroTypeId; list.Add(chess); } } return(list); }
public List <ChessData> ParseChessDataFromString(string data, string belong) { List <ChessData> chessList = new List <ChessData>(); int baseId = GetBaseId(belong); int offsetY = 0; ChessHeroGroup group = (ChessHeroGroup)(baseId / 100); string[] rows = data.Split(';'); for (int i = 0; i < rows.Length && i < 6; i++) { string[] chessTypeIds = rows[i].Split(','); for (int j = 0; j < chessTypeIds.Length; j++) { string id = chessTypeIds[j]; if (id != "") { int type = -1; int remoteId = 0; if (id.IndexOf("|") > -1) { string[] ids = id.Split('|'); type = int.Parse(ids[0]); remoteId = int.Parse(ids[1]); } else { type = int.Parse(id); } ChessData heroData = new ChessData(); heroData.ChessType = type; heroData.ChessRemoteId = remoteId; heroData.Group = (int)group; heroData.Belong = belong; heroData.Point = new Com.Violet.Rpc.ChessPoint(); heroData.Point.X = j; heroData.Point.Y = offsetY + i; chessList.Add(heroData); } } } return(chessList); }
/// <summary> /// 攻擊時觸發技能 /// <param name="orgData">攻擊者資料</param> /// <param name="targetData">被攻擊者資料</param> /// <param name="allDamage">傷害資料</param> public void OnTriggerSkill(ChessData orgData, ChessData targetData, List <DamageData> allDamage) { mainOrgIdx = allDamage [0].orgIdx; mainTargetIdx = allDamage [0].targetIdx; mainTarget = allDamage [0].tType; mainOrgData = orgData; mainTargetData = targetData; orgSkills = mainTarget[0] == "P" ? playerTriggerSkill : enemyTriggerSkill; targetSkills = mainTarget[1] == "P" ? playerTriggerSkill : enemyTriggerSkill; if (orgSkills.ContainsKey(mainOrgIdx)) { OnSkillSelfRule(orgSkills[mainOrgIdx], allDamage); } if (targetSkills.ContainsKey(mainTargetIdx)) { OnSkillExternalRule(targetSkills[mainTargetIdx], allDamage); } }
public void AddChessFromData(List <ChessData> chessList) { PlayerInfo playerInfo = App.Package.Player.playerInfo; string belong = playerInfo.ZoneId + "/" + playerInfo.UserId; Dictionary <ChessHeroGroup, int> map = new Dictionary <ChessHeroGroup, int>(); map.Add(ChessHeroGroup.Myself, 1); map.Add(ChessHeroGroup.Enemy, 1); int baseId = 0; for (int i = 0; i < chessList.Count; i++) { ChessData chess = chessList[i]; Debugger.Warn(chess.Belong + ":" + chess.Point.X + "," + chess.Point.Y + "|" + chess.ChessType); ChessHeroData heroData = new ChessHeroData(); ChessHeroGroup group; baseId = GetBaseId(chess.Belong); group = (ChessHeroGroup)(baseId / 100); switch (group) { case ChessHeroGroup.Myself: heroData.point = new ChessPoint(chess.Point.X, chess.Point.Y); break; case ChessHeroGroup.Enemy: //敌人要翻转 heroData.point = new ChessPoint(4 - chess.Point.X, 11 - chess.Point.Y); break; } heroData.heroTypeId = chess.ChessType; heroData.realChessType = heroData.heroTypeId; heroData.id = map[group] + baseId; heroData.remoteId = chess.ChessRemoteId; heroData.state = ChessHeroState.Alive; heroData.belong = chess.Belong; heroData.group = group; AddChessToMap(heroData); map[group]++; } }
public void OnRoundSkill() { foreach (KeyValuePair <int, SkillLargeData> kv in playerRoundSkill) { mainOrgIdx = kv.Key; mainOrgData = fightController.GetChessData("P", mainOrgIdx); mainOrgRadio = fightController.GetRadio("P", mainOrgIdx); mainTarget = new string[2] { "P", "" }; OnSkillSelfRule(kv.Value); } foreach (KeyValuePair <int, SkillLargeData> kv in enemyRoundSkill) { mainOrgIdx = kv.Key; mainOrgData = fightController.GetChessData("E", mainOrgIdx); mainOrgRadio = fightController.GetRadio("E", mainOrgIdx); mainTarget = new string[2] { "E", "" }; OnSkillSelfRule(kv.Value); } }
/// <summary> /// 走子情况 /// </summary> void OnReceiveChessMove(object data) { ChessMovePush push = (ChessMovePush)data; ChessData source = push.Source; ChessData target = push.Target; ChessMoveResult result = (ChessMoveResult)push.ChessMoveResult; ChessHeroData sourceReal = App.Package.ChessGame.GetChessHeroDataByRemoteId(source.ChessRemoteId); //强制回合同步 App.Package.ChessGame.GameRoundCounter = push.Counter - 1; if (target != null) { ChessHeroData targetReal = App.Package.ChessGame.GetChessHeroDataByRemoteId(target.ChessRemoteId); if (sourceReal == null || (targetReal == null && result != ChessMoveResult.CAN_MOVE && result != ChessMoveResult.CANNOT_MOVE) || push.Counter != App.Package.ChessGame.GameRoundCounter + 1) { ChessDataHasProblem(); return; } ChessHeroData fake = ChessDataToChessHeroData(target, true); if (targetReal != null) { fake = targetReal; } ChessMoveData moveData = ChessAgainst.ChessHeroCanMoveTo(sourceReal, fake.point); switch (result) { case ChessMoveResult.LOSE: fake.heroTypeId = 12; StartCoroutine(TweenMoveChessAndBeat(sourceReal, fake, result, moveData)); break; case ChessMoveResult.WIN: fake.heroTypeId = -2; StartCoroutine(TweenMoveChessAndBeat(sourceReal, fake, result, moveData)); break; case ChessMoveResult.TIE: fake.heroTypeId = -3; StartCoroutine(TweenMoveChessAndBeat(sourceReal, fake, result, moveData)); break; case ChessMoveResult.CAN_MOVE: StartCoroutine(TweenMoveChess(sourceReal, fake.point, result, moveData)); break; case ChessMoveResult.CANNOT_MOVE: break; } } else { NextGameRound(); if (source.Belong == App.Package.Player.GetBelong()) { Common.UI.OpenTips("超时跳过"); } else { Common.UI.OpenTips("敌方超时跳过"); } Debugger.Error("skip"); } }