コード例 #1
0
    public void CreateByCell(MoveImpl move)
    {
        foreach (GameObject marker in route)
        {
            Destroy(marker);
        }
        route.Clear();

        CFG.Animation route_animation = MoveAnimator.CreateAnimation(move);

        if (route_animation == null)
        {
            return;
        }

        double  cur_length = 0;
        double  angle;
        Vector2 cur_pos = new Vector2();

        while (route_animation.GetPosition(cur_length, out cur_pos, out angle))
        {
            //ToDo change GetPosition to return Vector3 and rotate board to be xy instead of xz
            Vector3    offset            = new Vector3((float)cur_pos.x, 0.1f, (float)cur_pos.y);
            GameObject route_marker_inst = Instantiate(route_marker, offset, transform.rotation) as GameObject;
            route.Add(route_marker_inst);

            cur_length += 0.5;//ToDo this is not good
        }
    }
コード例 #2
0
ファイル: GameBoard.cs プロジェクト: DKirikov/Unity3D_CFG
    public List <OrientedCell> CalcRouteTo(MoveImpl move)
    {
        List <OrientedCell> to_list = new List <OrientedCell> (1);

        List <OrientedCell>[] routes = new List <OrientedCell> [1];

        to_list.Add(move.GetTargetCell(gameboard_impl));

        new Routing(gameboard_impl).CalcRouteToMulty(move.GetUnitPlace(gameboard_impl), to_list, routes);        //ToDo try to remove this

        return(routes[0] != null && routes[0].Count > 0 ? routes[0] : null);
    }
コード例 #3
0
ファイル: MoveCommandTest.cs プロジェクト: sg10000/sg
        public void East_ExpectMoveEastByOne()
        {
            IToy toy = new Robot()
            {
                X      = X_Position,
                Y      = Y_Position,
                Facing = Direction.EAST
            };
            ICommand  c   = new MoveImpl();
            IPosition pos = c.Execute(toy);

            Assert.AreEqual(X_Position + 1, pos.X);
            Assert.AreEqual(Y_Position, pos.Y);
            Assert.AreEqual(Direction.EAST, pos.Facing);
        }
コード例 #4
0
ファイル: MoveCommandTest.cs プロジェクト: sg10000/sg
        public void South_ExpectMoveSouthByOne()
        {
            IToy toy = new Robot()
            {
                X      = X_Position,
                Y      = Y_Position,
                Facing = Direction.SOUTH
            };
            ICommand  c   = new MoveImpl();
            IPosition pos = c.Execute(toy);

            Assert.AreEqual(X_Position, pos.X);
            Assert.AreEqual(Y_Position - 1, pos.Y);
            Assert.AreEqual(Direction.SOUTH, pos.Facing);
        }
コード例 #5
0
    public void PlayRunAnimation(MoveImpl move)
    {
        if (gameObject.tag != "Dude")
        {
            ResetAnimations(false, false);
        }

        if (unit.isTeleport)
        {
            //ToDo change GetPosition to return Vector3 and rotate board to be xy instead of xz
            Vector2 cur_pos = GameBoard.instance.FindTargetCellPlace(move);
            Vector3 offset  = new Vector3((float)cur_pos.x, 0.1f, (float)cur_pos.y);
            gameObject.transform.position = offset;
        }
        else
        {
            GetComponent <Animator> ().SetTrigger("walk");

            cur_animation = CFG.MoveAnimator.CreateAnimation(move);
        }
    }
コード例 #6
0
        static public Animation CreateAnimation(MoveImpl move)
        {
            Animation ret       = null;
            var       cur_route = GameBoard.instance.CalcRouteTo(move);

            if (cur_route != null)
            {
                List <Vector2> points = new List <Vector2> (cur_route.Count);
                points.Add(GameBoard.instance.FindCellPlace(cur_route [0]));
                for (int i = 1; i < cur_route.Count - 1; ++i)
                {
                    if (!AreCellsInRow(cur_route [i - 1], cur_route [i + 1]))
                    {
                        points.Add(GameBoard.instance.FindCellPlace(cur_route [i]));
                    }
                }
                points.Add(GameBoard.instance.FindCellPlace(cur_route [cur_route.Count - 1]));

                ret = new MoveAnimation(points.ToArray(), 1);
            }
            return(ret);
        }
コード例 #7
0
ファイル: GameBoard.cs プロジェクト: DKirikov/Unity3D_CFG
 public Vector2 FindTargetCellPlace(MoveImpl move)
 {
     return(FindCellPlace(move.GetTargetCell(gameboard_impl)));
 }