Exemplo n.º 1
0
        //private static readonly ILog log = LogManager.GetLogger(typeof(Launcher));

        //private List<Loading> list = new List<Loading>();

        private void Awake()
        {
            GlobalWindowManager windowManager = FindObjectOfType <GlobalWindowManager>();

            if (windowManager == null)
            {
                throw new NotFoundException("Can't find the GlobalWindowManager.");
            }

            //DontDestroyOnLoad(this);

            ApplicationContext context   = ApplicationContext.GetApplicationContext();
            IServiceContainer  container = context.GetContainer();

            /*初始化数据绑定服务*/
            BindingServiceBundle bundle = new BindingServiceBundle(context.GetContainer());

            bundle.Start();

            /* Initialize the ui view locator and register UIViewLocator */
            container.Register <IUIViewLocator>(new ResourcesViewLocator());

            /*网络消息分析器注册*/
            IMessageDispatcher messageDispatcher = new MessageDispatcher();

            container.Register <IMessageDispatcher>(messageDispatcher);

            /*初始化网络连接*/
            ISession session = new Session();

            container.Register <ISession>(session);
            //session.Connect("127.0.0.1", 10001);

            SpriteAtlas spriteAtlas = Resources.Load <SpriteAtlas>("Atlas/Icon");

            IConverterRegistry converterRegistry = context.GetContainer().Resolve <IConverterRegistry>();

            converterRegistry.Register("spriteConverter", new SpriteConverter(spriteAtlas));

            SpriteAtlas merchandiseAtlas = Resources.Load <SpriteAtlas>("Atlas/Merchandise");

            converterRegistry.Register("merchandiseConverter", new SpriteConverter(merchandiseAtlas));

            SpriteAtlas wheelAtlas = Resources.Load <SpriteAtlas>("Atlas/Wheel");

            converterRegistry.Register("wheelConverter", new SpriteConverter(wheelAtlas));

            /*初始化定时器*/
            ITask taskContext = new TaskContext();

            container.Register <ITask>(taskContext);


            IRewardRepository rewardRepository = new RewardRepository();

            container.Register <IRewardRepository>(rewardRepository);
        }
        void Awake()
        {
            ApplicationContext   context        = Context.GetApplicationContext();
            BindingServiceBundle bindingService = new BindingServiceBundle(context.GetContainer());

            bindingService.Start();

            Dictionary <string, Sprite> sprites = new Dictionary <string, Sprite>();

            foreach (var sprite in Resources.LoadAll <Sprite>("EquipTextures"))
            {
                if (sprite != null)
                {
                    sprites.Add(sprite.name, sprite);
                }
            }
            IConverterRegistry converterRegistry = context.GetContainer().Resolve <IConverterRegistry>();

            converterRegistry.Register("spriteConverter", new SpriteConverter(sprites));
        }
Exemplo n.º 3
0
        void Awake()
        {
            //获取全局上下文
            ApplicationContext context = Context.GetApplicationContext();
            //初始化数据绑定服务
            BindingServiceBundle bindingService = new BindingServiceBundle(context.GetContainer());

            bindingService.Start();

            Dictionary <string, Sprite> sprites = new Dictionary <string, Sprite>();

            foreach (var sprite in Resources.LoadAll <Sprite>("EquipTextures"))
            {
                if (sprite != null)
                {
                    sprites.Add(sprite.name, sprite);
                }
            }
            //获得转换器注册服务,它在数据绑定服务启动时会自动创建并注入上下文容器中
            IConverterRegistry converterRegistry = context.GetContainer().Resolve <IConverterRegistry>();

            //注册精灵转换器
            converterRegistry.Register("spriteConverter", new SpriteConverter(sprites));
        }