public void Init() { SE = GetComponent <StateEdit>(); SF = GetComponent <StateFight>(); SER = GetComponent <StateEnterRoom>(); SA = GetComponent <StateAwait>(); _nowState = SER; }
public int OnFightClick(string pos = "") { StateFight se = StateManager.Instance.GetState() as StateFight; if (pos == "") { if (GetChessType() == ChessType.DiLei || transform.parent.GetComponent <ChessPosViewBehaviour>().PosLogic.CsType == ChessBoardPosType.BY) { if (se.PrevSeletedChess != null) { se.PrevSeletedChess.GetComponent <ChessViewBehaviour>().StopAllCoroutines(); se.PrevSeletedChess.GetComponent <SpriteRenderer>().enabled = true; } return(-1); } if (se.PrevSeletedChess != null) { se.PrevSeletedChess.GetComponent <ChessViewBehaviour>().StopAllCoroutines(); se.PrevSeletedChess.GetComponent <SpriteRenderer>().enabled = true; } StartCoroutine(Flash()); AudioManager.Instance.PlayEffect(Selected); return(0); } else //棋子移动 { ChessPosLogic mData = transform.parent.GetComponent <ChessPosViewBehaviour>().PosLogic; ChessPosLogic tarData = ChessBoardLogicData.Instance.FindPosWithPos(pos); List <ChessPosLogic> path = FindPath(mData, tarData); List <Path> pathString = new List <Path>(); foreach (var item in path) { Path pt = new Path(); pt.pt = item.LocalPos; pathString.Add(pt); } if (path.Count <= 0) { return(0); } if (path[path.Count - 1] != tarData) { path.RemoveAll(data => { return(true); }); return(0); } StopAllCoroutines(); GetComponent <SpriteRenderer>().enabled = true; //object[] obj = new object[1]; //AnimParameter am = new AnimParameter(); //am.Path = path; //am.Start = gameObject; //obj[0] = am; //ModuleManager.Instance.Invoke("PlayChessMove", obj); //tarData.IsOccupied = true; MovResReq req = new MovResReq(pathString); req.start = mData.LocalPos; req.targetpos = tarData.LocalPos; NetWorkManagement.Instance.SendProtobufCmd((int)Stype.game_server, (int)Cmd.eMovResReq, req); StateManager.Instance.ChangeState(StateManager.Instance.SA); return(1); } }