Exemplo n.º 1
0
    //--需要重构
    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);
        }
    }