コード例 #1
0
    TextAsset[] prefabText;   //現在のモードの出現マップ

    // Start is called before the first frame update
    void Start()
    {
        mapTask    = GetComponent <MapTask>();
        cameraTask = GetComponent <CameraTask>();
        prefabText = Resources.LoadAll <TextAsset>(GetPath.MainStage);

        CreatePrefab(Vector2Int.zero, StartMapData());
        CreateMap(RandomMapData());
    }
コード例 #2
0
 // Start is called before the first frame update
 private void Start()
 {
     skyJumpNum  = 0;
     rBody       = GetComponent <Rigidbody2D>();
     boxCol      = GetComponent <BoxCollider2D>();
     buttonTask  = Utility.GetButton();
     cameraTask  = Utility.GetCamera();
     swordPrefab = Resources.Load <GameObject>(GetPath.GamePrefab + "/Sword");
     jumpEffect  = Resources.Load <GameObject>(GetPath.GamePrefab + "/JumpEffect");
 }
コード例 #3
0
 public virtual void Awake()
 {
     cameraTask = Camera.main.GetComponent <CameraTask>();
 }
コード例 #4
0
ファイル: Program.cs プロジェクト: yappy/DollsKit
        static TaskParameter[] SetupTasks(string bootMsg)
        {
            Func<int, int> toMin = (sec) => sec * 60;
            Func<int, int> toHour = (sec) => sec * 60 * 60;
            var healthCheck = new HealthCheck();
            var twitterCheck = new TwitterCheck();
            var ddnsTask = new DdnsTask();
            var cameraTask = new CameraTask();

            var bootMsgTask = TaskParameter.OneShot("boot", 0, (taskServer, taskName) =>
            {
                TwitterManager.Update(string.Format("[{0}] {1}", DateTime.Now, bootMsg));
            });
            var healthCheckTask = TaskParameter.Periodic("health", 5, toHour(6),
                healthCheck.Check);

            var twitterCheckTask = TaskParameter.Periodic("twitter", 10, toMin(10),
                twitterCheck.CheckTwitter);

            var updateDdnsTask = TaskParameter.Periodic("ddns", 20, toHour(1),
                ddnsTask.UpdateTask);

            var cameraShotTask = TaskParameter.Periodic("camera", /*30*/0, toHour(1),
                cameraTask.TakePictureTask);
            var uploadPictureTask = TaskParameter.Periodic("uploadpic", /*40*/0, toMin(10),
                cameraTask.UploadPictureTask);

            return new TaskParameter[] {
                bootMsgTask, healthCheckTask,
                twitterCheckTask, updateDdnsTask, cameraShotTask, uploadPictureTask,
            };
        }
コード例 #5
0
        // Event handler called when the camera capture task is completed
        private void OnCameraTaskCompleted(object sender, PhotoResult e)
        {
            Dictionary <string, string> result = new Dictionary <string, string>();
            bool       status     = false;
            string     error      = String.Empty;
            CameraTask cameraTask = sender as CameraTask;
            string     callbackId = cameraTask.CallbackId;

            if (e.TaskResult == TaskResult.OK)
            {
                if (e.Error == null)
                {
                    CameraOptions options  = cameraTask.Options;
                    string        filePath = (options.FilePath != null) ?
                                             FileManager.GetAbsolutePath(options.FilePath) :
                                             FileManager.GetAbsolutePath(new FilePath
                    {
                        Path        = Path.GetFileName(e.OriginalFileName),
                        Level       = FileLevel.App,
                        StorageType = StorageType.Cache
                    });
                    result.Add(KEY_PATH, filePath);


                    if (cameraTask.Type == CameraTaskType.PhotoChooser || options.ReadData)
                    {
                        // Load the image as bitmap to know dimensions
                        BitmapImage bi = new BitmapImage();
                        bi.SetSource(e.ChosenPhoto);
                        int imgWidth  = bi.PixelWidth;
                        int imgHeight = bi.PixelHeight;

                        // Get the target dimensions with user requested width/height
                        int width, height;
                        if (options.Width == -1)
                        {
                            if (options.Height == -1)
                            {
                                // Auto width and height. Do nothing.
                                height = imgHeight;
                                width  = imgWidth;
                            }
                            else
                            {
                                // Auto width, scale by height
                                float scale = imgHeight / options.Height;
                                width  = (int)(imgWidth * scale);
                                height = options.Height;
                            }
                        }
                        else
                        {
                            if (options.Height == -1)
                            {
                                // Auto height, scale by width
                                float scale = imgWidth / options.Width;
                                height = (int)(imgHeight * scale);
                                width  = options.Width;
                            }
                            else
                            {
                                // User provided required dimensions. Scale to them.
                                height = options.Height;
                                width  = options.Width;
                            }
                        }

                        // Format the image as specified in options
                        // Though width and height can be same as the captured image,
                        // formatting is required as quality might be different
                        try
                        {
                            e.ChosenPhoto.Seek(0, SeekOrigin.Begin);
                            byte[] data = FormatImage(e.ChosenPhoto, width, height, options.Quality);
                            if (data != null)
                            {
                                try
                                {
                                    // Write to File
                                    FileManager.WriteDataToFile(filePath, data, false);

                                    // Set data in result
                                    if (options.ReadData)
                                    {
                                        result.Add(KEY_DATA, Convert.ToBase64String(data));
                                    }
                                    status = true;
                                }
                                catch (Exception ex)
                                {
                                    // Error writing picture
                                    error = String.Concat(Mowbly.GetString(Constants.STRING_CAMERA_WRITE_PICTURE_ERROR), ex.Message);
                                }
                            }
                            {
                                // Error in formatting picture
                                error = Mowbly.GetString(Constants.STRING_CAMERA_FORMAT_ERROR);
                            }
                        }
                        catch (Exception ex)
                        {
                            // Error formatting picture
                            error = String.Concat(Mowbly.GetString(Constants.STRING_CAMERA_PROCESS_PICTURE_ERROR), ex.Message);
                        }
                    }
                    else
                    {
                        try
                        {
                            // Choose pic with no read
                            FileManager.WriteDataToFile(filePath, e.ChosenPhoto, false);

                            status = true;
                        }
                        catch (Exception ex)
                        {
                            // Error writing picture
                            error = String.Concat(Mowbly.GetString(Constants.STRING_CAMERA_WRITE_PICTURE_ERROR), ex.Message);
                        }
                    }
                }
                else
                {
                    // Error in capturing picture
                    error = String.Concat(Mowbly.GetString(Constants.STRING_CAMERA_CAPTURE_ERROR), e.Error.Message);
                }
            }
            else
            {
                // User cancelled the task
                error = Mowbly.GetString(Constants.STRING_ACTIVITY_CANCELLED);
            }

            if (status)
            {
                InvokeCallbackJavascript(callbackId, new MethodResult
                {
                    Result = result
                });
            }
            else
            {
                Logger.Error(error);
                InvokeCallbackJavascript(callbackId, new MethodResult
                {
                    Code  = MethodResult.FAILURE_CODE,
                    Error = new MethodError
                    {
                        Message = error
                    }
                });
            }
            Logger.Debug(cameraTask.Name + " completed");
        }