//--需要重构 public void ShootBall() { int randomIndex = Random.Range(0, _RandomPlayerCells.Count); SGridCoordinate coor = _RandomPlayerCells[randomIndex]; GridInfo theCell = BallGrid[coor.x, coor.z]; if (theCell.IsEmpty()) { _RandomPlayerCells.RemoveAt(randomIndex); Vector3 worldPosition = Definition.GridToWorld(coor.x, coor.z); sc.Show(coor); GameObject ball = GameObject.Instantiate(Ball, Boss.transform.position, Quaternion.identity) as GameObject; MotionParabolic motion = ball.AddMissingComponent <MotionParabolic>(); motion.Go(Boss.transform.position, worldPosition, 30, 10); motion.SetCallBack( delegate() { ToolAutoDestory boom = ball.AddMissingComponent <ToolAutoDestory>(); boom.SetCallBack(delegate { theCell.CleanOccupant(); _RandomPlayerCells.Add(coor); }); boom.Do(20); } ); //网格准备被占领. theCell.BeginOccupy(ball); ball.AddMissingComponent <BallMoveHelper>().SetAim(theCell); } }
/// <summary> /// 踢回球.需要重构. /// </summary> /// <param name="oriCoor">角色坐标.</param> /// <param name="coor">球所在坐标</param> public void KickBackBall(SGridCoordinate oriCoor, SGridCoordinate coor) { GridInfo theGrid = BallGrid[coor.x, coor.z]; if (theGrid.MCurState == GridInfo.EState.Occupation) { GameObject ball = theGrid.MOccupant; if (ball != null) { ToolAutoDestory boom = ball.AddMissingComponent <ToolAutoDestory>(); boom.Stop(); boom.Do(5); MotionParabolic motion = ball.AddMissingComponent <MotionParabolic>(); motion.Go(ball.transform.position, Boss.transform.position, 30, 10); motion.SetCallBack(null); } theGrid.CleanOccupant(); } }