Exemplo n.º 1
0
    private void Awake()
    {
        // Master
        MasterView viewMaster = Instantiate(masterView);

        viewMaster.Initialize(gameSetting.masterSetting);
        Master          master        = new Master(viewMaster);
        MasterAIControl masterControl = new MasterAIControl(master);

        // AI
        List <AIControl> AIControlList = new List <AIControl>();
        List <Character> AICharacter   = new List <Character>();

        for (int i = 0; i < AINumber; ++i)
        {
            CharacterView view = Instantiate(characterPrefab);
            view.Initialize(gameSetting.characterSetting);
            Character character = new Character(view);
            AIControl aiControl = new AIControl(gameSetting.AIControlSetting, character, master);
            AIControlList.Add(aiControl);
            AICharacter.Add(character);
        }

        // Player
        CharacterView playerView = Instantiate(characterPrefab);

        playerView.Initialize(gameSetting.characterSetting);
        Character     player        = new Character(playerView);
        PlayerControl playerControl = new PlayerControl(player, AICharacter);

        GameTime gameTime = new GameTime();

        controllerManager = new ControllerManager(playerControl, AIControlList, masterControl);
        gameManager       = new GameManager(gameTime, controllerManager, player, AICharacter, master);

        successPanel.SetGameTime(gameTime);
    }
Exemplo n.º 2
0
        /// <summary>
        /// 处理和渲染指定 HTML 范畴
        /// </summary>
        /// <param name="scope">要处理和渲染的范畴</param>
        /// <returns>渲染结果</returns>
        protected override string RenderCore(IHtmlContainer scope)
        {
            HttpContext.Trace.Write("JumonyView", "Begin GetViewHandler");
            var handler = GetHandler(VirtualPath);

            HttpContext.Trace.Write("JumonyView", "End GetViewHandler");

            HttpContext.Trace.Write("JumonyView", "Begin Process");
            OnPreProcess();
            ProcessScope(handler);
            OnPostProcess();
            HttpContext.Trace.Write("JumonyView", "End Process");

            HttpContext.Trace.Write("JumonyView", "Begin ProcessActionRoutes");
            Url.ProcessActionUrls(Scope);
            HttpContext.Trace.Write("JumonyView", "End ProcessActionRoutes");


            HttpContext.Trace.Write("JumonyView", "Begin ResolveUri");
            Scope.Find("form[postback]")
            .SetAttribute("action", RawViewContext.HttpContext.Request.RawUrl)
            .SetAttribute("method", "post")
            .RemoveAttribute("postback");

            Url.ResolveUri(Scope, VirtualPath);
            HttpContext.Trace.Write("JumonyView", "End ResolveUri");

            AddGeneratorMetaData();


            RenderAdapters = GetRenderAdapters(handler);

            string result;

            if (MasterView != null)
            {
                HttpContext.Trace.Write("JumonyView", "Begin Initialize Master");
                MasterView.Initialize(ViewContext);
                HttpContext.Trace.Write("JumonyView", "End Initialize Master");


                var jumonyMaster = MasterView as JumonyMasterView;
                if (jumonyMaster != null)
                {
                    HttpContext.Trace.Write("JumonyView", "Begin Process Master");
                    ProcessMaster(jumonyMaster);
                    HttpContext.Trace.Write("JumonyView", "Begin Process Master");
                }

                HttpContext.Trace.Write("JumonyView", "Begin Render");
                OnPreRender();
                result = MasterView.Render(this);
                OnPostRender();
                HttpContext.Trace.Write("JumonyView", "End Render");
            }
            else
            {
                HttpContext.Trace.Write("JumonyView", "Begin Render");
                OnPreRender();
                result = RenderContent(RenderAdapters.ToArray());
                OnPostRender();
                HttpContext.Trace.Write("JumonyView", "End Render");
            }


            var disposable = handler as IDisposable;

            if (disposable != null)
            {
                disposable.Dispose();
            }

            return(result);
        }