Example #1
0
        protected void OnMovementFinished(object data)
        {
            var toDo = data as ActionArea;

            if (toDo != null)
            {
                switch (toDo.action.getType())
                {
                case Action.USE:
                case Action.USE_WITH:
                case Action.GRAB:
                    representable.Orientation = (representable.getPosition() - toDo.area.ToRect().center).ToOrientation(true);
                    representable.Play("use", "stand");
                    break;

                case Action.CUSTOM:
                    representable.Orientation = (representable.getPosition() - toDo.area.ToRect().center).ToOrientation(true);
                    representable.Play("actionAnimation", "stand");
                    break;
                }

                Game.Instance.GameState.BeginChangeAmbit();
                if (onExecutionStarted != null)
                {
                    onExecutionStarted(toDo.action);
                }
                Game.Instance.Execute(new EffectHolder(toDo.action.Effects), FinishedCallbackFor(toDo, onExecutionFinished));
            }
        }
Example #2
0
        public bool Move(Vector2 point, object data, OnMovementFinished onMovementFinished, OnMovementCancelled onMovementCancelled)
        {
            AbortCurrentMovement();

            this.data = data;
            this.onMovementFinished  = onMovementFinished;
            this.onMovementCancelled = onMovementCancelled;

            var accesible = TrajectoryHandler.GetAccessibleTrajectory(representable.getPosition(), FindObjectOfType <SceneMB>().Trajectory);
            var route     = accesible.route(representable.getPosition(), point);

            if (route != null && route.Length > 0)
            {
                toArea = null;
                MoveRoute(route);
                return(true);
            }
            return(false);
        }