Пример #1
0
        private void RunTickForObjectGroup(Dictionary <int, GameObject> objectGroup)
        {
            // Loop through each object in the dictionary, run it's tick:
            foreach (var obj in objectGroup)
            {
                obj.Value.RunTick();

                // Run Tile Detection for the Object
                CollideTile.RunTileCollision(obj.Value);
            }
        }
Пример #2
0
        // Identical to "RunTickForObjectGroup", but with an extra overlap test for Characters.
        // RunTileCollision only detects what you're moving INTO, not what you're on top of.
        // Characters need the additional check to know what they're on top of, such as for Chests, Doors, NPCs, etc.
        private void RunTickForCharacterGroup(Dictionary <int, GameObject> objectGroup)
        {
            foreach (var obj in objectGroup)
            {
                Character character = (Character)obj.Value;

                // If the character is frozen from a reset, prevent them from running any actions.
                if (character.frozenFrame >= Systems.timer.Frame)
                {
                    // If we're on the release frame, provide a sound:
                    if (character.frozenFrame == Systems.timer.Frame)
                    {
                        character.room.PlaySound(Systems.sounds.pop, 0.7f, Systems.camera.posX + Systems.camera.halfWidth, Systems.camera.posY + Systems.camera.halfHeight);
                    }

                    continue;
                }

                character.RunTick();

                CollideTile.RunTileCollision(character);

                // Determine Tiles Potentially Touched
                short gridX  = character.GridX;
                short gridY  = character.GridY;
                short gridX2 = character.GridX2;
                short gridY2 = character.GridY2;

                // Run Collision Tests on any tiles beneath the Character (to identify Chests, Doors, NPCs, etc).
                CollideTile.RunGridTest(character, gridX, gridY, DirCardinal.Center);

                if (gridX != gridX2)
                {
                    CollideTile.RunGridTest(character, gridX2, gridY, DirCardinal.Center);

                    if (gridY != gridY2)
                    {
                        CollideTile.RunGridTest(character, gridX, gridY2, DirCardinal.Center);
                        CollideTile.RunGridTest(character, gridX2, gridY2, DirCardinal.Center);
                    }
                }
                else if (gridY != gridY2)
                {
                    CollideTile.RunGridTest(character, gridX, gridY2, DirCardinal.Center);
                }
            }
        }