Ejemplo n.º 1
0
        private void TryAddRay(bool wide, bool midLife)
        {
            Mesh mesh = this.Meshes[FezMath.AsViewpoint(FezMath.OrientationFromPhi((float)RandomHelper.Random.Next(0, 4) * 1.570796f))];

            if (mesh.Groups.Count >= 15)
            {
                return;
            }
            float   num1    = wide ? this.CameraManager.Radius * 2f : this.CameraManager.Radius;
            Vector3 vector3 = RandomHelper.Between(-(double)num1 / 2.0, (double)(num1 / 2f)) * Vector3.UnitX;
            float   num2    = RandomHelper.Between(0.75, 4.0);
            float   num3    = 8f + RandomHelper.Centered(4.0);

            lock (mesh)
            {
                Group local_9 = mesh.AddColoredQuad(new Vector3(0.0f, 0.0f, 0.0f), new Vector3(-num3 - num2, -num3, 0.0f), new Vector3(-num3, -num3, 0.0f), new Vector3(-num2, 0.0f, 0.0f), new Color((int)byte.MaxValue, (int)byte.MaxValue, (int)byte.MaxValue), Color.Black, Color.Black, new Color((int)byte.MaxValue, (int)byte.MaxValue, (int)byte.MaxValue));
                local_9.CustomData = (object)new GodRays.RayCustomData()
                {
                    RandomOpacity   = RandomHelper.Between(0.125, 0.5),
                    Layer           = RandomHelper.Random.Next(0, 4),
                    RandomSpeed     = RandomHelper.Between(0.25, 2.0),
                    AccumulatedTime = (midLife ? TimeSpan.FromSeconds((double)RandomHelper.Between(0.0, 8.0)) : TimeSpan.Zero)
                };
                local_9.Material = new Material()
                {
                    Diffuse = Vector3.Zero
                };
                local_9.Position = vector3;
            }
        }
Ejemplo n.º 2
0
        private TrileInstance IsOnLadder(out ClimbingApproach approach)
        {
            Vector3       b              = FezMath.ForwardVector(this.CameraManager.Viewpoint);
            Vector3       vector3        = FezMath.RightVector(this.CameraManager.Viewpoint);
            float         num1           = float.MaxValue;
            bool          flag1          = false;
            TrileInstance trileInstance1 = (TrileInstance)null;
            bool          flag2          = true;

            if (this.currentApproach == ClimbingApproach.None)
            {
                NearestTriles nearestTriles = this.LevelManager.NearestTrile(this.PlayerManager.Center, this.PlayerManager.Background ? QueryOptions.Background : QueryOptions.None);
                flag2 = nearestTriles.Surface != null && nearestTriles.Surface.Trile.ActorSettings.Type == ActorType.Ladder;
            }
            foreach (NearestTriles nearestTriles in this.PlayerManager.AxisCollision.Values)
            {
                if (nearestTriles.Surface != null && this.TestLadderCollision(nearestTriles.Surface, true))
                {
                    TrileInstance trileInstance2 = nearestTriles.Surface;
                    float         num2           = FezMath.Dot(trileInstance2.Position, b);
                    if (flag2 && (double)num2 < (double)num1)
                    {
                        num1           = num2;
                        trileInstance1 = trileInstance2;
                    }
                }
            }
            if (trileInstance1 == null)
            {
                foreach (NearestTriles nearestTriles in this.PlayerManager.AxisCollision.Values)
                {
                    if (nearestTriles.Surface != null && this.TestLadderCollision(nearestTriles.Surface, false))
                    {
                        TrileInstance trileInstance2 = nearestTriles.Surface;
                        float         num2           = FezMath.Dot(trileInstance2.Position, b);
                        if (flag2 && (double)num2 < (double)num1)
                        {
                            flag1          = true;
                            num1           = num2;
                            trileInstance1 = trileInstance2;
                        }
                    }
                }
            }
            if (trileInstance1 != null)
            {
                float num2 = FezMath.Dot(FezMath.AsVector(FezMath.OrientationFromPhi(FezMath.WrapAngle(FezMath.ToPhi(trileInstance1.Trile.ActorSettings.Face) + trileInstance1.Phi))), flag1 ? vector3 : b);
                approach = !flag1 ? ((double)num2 > 0.0 ? ClimbingApproach.Front : ClimbingApproach.Back) : ((double)num2 > 0.0 ? ClimbingApproach.Left : ClimbingApproach.Right);
            }
            else
            {
                approach = ClimbingApproach.None;
            }
            return(trileInstance1);
        }
Ejemplo n.º 3
0
        private bool TestSignCollision(VerticalDirection direction)
        {
            TrileInstance trileInstance = this.PlayerManager.AxisCollision[direction].Surface;

            if (trileInstance == null)
            {
                return(false);
            }
            Trile           trile           = trileInstance.Trile;
            FaceOrientation faceOrientation = FezMath.OrientationFromPhi(FezMath.ToPhi(trile.ActorSettings.Face) + trileInstance.Phi);
            bool            flag            = trile.ActorSettings.Type == ActorType.Sign && faceOrientation == this.CameraManager.VisibleOrientation && trileInstance.ActorSettings != (InstanceActorSettings)null && !string.IsNullOrEmpty(trileInstance.ActorSettings.SignText);

            if (flag)
            {
                this.signText = trileInstance.ActorSettings.SignText;
            }
            return(flag);
        }
Ejemplo n.º 4
0
        public CollisionType GetRotatedFace(FaceOrientation face)
        {
            FaceOrientation index         = FezMath.OrientationFromPhi(FezMath.ToPhi(face) - this.Phi);
            CollisionType   collisionType = this.Trile.Faces[index];

            if (collisionType == CollisionType.TopOnly)
            {
                TrileEmplacement emplacement = this.Emplacement;
                ++emplacement.Y;
                Vector3       mask = FezMath.GetMask(FezMath.AsAxis(face));
                TrileInstance trileInstance;
                if (TrileInstance.LevelManager.Triles.TryGetValue(emplacement, out trileInstance) && trileInstance.Enabled && !trileInstance.IsMovingGroup && (trileInstance.Trile.Geometry == null || !trileInstance.Trile.Geometry.Empty || trileInstance.Trile.Faces[index] != CollisionType.None) && (!trileInstance.Trile.Immaterial && trileInstance.Trile.Faces[index] != CollisionType.Immaterial && (!trileInstance.Trile.Thin && !ActorTypeExtensions.IsPickable(trileInstance.Trile.ActorSettings.Type)) && (((double)trileInstance.Trile.Size.Y == 1.0 || trileInstance.ForceTopMaybe) && FezMath.AlmostEqual(FezMath.Dot(trileInstance.Center, mask), FezMath.Dot(this.Center, mask)))))
                {
                    collisionType = CollisionType.None;
                }
            }
            return(collisionType);
        }
Ejemplo n.º 5
0
 protected override void TestConditions()
 {
     if (!this.PlayerManager.Grounded)
     {
         this.UnDotize();
     }
     else if (this.PlayerManager.CarriedInstance != null)
     {
         this.UnDotize();
     }
     else
     {
         bool flag = false;
         foreach (NearestTriles nearestTriles in this.PlayerManager.AxisCollision.Values)
         {
             TrileInstance trileInstance = nearestTriles.Surface;
             if (trileInstance != null)
             {
                 Trile           trile           = trileInstance.Trile;
                 FaceOrientation faceOrientation = FezMath.OrientationFromPhi(FezMath.ToPhi(trile.ActorSettings.Face) + trileInstance.Phi);
                 if (ActorTypeExtensions.IsDoor(trile.ActorSettings.Type) && faceOrientation == FezMath.VisibleOrientation(this.CameraManager.Viewpoint))
                 {
                     flag            = this.GameState.SaveData.Keys > 0 && this.LevelManager.Name != "VILLAGEVILLE_2D" || trile.ActorSettings.Type == ActorType.UnlockedDoor;
                     this.isUnlocked = trile.ActorSettings.Type == ActorType.UnlockedDoor;
                     this.doorBottom = trileInstance;
                     break;
                 }
             }
         }
         if (!flag)
         {
             this.UnDotize();
         }
         else if (this.doorBottom.ActorSettings.Inactive)
         {
             this.UnDotize();
         }
         else
         {
             if (!this.PlayerManager.HideFez && this.PlayerManager.CanControl && (!this.DotManager.PreventPoI && this.doorBottom.Trile.ActorSettings.Type == ActorType.Door))
             {
                 this.DotManager.Behaviour  = DotHost.BehaviourType.ThoughtBubble;
                 this.DotManager.FaceButton = DotFaceButton.Up;
                 this.DotManager.ComeOut();
                 if (this.DotManager.Owner != this)
                 {
                     this.DotManager.Hey();
                 }
                 this.DotManager.Owner = (object)this;
             }
             if (this.GameState.IsTrialMode && this.LevelManager.Name == "trial/VILLAGEVILLE_2D" || this.InputManager.ExactUp != FezButtonState.Pressed)
             {
                 return;
             }
             TrileGroup trileGroup1 = (TrileGroup)null;
             this.aoInstance = (ArtObjectInstance)null;
             foreach (TrileGroup trileGroup2 in (IEnumerable <TrileGroup>) this.LevelManager.Groups.Values)
             {
                 if (trileGroup2.Triles.Contains(this.doorBottom))
                 {
                     trileGroup1 = trileGroup2;
                     break;
                 }
             }
             if (trileGroup1 != null)
             {
                 foreach (ArtObjectInstance artObjectInstance in (IEnumerable <ArtObjectInstance>) this.LevelManager.ArtObjects.Values)
                 {
                     int?attachedGroup = artObjectInstance.ActorSettings.AttachedGroup;
                     int id            = trileGroup1.Id;
                     if ((attachedGroup.GetValueOrDefault() != id ? 0 : (attachedGroup.HasValue ? 1 : 0)) != 0)
                     {
                         this.aoInstance = artObjectInstance;
                         break;
                     }
                 }
                 if (this.aoInstance != null)
                 {
                     this.aoInitialRotation = this.aoInstance.Rotation;
                     this.initialAoPosition = this.aoInstance.Position;
                 }
             }
             this.WalkTo.Destination   = new Func <Vector3>(this.GetDestination);
             this.PlayerManager.Action = ActionType.WalkingTo;
             this.WalkTo.NextAction    = ActionType.OpeningDoor;
         }
     }
 }
Ejemplo n.º 6
0
        private void DoLoad(bool dummy)
        {
            this.LevelManager.ChangeLevel(this.NextLevel);
            this.PlayerManager.ForceOverlapsDetermination();
            TrileInstance instance1 = this.PlayerManager.AxisCollision[VerticalDirection.Up].Surface;

            if (instance1 != null && instance1.Trile.ActorSettings.Type == ActorType.UnlockedDoor && FezMath.OrientationFromPhi(FezMath.ToPhi(instance1.Trile.ActorSettings.Face) + instance1.Phi) == FezMath.VisibleOrientation(this.CameraManager.Viewpoint))
            {
                ++this.GameState.SaveData.ThisLevel.FilledConditions.UnlockedDoorCount;
                TrileEmplacement id        = instance1.Emplacement + Vector3.UnitY;
                TrileInstance    instance2 = this.LevelManager.TrileInstanceAt(ref id);
                if (instance2.Trile.ActorSettings.Type == ActorType.UnlockedDoor)
                {
                    ++this.GameState.SaveData.ThisLevel.FilledConditions.UnlockedDoorCount;
                }
                this.LevelManager.ClearTrile(instance1);
                this.LevelManager.ClearTrile(instance2);
                this.GameState.SaveData.ThisLevel.InactiveTriles.Add(instance1.Emplacement);
                instance1.ActorSettings.Inactive = true;
            }
            this.PlayerManager.Hidden      = false;
            this.CameraManager.Constrained = false;
            this.GameState.ScheduleLoadEnd = true;
        }
Ejemplo n.º 7
0
        private void DoLoad(bool dummy)
        {
            this.LevelManager.ChangeLevel(this.newLevel);
            this.PlayerManager.ForceOverlapsDetermination();
            TrileInstance instance1 = this.PlayerManager.AxisCollision[VerticalDirection.Up].Surface;

            if (instance1 != null && instance1.Trile.ActorSettings.Type == ActorType.UnlockedDoor && FezMath.OrientationFromPhi(FezMath.ToPhi(instance1.Trile.ActorSettings.Face) + instance1.Phi) == FezMath.VisibleOrientation(this.CameraManager.Viewpoint))
            {
                ++this.GameState.SaveData.ThisLevel.FilledConditions.UnlockedDoorCount;
                TrileEmplacement id        = instance1.Emplacement + Vector3.UnitY;
                TrileInstance    instance2 = this.LevelManager.TrileInstanceAt(ref id);
                if (instance2.Trile.ActorSettings.Type == ActorType.UnlockedDoor)
                {
                    ++this.GameState.SaveData.ThisLevel.FilledConditions.UnlockedDoorCount;
                }
                this.LevelManager.ClearTrile(instance1);
                this.LevelManager.ClearTrile(instance2);
                this.GameState.SaveData.ThisLevel.InactiveTriles.Add(instance1.Emplacement);
                instance1.ActorSettings.Inactive = true;
            }
            if (!this.PlayerManager.SpinThroughDoor)
            {
                if (this.PlayerManager.CarriedInstance != null)
                {
                    this.PlayerManager.Action = ActorTypeExtensions.IsHeavy(this.PlayerManager.CarriedInstance.Trile.ActorSettings.Type) ? ActionType.ExitDoorCarryHeavy : ActionType.ExitDoorCarry;
                }
                else
                {
                    this.PlayerManager.Action = ActionType.ExitDoor;
                }
            }
            if (!this.skipFade)
            {
                this.GameState.ScheduleLoadEnd = true;
            }
            this.GameState.SkipLoadScreen = false;
        }
Ejemplo n.º 8
0
 protected override void TestConditions()
 {
     switch (this.PlayerManager.Action)
     {
     case ActionType.Teetering:
     case ActionType.IdlePlay:
     case ActionType.IdleSleep:
     case ActionType.IdleLookAround:
     case ActionType.IdleYawn:
     case ActionType.Idle:
     case ActionType.Walking:
     case ActionType.Running:
     case ActionType.Sliding:
         if (!this.PlayerManager.Grounded || (double)this.InputManager.Movement.X == 0.0 || this.PlayerManager.LookingDirection == HorizontalDirection.None)
         {
             break;
         }
         TrileInstance trileInstance = this.PlayerManager.WallCollision.NearLow.Destination;
         if (trileInstance == null || !ActorTypeExtensions.IsPickable(trileInstance.Trile.ActorSettings.Type) || (trileInstance.GetRotatedFace(this.CameraManager.VisibleOrientation) != CollisionType.AllSides || trileInstance.Hidden) || (trileInstance.PhysicsState == null || !trileInstance.PhysicsState.Grounded))
         {
             break;
         }
         NearestTriles nearestTriles = this.LevelManager.NearestTrile(trileInstance.Position);
         if (nearestTriles.Surface != null && nearestTriles.Surface.Trile.ForceHugging || (double)Math.Abs(trileInstance.Center.Y - this.PlayerManager.Position.Y) > 0.5 || trileInstance.Trile.ActorSettings.Type == ActorType.Couch && FezMath.OrientationFromPhi(FezMath.ToPhi(trileInstance.Trile.ActorSettings.Face) + trileInstance.Phi) != FezMath.VisibleOrientation(FezMath.GetRotatedView(this.CameraManager.Viewpoint, this.PlayerManager.LookingDirection == HorizontalDirection.Right ? -1 : 1)))
         {
             break;
         }
         this.PlayerManager.Action         = ActionType.Grabbing;
         this.PlayerManager.PushedInstance = trileInstance;
         break;
     }
 }
Ejemplo n.º 9
0
        public override void Update(GameTime gameTime)
        {
            if (this.GameState.Paused || this.GameState.InMap || (!this.CameraManager.ActionRunning || !FezMath.IsOrthographic(this.CameraManager.Viewpoint)) || this.GameState.Loading)
            {
                return;
            }
            Vector3 b1        = FezMath.SideMask(this.CameraManager.Viewpoint);
            Vector3 depthMask = FezMath.DepthMask(this.CameraManager.Viewpoint);
            Vector3 vector3_1 = FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint);

            if (this.RightPositions == 8)
            {
                bool flag = false;
                foreach (TrileInstance instance in this.Blocks)
                {
                    if (!flag)
                    {
                        ServiceHelper.AddComponent((IGameComponent) new GlitchyDespawner(this.Game, instance, NameOfGodPuzzleHost.PuzzleCenter + Vector3.UnitY * 2f + Vector3.UnitZ)
                        {
                            FlashOnSpawn = true,
                            ActorToSpawn = ActorType.PieceOfHeart
                        });
                        flag = true;
                    }
                    else
                    {
                        ServiceHelper.AddComponent((IGameComponent) new GlitchyDespawner(this.Game, instance));
                    }
                }
                this.GameState.SaveData.ThisLevel.InactiveArtObjects.Add(0);
                foreach (Volume volume in Enumerable.Where <Volume>((IEnumerable <Volume>) this.LevelManager.Volumes.Values, (Func <Volume, bool>)(x =>
                {
                    if (x.ActorSettings != null && x.ActorSettings.IsPointOfInterest)
                    {
                        return(x.Enabled);
                    }
                    else
                    {
                        return(false);
                    }
                })))
                {
                    volume.Enabled = false;
                    this.GameState.SaveData.ThisLevel.InactiveVolumes.Add(volume.Id);
                }
                this.LevelService.ResolvePuzzle();
                this.Enabled = false;
            }
            else
            {
                this.RightPositions = 0;
                Vector3 b2 = FezMath.RightVector(this.CameraManager.Viewpoint);
                foreach (TrileInstance trileInstance1 in this.Blocks)
                {
                    float num = FezMath.Dot(trileInstance1.Center, b2);
                    trileInstance1.LastTreasureSin = 0.0f;
                    foreach (TrileInstance trileInstance2 in this.Blocks)
                    {
                        if (trileInstance2 != trileInstance1 && (double)num > (double)FezMath.Dot(trileInstance2.Center, b2))
                        {
                            ++trileInstance1.LastTreasureSin;
                        }
                    }
                }
                using (List <TrileInstance> .Enumerator enumerator = this.Blocks.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        TrileInstance instance = enumerator.Current;
                        if (!instance.PhysicsState.Background && instance.Enabled && ((double)instance.Position.Y >= 57.0 && (double)instance.Position.Y < 57.75) && (this.PlayerManager.HeldInstance != instance && this.PlayerManager.PushedInstance != instance && instance.PhysicsState.Grounded) && instance.PhysicsState.Ground.First != this.PlayerManager.PushedInstance)
                        {
                            Vector3 vector3_2 = Vector3.Min(Vector3.Max(FezMath.Round((instance.Center - NameOfGodPuzzleHost.PuzzleCenter) / 1f), new Vector3(-8f, 0.0f, -8f)), new Vector3(8f, 1f, 8f));
                            Vector3 vector3_3 = NameOfGodPuzzleHost.PuzzleCenter + vector3_2 * 1f;
                            Vector3 vector3_4 = (vector3_3 - instance.Center) * FezMath.XZMask;
                            float   num1      = Math.Max(vector3_4.Length(), 0.1f);
                            instance.PhysicsState.Velocity += 0.25f * vector3_4 / num1 * (float)gameTime.ElapsedGameTime.TotalSeconds;
                            if ((double)num1 <= 0.100000001490116 && (double)vector3_2.Y == 0.0 && instance != this.PlayerManager.Ground.First && !Enumerable.Any <TrileInstance>((IEnumerable <TrileInstance>) this.Blocks, (Func <TrileInstance, bool>)(x => x.PhysicsState.Ground.First == instance)) && Enumerable.Any <TrileInstance>((IEnumerable <TrileInstance>) this.Blocks, (Func <TrileInstance, bool>)(b =>
                            {
                                if (b != instance && FezMath.AlmostEqual(b.Position.Y, instance.Position.Y))
                                {
                                    return((double)Math.Abs(FezMath.Dot(b.Center - instance.Center, depthMask)) < 1.0);
                                }
                                else
                                {
                                    return(false);
                                }
                            })))
                            {
                                instance.Enabled = false;
                                for (int index = 0; index < NameOfGodPuzzleHost.SpiralTraversal.Length; ++index)
                                {
                                    int           num2          = NameOfGodPuzzleHost.SpiralTraversal[index];
                                    NearestTriles nearestTriles = this.LevelManager.NearestTrile(NameOfGodPuzzleHost.PuzzleCenter + (float)num2 * 1f * depthMask, QueryOptions.None, new Viewpoint?(FezMath.GetRotatedView(this.CameraManager.Viewpoint, 1)));
                                    if (nearestTriles.Deep == null)
                                    {
                                        nearestTriles.Deep = this.LevelManager.NearestTrile(NameOfGodPuzzleHost.PuzzleCenter + (float)num2 * 1f * depthMask - depthMask * 0.5f, QueryOptions.None, new Viewpoint?(FezMath.GetRotatedView(this.CameraManager.Viewpoint, 1))).Deep;
                                    }
                                    if (nearestTriles.Deep == null)
                                    {
                                        nearestTriles.Deep = this.LevelManager.NearestTrile(NameOfGodPuzzleHost.PuzzleCenter + (float)num2 * 1f * depthMask + depthMask * 0.5f, QueryOptions.None, new Viewpoint?(FezMath.GetRotatedView(this.CameraManager.Viewpoint, 1))).Deep;
                                    }
                                    if (nearestTriles.Deep == null)
                                    {
                                        vector3_3 = instance.PhysicsState.Center = vector3_1 * instance.PhysicsState.Center + NameOfGodPuzzleHost.PuzzleCenter * depthMask + depthMask * (float)num2 * 1f;
                                        break;
                                    }
                                }
                                instance.Enabled = true;
                            }
                            if ((double)Math.Abs(vector3_4.X) <= 1.0 / 64.0 && (double)Math.Abs(vector3_4.Y) <= 1.0 / 64.0)
                            {
                                instance.PhysicsState.Velocity = Vector3.Zero;
                                instance.PhysicsState.Center   = vector3_3;
                                instance.PhysicsState.UpdateInstance();
                                this.LevelManager.UpdateInstance(instance);
                            }
                            if ((instance.PhysicsState.Ground.NearLow == null || instance.PhysicsState.Ground.NearLow.PhysicsState != null && (double)Math.Abs(FezMath.Dot(instance.PhysicsState.Ground.NearLow.Center - instance.Center, b1)) > 0.875) && (instance.PhysicsState.Ground.FarHigh == null || instance.PhysicsState.Ground.FarHigh.PhysicsState != null && (double)Math.Abs(FezMath.Dot(instance.PhysicsState.Ground.FarHigh.Center - instance.Center, b1)) > 0.875))
                            {
                                instance.PhysicsState.Ground  = new MultipleHits <TrileInstance>();
                                instance.PhysicsState.Center += Vector3.Down * 0.1f;
                            }
                            if (instance.PhysicsState.Grounded && instance.PhysicsState.Velocity == Vector3.Zero)
                            {
                                string          cubemapPath = instance.Trile.CubemapPath;
                                FaceOrientation o           = FezMath.OrientationFromPhi(FezMath.ToPhi(this.CameraManager.Viewpoint) + instance.Phi);
                                switch (o)
                                {
                                case FaceOrientation.Right:
                                case FaceOrientation.Left:
                                    o = FezMath.GetOpposite(o);
                                    break;
                                }
                                int index = (int)MathHelper.Clamp(instance.LastTreasureSin, 0.0f, 7f);
                                if (NameOfGodPuzzleHost.Slots[index].Face == o && NameOfGodPuzzleHost.Slots[index].TrileName == cubemapPath)
                                {
                                    ++this.RightPositions;
                                }
                            }
                        }
                    }
                }
            }
        }