예제 #1
0
 public void Show()
 {
     if (Opacity == 0)
     {
         RunAction(SCNAction.FadeIn(0.5f));
     }
 }
예제 #2
0
        private void ShowPatientDetails(ARReferenceImage detectedImage, SCNNode node)
        {
            // Highlight the QR Code?
            var width     = detectedImage.PhysicalSize.Width;
            var length    = detectedImage.PhysicalSize.Height;
            var planeNode = new PlaneNode(0, width, length, new SCNVector3(0, 0, 0), "");

            planeNode.Opacity = 1f;
            float angle = (float)(-Math.PI / 2);

            planeNode.EulerAngles = new SCNVector3(angle, 0, 0);
            //node.AddChildNode(planeNode);

            // Get and Show information panels
            foreach (var informationPanelNode in GetPatientInformationPanels())
            {
                var waitAction     = SCNAction.Wait(0.1 * informationPanelNode.Number);
                var fadeInAction   = SCNAction.FadeIn(1);
                var actionSequence = SCNAction.Sequence(new[] { waitAction, fadeInAction });

                // Not sure I can run actions before adding. May have to add, then run.
                informationPanelNode.RunAction(actionSequence);

                informationPanelNode.EulerAngles = new SCNVector3(angle, 0, 0);

                node.AddChildNode(informationPanelNode);
            }
        }
예제 #3
0
        public void CollideWithLava()
        {
            if (HitByLavaReset == true)
            {
                return;
            }

            PlayerCharacter.InRunAnimation = false;

            GameSimulation.Sim.PlaySound("ack.caf");

            // Blink for a second
            SCNAction blinkOffAction = SCNAction.FadeOut(0.15f);
            SCNAction blinkOnAction  = SCNAction.FadeIn(0.15f);
            SCNAction cycle          = SCNAction.Sequence(new SCNAction[] { blinkOffAction, blinkOnAction });
            SCNAction repeatCycle    = SCNAction.RepeatAction(cycle, 17);

            HitByLavaReset = true;

            PlayerCharacter.RunAction(repeatCycle, () => {
                TimeAlongPath            = 0;
                PlayerCharacter.Position = LocationAlongPath(TimeAlongPath);
                PlayerCharacter.Rotation = GetPlayerDirectionFromCurrentPosition();
                HitByLavaReset           = false;
            });
        }
예제 #4
0
 /// <summary>
 /// Unhides the border.
 /// </summary>
 public void UnhideBorder()
 {
     if (this.borderNode.GetAction("unhide") == null)
     {
         this.borderNode.RemoveAction("hide");
         this.borderNode.RunAction(SCNAction.FadeIn(0.5), "unhide");
         this.borderNode.Hidden = false;
     }
 }
예제 #5
0
        public SCNNode Create3DNode()
        {
            SCNScene jellyfishScn  = SCNScene.FromFile("art.scnassets/Jellyfish");
            SCNNode  jellyfishNode = jellyfishScn.RootNode.FindChildNode("Jellyfish", false);

            jellyfishNode.Scale    = new SCNVector3(0.019f, 0.019f, 0.019f);
            jellyfishNode.Position = new SCNVector3(0, 0, 0);

            // Animate the opacity to 100% over 0.75 seconds
            jellyfishNode.Opacity = 0;
            jellyfishNode.RunAction(SCNAction.FadeIn(0.75));

            return(jellyfishNode);
        }
예제 #6
0
        void StartGame()
        {
            if (!gameNodes.HasValue)
            {
                throw new InvalidProgramException("Nodes not set");
            }

            var startSequence = SCNAction.Sequence(new SCNAction [] {
                // Wait for 1 second.
                SCNAction.Wait(1),
                SCNAction.Group(new SCNAction[] {
                    SCNAction.FadeIn(0.3),

                    // Start the game.
                    SCNAction.Run(node => {
                        if (!gameNodes.HasValue)
                        {
                            return;
                        }
                        var gNodes = gameNodes.Value;

                        var rnd = new Random();

                        // Compute a random orientation for the object3D.
                        var theta = (float)(Math.PI * rnd.NextDouble());
                        var phi   = (float)(Math.Acos(2 * rnd.NextDouble() - 1) / NMath.PI);

                        var axis = new Vector3 {
                            X = (float)(Math.Cos(theta) * Math.Sin(phi)),
                            Y = (float)(Math.Sin(theta) * Math.Sin(phi)),
                            Z = (float)Math.Cos(theta)
                        };
                        var angle = (float)(2 * Math.PI * rnd.NextDouble());

                        SCNTransaction.Begin();
                        SCNTransaction.AnimationDuration = 0.3;
                        SCNTransaction.SetCompletionBlock(() => gameStarted = true);

                        gNodes.ObjectMaterial.Transparency = 1;
                        gNodes.Object.Transform            = SCNMatrix4.CreateFromAxisAngle(axis, angle);

                        SCNTransaction.Commit();
                    })
                })
            });

            gameNodes.Value.Object.RunAction(startSequence);

            // Load and set the background image.
            var backgroundImage = UIImage.FromBundle("art.scnassets/background.png");

            sceneInterface.Scene.Background.Contents = backgroundImage;

            // Hide particles, set camera projection to orthographic.
            particleRemovalTimer?.Invalidate();
            gameNodes.Value.CongratulationsLabel.RemoveFromParent();
            gameNodes.Value.Confetti.Hidden = true;
            gameNodes.Value.Camera.UsesOrthographicProjection = true;

            // Reset the countdown.
            countdown = 30;
            gameNodes.Value.CountdownLabel.Text      = countdown.ToString();
            gameNodes.Value.CountdownLabel.FontColor = GameColors.DefaultFont;
            gameNodes.Value.CountdownLabel.Position  = new CGPoint(ContentFrame.Width / 2, ContentFrame.Height - 30);

            textUpdateTimer?.Invalidate();
            textUpdateTimer = NSTimer.CreateRepeatingScheduledTimer(1, UpdateText);
        }