예제 #1
0
        public async Task <IEnumerable <Algorithms.Algorithm> > GetAlgorithmsAsync()
        {
            var algorithms = new List <Algorithms.Algorithm>();

            var remoteAlgorithmResponse = await _apiService.Api.GetLiveAlgorithmListAsync(AlgorithmStatus.Running);

            var remoteProjectResponse = await _apiService.Api.GetProjectsAsync();

            remoteAlgorithmResponse.EnsureSuccess();
            remoteProjectResponse.EnsureSuccess();

            foreach (var remoteAlgorithm in remoteAlgorithmResponse.Algorithms)
            {
                var project = remoteProjectResponse.Projects.Find(p => p.ProjectId == remoteAlgorithm.ProjectId);

                var algorithm = new Algorithms.Algorithm
                {
                    Id = new AlgorithmId
                    {
                        DeployId  = remoteAlgorithm.DeployId,
                        ProjectId = remoteAlgorithm.ProjectId
                    },
                    LaunchedDateTime = remoteAlgorithm.Launched,
                    Name             = project.Name
                };

                switch (remoteAlgorithm.Status)
                {
                case AlgorithmStatus.Completed:
                    algorithm.Status = Algorithms.AlgorithmStatus.Completed;
                    break;

                case AlgorithmStatus.Running:
                    algorithm.Status = Algorithms.AlgorithmStatus.Running;
                    break;

                case AlgorithmStatus.Liquidated:
                    algorithm.Status = Algorithms.AlgorithmStatus.Liquidated;
                    break;

                case AlgorithmStatus.Stopped:
                    algorithm.Status = Algorithms.AlgorithmStatus.Stopped;
                    break;

                default:
                    throw new Exception("Unexpected algorithm status");
                }

                algorithms.Add(algorithm);
            }

            return(algorithms);
        }
 public void OnAlgorithmValueChanged(Algorithms.Algorithm algorithm)
 {
     if (Promoscience.Utils.CurrentDeviceType == DeviceType.Tablet)
     {
         text.text            = Client.Instance.Algorithm.Value.Name + " (?)";
         descriptionText.text = Client.Instance.Algorithm.Value.Description;
         descriptionName.text = Client.Instance.Algorithm.Value.Name;
     }
     else
     {
         text.text = Client.Instance.Algorithm.Value.Name;
     }
 }
예제 #3
0
        public void OnAlgorithm(Algorithms.Algorithm algorithm)
        {
            switch (algorithm.Id)
            {
            case Algorithms.Id.ShortestFlightDistance:
                ids = new ToolId[] {
                    ToolId.None,
                    ToolId.PaintBucket,
                    // TODO remove algorithm clipboard tool
                    //ToolId.AlgorithmClipboard,
                    ToolId.Compass,
                    ToolId.FlightDistanceScanner
                };
                break;

            case Algorithms.Id.LongestStraight:
                ids = new ToolId[] {
                    ToolId.None,
                    ToolId.PaintBucket,
                    //ToolId.AlgorithmClipboard,
                    ToolId.Compass,
                    ToolId.WallDistanceScanner
                };
                break;

            case Algorithms.Id.Standard:
                ids = new ToolId[] {
                    ToolId.None,
                    ToolId.PaintBucket,
                    //ToolId.AlgorithmClipboard,
                    ToolId.Compass
                };
                break;

            case Algorithms.Id.RightHand:
                ids = new ToolId[] {
                    ToolId.None,
                    ToolId.PaintBucket,
                    //ToolId.AlgorithmClipboard
                };
                break;
            }

            // Put last tool in hand
            currentToolIndex        = ids.Length - 1;
            asset.CurrentTool.Value = ids[currentToolIndex];
        }
예제 #4
0
        public AlgorithmReplay Create(
            BaseReplay parent,
            Labyrinths.LabyrinthObject labyrinth,
            Algorithms.Algorithm algorithm,
            Vector2Int startPosition)
        {
            var replay = this.Create(
                labyrinth.GetLabyrinthPositionInWorldPosition(startPosition));

            replay.parent         = parent;
            replay.labyrinth      = labyrinth;
            replay.lposition      = startPosition;
            replay.startlposition = startPosition;
            replay.execution      = new Algorithms.AlgorithmExecution(algorithm, labyrinth);

            parent.OnResumeHandler           += replay.OnResume;
            parent.OnStopHandler             += replay.OnStop;
            parent.OnMoveIndexChangedHandler += replay.OnMoveIndexChanged;

            return(replay);
        }
 public void OnAlgorithmChanged(Algorithms.Algorithm algorithm)
 {
     algorithmName.text = algorithm.Name;
 }