Exemplo n.º 1
0
        public Game(Context ctx)
        {
            this.ctx = ctx;

            state = GameState.UNDEFINED;

            systems = new GameSystems();
            systems.Add(new AnimSystem());
            systems.Add(new MovementSystem());
            systems.Add(new MapSystem(ctx.config.Get <MapSystemConfig>()));
            systems.Add(new CameraSystem());
            systems.Add(new EntitySystem());

            systems.Init(systems, ctx);

            ActionSystem actionSys = new ActionSystem(assemblyNames: "Game");

            actionSys.OnActionSystemRegistered += iActionSystem => {
                if (iActionSystem is IGameSystem gs)
                {
                    gs.Init(systems, ctx);
                }
            };
            actionSys.RegisterSystems();

            MapSystem mapSystem = systems.Get <MapSystem>();

            mapSystem.Load(new[] {
                0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1,
                0x1, 0xB, 0xB, 0xB, 0xB, 0x1000A, 0xB, 0xB, 0xB, 0x1, 0x1, 0x1,
                0x1, 0xB, 0xA, 0xA, 0xA, 0xA, 0xA, 0xA, 0xB, 0x1, 0x1, 0x1,
                0x1, 0xB, 0xA, 0xA, 0xA, 0xA, 0xA, 0xA, 0xB, 0x1, 0x1, 0x1,
                0x1, 0xB, 0xA, 0xA, 0xA, 0xA, 0xA, 0xA, 0xB, 0x1, 0x1, 0x1,
                0x1, 0xB, 0xB, 0xB, 0xB, 0xB, 0xB, 0xB, 0xB, 0x1, 0x1, 0x1,
                0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1,
                0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1,
            }, 12, "Entrance");

            player = systems.Get <EntitySystem>().CreatePlayer("Player");
            int spawnpoint = mapSystem.Map.Spawnpoint;

            player.SetLocalPosition(mapSystem.Map.IndexToWorldPos(spawnpoint));

            ctx.eventPump.Dispatch();
            // systems.Get<CameraSystem>().SetTarget(player.transform);
        }
Exemplo n.º 2
0
        private static bool Do <T>(Item source, Item target) where T : Component, IAction
        {
            T action = source.GetAction <T>();

            return(action != null && ActionSystem.Resolve(source, action, target));
        }
Exemplo n.º 3
0
 public ActionSystem(params string[] assemblyNames)
 {
     self       = this;
     assemblies = new string[assemblyNames.Length];
     Array.Copy(assemblyNames, assemblies, assemblyNames.Length);
 }