Esempio n. 1
0
        public virtual bool ChangeViewpoint(Viewpoint newViewpoint, float speedFactor)
        {
            bool flag = FezMath.IsOrthographic(newViewpoint) != FezMath.IsOrthographic(this.viewpoint);

            if (flag && this.ProjectionTransition)
            {
                return(false);
            }
            this.ProjectionTransition   = flag && (double)speedFactor > 0.0;
            this.radiusBeforeTransition = FezMath.IsOrthographic(this.viewpoint) ? this.current.Radius : this.predefinedViews[this.lastViewpoint].Radius;
            if ((double)speedFactor > 0.0)
            {
                float num = (float)((double)(Math.Abs(FezMath.GetDistance(newViewpoint, this.Viewpoint)) - 1) / 2.0 + 1.0);
                if (newViewpoint == Viewpoint.Perspective || this.Viewpoint == Viewpoint.Perspective)
                {
                    num = 1f;
                }
                Vector3 from = this.current.Direction;
                Vector3 to   = this.predefinedViews[newViewpoint].Direction;
                this.directionTransition = new Vector3SplineInterpolation(TimeSpan.FromSeconds((double)DefaultCameraManager.TransitionSpeed * (double)num * (double)speedFactor), new Vector3[3]
                {
                    from,
                    DefaultCameraManager.GetIntemediateVector(from, to),
                    to
                });
                this.directionTransition.Start();
            }
            if (FezMath.IsOrthographic(this.viewpoint))
            {
                this.current.Direction = -FezMath.ForwardVector(this.viewpoint);
                this.current.Radius    = this.DefaultViewableWidth;
            }
            this.olderViewpoint = this.lastViewpoint;
            this.lastViewpoint  = this.viewpoint;
            this.viewpoint      = newViewpoint;
            Vector3 center = this.Center;

            this.current        = this.predefinedViews[newViewpoint];
            this.current.Center = center;
            if (this.lastViewpoint != Viewpoint.None)
            {
                this.PreViewpointChanged();
                if (!this.ViewTransitionCancelled)
                {
                    this.ViewpointChanged();
                }
            }
            if ((double)speedFactor == 0.0 && !this.ViewTransitionCancelled)
            {
                this.RebuildView();
            }
            bool transitionCancelled = this.ViewTransitionCancelled;

            this.ViewTransitionCancelled = false;
            return(!transitionCancelled);
        }
Esempio n. 2
0
 public virtual bool ChangeViewpoint(Viewpoint newViewpoint, float speedFactor)
 {
   bool flag = FezMath.IsOrthographic(newViewpoint) != FezMath.IsOrthographic(this.viewpoint);
   if (flag && this.ProjectionTransition)
     return false;
   this.ProjectionTransition = flag && (double) speedFactor > 0.0;
   this.radiusBeforeTransition = FezMath.IsOrthographic(this.viewpoint) ? this.current.Radius : this.predefinedViews[this.lastViewpoint].Radius;
   if ((double) speedFactor > 0.0)
   {
     float num = (float) ((double) (Math.Abs(FezMath.GetDistance(newViewpoint, this.Viewpoint)) - 1) / 2.0 + 1.0);
     if (newViewpoint == Viewpoint.Perspective || this.Viewpoint == Viewpoint.Perspective)
       num = 1f;
     Vector3 from = this.current.Direction;
     Vector3 to = this.predefinedViews[newViewpoint].Direction;
     this.directionTransition = new Vector3SplineInterpolation(TimeSpan.FromSeconds((double) DefaultCameraManager.TransitionSpeed * (double) num * (double) speedFactor), new Vector3[3]
     {
       from,
       DefaultCameraManager.GetIntemediateVector(from, to),
       to
     });
     this.directionTransition.Start();
   }
   if (FezMath.IsOrthographic(this.viewpoint))
   {
     this.current.Direction = -FezMath.ForwardVector(this.viewpoint);
     this.current.Radius = this.DefaultViewableWidth;
   }
   this.olderViewpoint = this.lastViewpoint;
   this.lastViewpoint = this.viewpoint;
   this.viewpoint = newViewpoint;
   Vector3 center = this.Center;
   this.current = this.predefinedViews[newViewpoint];
   this.current.Center = center;
   if (this.lastViewpoint != Viewpoint.None)
   {
     this.PreViewpointChanged();
     if (!this.ViewTransitionCancelled)
       this.ViewpointChanged();
   }
   if ((double) speedFactor == 0.0 && !this.ViewTransitionCancelled)
     this.RebuildView();
   bool transitionCancelled = this.ViewTransitionCancelled;
   this.ViewTransitionCancelled = false;
   return !transitionCancelled;
 }
Esempio n. 3
0
 public SwooshingCube(TrileInstance instance, Mesh destinationMesh, Vector3 Offset, Quaternion Rotation)
 {
   this.CameraManager = ServiceHelper.Get<IGameCameraManager>();
   this.LevelManager = ServiceHelper.Get<ILevelManager>();
   this.LevelMaterializer = ServiceHelper.Get<ILevelMaterializer>();
   this.rotation = Rotation;
   this.positionOffset = Offset;
   this.color = this.StandardTrail;
   switch (this.LevelManager.WaterType)
   {
     case LiquidType.Lava:
       this.color = this.RedTrail;
       break;
     case LiquidType.Sewer:
       this.color = this.SewerTrail;
       break;
   }
   if (this.LevelManager.BlinkingAlpha)
     this.color = this.CMYTrail;
   this.Trail = new Mesh()
   {
     Effect = (BaseEffect) new DefaultEffect.VertexColored(),
     Culling = CullMode.None,
     Blending = new BlendingMode?(BlendingMode.Additive),
     AlwaysOnTop = true
   };
   this.Cube = new Mesh()
   {
     Texture = this.LevelMaterializer.TrilesMesh.Texture
   };
   if (this.LevelManager.WaterType == LiquidType.Sewer || this.LevelManager.WaterType == LiquidType.Lava || this.LevelManager.BlinkingAlpha)
   {
     Mesh mesh = this.Cube;
     DefaultEffect.Textured textured1 = new DefaultEffect.Textured();
     textured1.AlphaIsEmissive = true;
     DefaultEffect.Textured textured2 = textured1;
     mesh.Effect = (BaseEffect) textured2;
   }
   else
   {
     Mesh mesh = this.Cube;
     DefaultEffect.LitTextured litTextured1 = new DefaultEffect.LitTextured();
     litTextured1.Specular = true;
     litTextured1.Emissive = 0.5f;
     litTextured1.AlphaIsEmissive = true;
     DefaultEffect.LitTextured litTextured2 = litTextured1;
     mesh.Effect = (BaseEffect) litTextured2;
   }
   ShaderInstancedIndexedPrimitives<VertexPositionNormalTextureInstance, Vector4> geometry = instance.Trile.Geometry;
   this.Cube.AddGroup().Geometry = (IIndexedPrimitiveCollection) new IndexedUserPrimitives<VertexPositionNormalTextureInstance>(geometry.Vertices, geometry.Indices, geometry.PrimitiveType);
   this.Trail.AddGroup().Geometry = (IIndexedPrimitiveCollection) (this.TrailGeometry = new IndexedUserPrimitives<FezVertexPositionColor>(this.TrailVertices = new FezVertexPositionColor[0], this.TrailIndices = new int[0], PrimitiveType.TriangleList));
   this.Instance = instance;
   this.lastPoint = instance.Center;
   this.DestinationMesh = destinationMesh;
   this.sideDirection = (RandomHelper.Probability(0.5) ? -1f : 1f) * FezMath.RightVector(this.CameraManager.Viewpoint);
   this.Spline = new Vector3SplineInterpolation(TimeSpan.FromSeconds(3.0), new Vector3[10]);
   this.Spline.Start();
   this.AddSegment();
 }
Esempio n. 4
0
            public SwooshingCube(TrileInstance instance, Mesh destinationMesh, Vector3 Offset, Quaternion Rotation)
            {
                this.CameraManager     = ServiceHelper.Get <IGameCameraManager>();
                this.LevelManager      = ServiceHelper.Get <ILevelManager>();
                this.LevelMaterializer = ServiceHelper.Get <ILevelMaterializer>();
                this.rotation          = Rotation;
                this.positionOffset    = Offset;
                this.color             = this.StandardTrail;
                switch (this.LevelManager.WaterType)
                {
                case LiquidType.Lava:
                    this.color = this.RedTrail;
                    break;

                case LiquidType.Sewer:
                    this.color = this.SewerTrail;
                    break;
                }
                if (this.LevelManager.BlinkingAlpha)
                {
                    this.color = this.CMYTrail;
                }
                this.Trail = new Mesh()
                {
                    Effect      = (BaseEffect) new DefaultEffect.VertexColored(),
                    Culling     = CullMode.None,
                    Blending    = new BlendingMode?(BlendingMode.Additive),
                    AlwaysOnTop = true
                };
                this.Cube = new Mesh()
                {
                    Texture = this.LevelMaterializer.TrilesMesh.Texture
                };
                if (this.LevelManager.WaterType == LiquidType.Sewer || this.LevelManager.WaterType == LiquidType.Lava || this.LevelManager.BlinkingAlpha)
                {
                    Mesh mesh = this.Cube;
                    DefaultEffect.Textured textured1 = new DefaultEffect.Textured();
                    textured1.AlphaIsEmissive = true;
                    DefaultEffect.Textured textured2 = textured1;
                    mesh.Effect = (BaseEffect)textured2;
                }
                else
                {
                    Mesh mesh = this.Cube;
                    DefaultEffect.LitTextured litTextured1 = new DefaultEffect.LitTextured();
                    litTextured1.Specular        = true;
                    litTextured1.Emissive        = 0.5f;
                    litTextured1.AlphaIsEmissive = true;
                    DefaultEffect.LitTextured litTextured2 = litTextured1;
                    mesh.Effect = (BaseEffect)litTextured2;
                }
                ShaderInstancedIndexedPrimitives <VertexPositionNormalTextureInstance, Vector4> geometry = instance.Trile.Geometry;

                this.Cube.AddGroup().Geometry  = (IIndexedPrimitiveCollection) new IndexedUserPrimitives <VertexPositionNormalTextureInstance>(geometry.Vertices, geometry.Indices, geometry.PrimitiveType);
                this.Trail.AddGroup().Geometry = (IIndexedPrimitiveCollection)(this.TrailGeometry = new IndexedUserPrimitives <FezVertexPositionColor>(this.TrailVertices = new FezVertexPositionColor[0], this.TrailIndices = new int[0], PrimitiveType.TriangleList));
                this.Instance        = instance;
                this.lastPoint       = instance.Center;
                this.DestinationMesh = destinationMesh;
                this.sideDirection   = (RandomHelper.Probability(0.5) ? -1f : 1f) * FezMath.RightVector(this.CameraManager.Viewpoint);
                this.Spline          = new Vector3SplineInterpolation(TimeSpan.FromSeconds(3.0), new Vector3[10]);
                this.Spline.Start();
                this.AddSegment();
            }