示例#1
0
        public static RoomScene Create(object state)
        {
            var gs = state as GameplayState;

            var s = new RoomScene();

            var room = gs.CurrentRoom;

            var roomEntity = new Entity();

            roomEntity.AddComponent(new RoomController(room, gs));
            roomEntity.AddComponent(new TilemapRenderer(
                                        tileWidth: room.TileSize,
                                        tileHeight: room.TileSize,
                                        tilemap: room.Tilemap
                                        ));
            s.AddEntity(roomEntity);

            room.Inanimates.Select(i => InanimateEntity(gs, i)).ToList().ForEach(i => s.AddEntity(i));
            room.Enemies.Select(i => EnemyEntity(gs, i)).ToList().ForEach(i => s.AddEntity(i));

            var player = gs.Player;

            if (player.Position == Vector2.Zero)
            {
                player.Transform.Position = room.PlayerStartPosition;
            }
            s.AddEntity(player);
            s.AddEntity(player.Hammer);

            var camera = new Entity();

            camera.AddComponent(new Camera());
            var cc = new CameraController(player, gs);

            camera.AddComponent(cc);
            s.AddEntity(camera);
            player.Shake = cc.Shake;

            var sacrificeTimer     = new Entity();
            var spriteTextRenderer = new SpriteTextRenderer("GenericFont")
            {
                Layer = "Hud",
            };

            sacrificeTimer.AddComponent(spriteTextRenderer);
            sacrificeTimer.AddComponent(new SacrificeUpdater(gs, spriteTextRenderer));
            sacrificeTimer.Transform.Position = new Vector2(100, 100);
            s.AddEntity(sacrificeTimer);

            return(s);
        }
        protected unsafe static float LayoutSetTransform(SpriteTextRenderer spriteRenderer, float position)
        {
            //IL_0007: Unknown result type (might be due to invalid IL or missing references)
            //IL_000c: Unknown result type (might be due to invalid IL or missing references)
            //IL_0015: Unknown result type (might be due to invalid IL or missing references)
            //IL_0021: Unknown result type (might be due to invalid IL or missing references)
            //IL_0026: Unknown result type (might be due to invalid IL or missing references)
            //IL_0029: Unknown result type (might be due to invalid IL or missing references)
            Transform transform     = spriteRenderer.get_transform();
            Vector3   localPosition = transform.get_localPosition();

            localPosition.x = position;
            transform.set_localPosition(localPosition);
            Bounds textBounds = spriteRenderer.textBounds;

            return(Mathf.Ceil(100f * ((IntPtr)(void *)textBounds.get_max()).x) / 100f);
        }
示例#3
0
 public SacrificeUpdater(GameplayState gs, SpriteTextRenderer spriteTextRenderer)
 {
     _gs = gs;
     _spriteTextRenderer = spriteTextRenderer;
     SetHudText();
 }