예제 #1
0
        /// <summary>
        ///     Starts the PaintMode. Call this method with the pattern.
        /// </summary>
        /// <param name="pattern">Pattern to edit.</param>
        /// <returns>Returns true for success, false otherwise</returns>
        public bool Open(Pattern.Pattern pattern)
        {
            if (gameObject.activeSelf)
            {
                return(false);
            }

            if (!(pattern is PaintPattern))
            {
                return(false);
            }
            var paintPattern = (PaintPattern)pattern;

            this.pattern = paintPattern;

            gameObject.SetActive(true);

            player.pattern   = pattern;
            player.evaluator = new ClosestEvaluator(GetComponentInChildren <VibratorMesh>(), paintPattern);

            defaultPaintingTool = new PaintingTool.DefaultPainting(player.evaluator as ClosestEvaluator);
            currentPaintingTool = defaultPaintingTool;
            hmdDisplay.SetPaintingToolName(currentPaintingTool.name);

            reflectionPaintingTool = new PaintingTool.ReflectionPainting(player.evaluator as ClosestEvaluator);

            eraserModeTool = new PaintingTool.EraserMode(player.evaluator as ClosestEvaluator);

            foreach (var stroke in paintPattern.strokes)
            {
                OnStrokeAdded(stroke);
            }

            player.SetTime(0);

            if (this.pattern.strokes.Count > 0)
            {
                selectStroke(this.pattern.strokes[0]);
            }

            if (!int.TryParse(Regex.Match(pattern.name, @"\d+").Value, out _))
            {
            }

            return(true);
        }
예제 #2
0
        /// <summary>
        ///     Will switch between painting modes.
        /// </summary>
        private void OnChangePaintingToolClicked(SteamVR_Action_In actionIn)
        {
            if (changePaintingToolAction.GetStateDown(SteamVR_Input_Sources.Any))
            {
                if (currentPaintingTool is PaintingTool.DefaultPainting)
                {
                    currentPaintingTool = reflectionPaintingTool;
                }
                else if (currentPaintingTool is PaintingTool.ReflectionPainting)
                {
                    currentPaintingTool = eraserModeTool;
                    erasing             = true;
                }
                else
                {
                    currentPaintingTool = defaultPaintingTool;
                    erasing             = false;
                }
            }

            hmdDisplay.SetPaintingToolName(currentPaintingTool.name);
        }