void CustomActivity(bool firstTimeCalled)
        {
            PlayerCharacterInstance.CollideAgainst(() => mTileSolidCollision.CollideAgainstSolid(PlayerCharacterInstance.Collision), false);

            //this.PlayerCharacterInstance.CollideAgainst(SolidCollisions);
            this.PlayerCharacterInstance.DetermineMovementValues();
            Camera.Main.X = PlayerCharacterInstance.X;


            Cursor cursor = GuiManager.Cursor;

            if (cursor.PrimaryClick)
            {
                float x = cursor.WorldXAt(0);
                float y = cursor.WorldYAt(0);

                if (mTileSolidCollision.GetTileAt(x, y) == null)
                {
                    mTileSolidCollision.AddCollisionAtWorld(x, y);
                }
                else
                {
                    mTileSolidCollision.RemoveCollisionAtWorld(x, y);
                }
            }
        }
Exemple #2
0
        public void HandleCollision(TileShapeCollection solidCollision, TileShapeCollection cloudCollision)
        {
            var wasOnGround = IsOnGround;

            CollideAgainst(() => solidCollision.CollideAgainstSolid(this), false);

            if (!IsFallingThroughClouds)
            {
                CollideAgainst(() => cloudCollision.CollideAgainstSolid(this), true);
            }
            else if (!cloudCollision.CollideAgainst(this))
            {
                IsFallingThroughClouds = false;
            }

            if (!wasOnGround && IsOnGround && LandedAction != null)
            {
                LandedAction();
            }
        }
Exemple #3
0
        private void PerformCollision()
        {
            foreach (var player in PlayerList)
            {
                solidCollision.CollideAgainstSolid(player);

                player.CollideAgainstBounce(AboveWaterCollision, 0, 1, 0);

                objectCollidingWith = null;
                player.ObjectsToPerformCurrencyTransactionOn.Clear();

                foreach (var worldObject in WorldObjectEntityList)
                {
                    worldObject.SetIsVisible(true);
                    if (player.CollideAgainst(worldObject))
                    {
                        objectCollidingWith = worldObject;
                        worldObject.SetIsVisible(false);
                        break;
                    }
                }

                foreach (var disablerEntity in DisablerEntityList)
                {
                    if (player.CollideAgainst(disablerEntity))
                    {
                        string nameToDisable = disablerEntity.ObjectToDisable;

                        var matchingWorldObjectEntity = WorldObjectEntityList.FirstOrDefault(item => item.Name == nameToDisable);

                        if (matchingWorldObjectEntity != null)
                        {
                            matchingWorldObjectEntity.Enabled = false;
                        }
                        else
                        {
                            throw new InvalidOperationException($"Could not find a MoveToScreen entity with the name {nameToDisable}");
                        }
                    }
                }

                if (!isTransitioning)
                {
                    foreach (var enablerEntity in EnablerEntityList)
                    {
                        if (player.CollideAgainst(enablerEntity))
                        {
                            string nameToEnable = enablerEntity.ObjectToEnable;

                            var foundMoveEntity = MoveToScreenEntityList.FirstOrDefault(item => item.Name == nameToEnable);

                            var foundMatchingSafeZoneEntity = SafeZoneList.FirstOrDefault(item => item.Name == nameToEnable);

                            if (foundMoveEntity != null)
                            {
                                foundMoveEntity.Enabled = true;
                            }
                            else if (foundMatchingSafeZoneEntity != null)
                            {
                                foundMatchingSafeZoneEntity.Enabled = true;
                            }
                            else
                            {
                                throw new InvalidOperationException($"Could not find a MoveToScreen or SafeZone entity with the name {nameToEnable}");
                            }
                        }
                    }

                    foreach (var moveEntity in MoveToScreenEntityList)
                    {
                        if (moveEntity.Enabled && player.CollideAgainst(moveEntity))
                        {
                            isTransitioning = true;
                            GlobalData.TotalCurrencyCollected = player.TotalCurrencyCollected;
                            this.GameScreenGumRuntime.InterpolateTo(FadeoutCategory.Dark, FadeOutTime, InterpolationType.Linear, Easing.In);
                            this.Call(() => MoveToScreen($"Anfloga.Screens.{moveEntity.Screen}"))
                            .After(FadeOutTime);
                        }
                    }
                }

                foreach (var disabler in this.SafeZoneDisablerList)
                {
                    if (player.CollideAgainst(disabler))
                    {
                        arePlayerBuiltSafeZonesEnabled = false;
                    }
                }
                // We will assume the player is not in a replenish zone, then set to replenish if they are colliding with one.
                player.CurrentExplorationState = ExplorationState.Consume;
                foreach (var safeZone in SafeZoneList)
                {
                    if (player.CollideAgainst(safeZone))
                    {
                        if (safeZone.IsActive)
                        {
                            if ((arePlayerBuiltSafeZonesEnabled || safeZone.BuiltByPlayer == false) && safeZone.Enabled)
                            {
                                player.CurrentExplorationState = ExplorationState.Replenish;
                            }
                        }
                        else
                        {
                            //Let the playe know they can activate the safe zone?
                            player.ObjectsToPerformCurrencyTransactionOn.Add(safeZone);
                        }
                    }
                }
                foreach (var mineral in MineralDepositList)
                {
                    if (player.CollideAgainst(mineral))
                    {
                        player.ObjectsToPerformCurrencyTransactionOn.Add(mineral);
                    }
                }

                foreach (var darknessTrigger in DarknessTriggerList)
                {
                    if (player.CollideAgainst(darknessTrigger) && lastDarknessTriggerCollidedAgainst != darknessTrigger)
                    {
                        lastDarknessTriggerCollidedAgainst = darknessTrigger;
                        RespondToDarknessTriggerCollision(darknessTrigger);
                    }
                }
            }
        }
Exemple #4
0
 void CustomActivity(bool firstTimeCalled)
 {
     InputManager.Keyboard.ControlPositionedObject(Rectangle, 200);
     mCollision.CollideAgainstSolid(Rectangle);
 }