Exemple #1
0
        public static void Init(Control Viewport, IGameEntry gameEntry)
        {
            game = gameEntry;

            // Graphics inits
            fpser      = new Stopwatch();
            ClearColor = Color.Wheat;

            gViewPort     = Viewport.CreateGraphics();
            renderTexture = new Bitmap(Viewport.Width, Viewport.Height);
            gRender       = Graphics.FromImage(renderTexture);

            IsRender       = true;
            RenderInterval = 1;

            renderThread = new Thread(render);
            renderThread.Start();

            // physics inits
            UdpateInterval = 1;
            IsUpdating     = true;

            updateThread = new Thread(update);
            updateThread.Start();
        }
Exemple #2
0
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="machine"></param>
        /// <param name="callBack"></param>
        public void Init(Utility.StateMachine <IGameEntry> machine, UpgradeCallback upcallBack, Action <int> confirmCallback)
        {
            m_gameEntry = machine.GetOwner();
            machine.RegisterState(new CheckVersion(machine));
            machine.RegisterState(new CopyFile(machine));
            machine.RegisterState(new DownloadFile(machine));
            machine.RegisterState(new GameRun(machine));
            machine.RegisterState(new GameUpdate(machine));

            m_callBack        = upcallBack;
            m_downloadConfirm = confirmCallback;
        }
Exemple #3
0
 // 进入状态
 public override void Enter(object param)
 {
     Utility.Log.Info("CopyFile.Enter");
     m_owner = m_Statemachine.GetOwner();
     if (!Application.isEditor)
     {
         string strDataPath = Application.dataPath;
         Thread t           = new Thread(() =>
         {
             // 更新资源文件
             Utility.EngineNativeMethod.ExtractZip(strDataPath, GameUpgrade.localFilePath, PluginCallback, "assets", "assets/bin");
         });
         t.Start();
     }
     else
     {
         GameUpgrade.Instance.ReadLocalVersion();
         // 版本检测
         m_owner.ChangeState(GameState.CHKVersion, false);
     }
 }
Exemple #4
0
        /// <summary>
        /// Engine entry.... all begins from here
        /// </summary>
        public static AshUnityEntry New(GameObject gameObjectToAttach = null, IGameEntry entry = null, bool showComponentsInHierarchy = false)
        {
            if (Instance != null)
            {
                throw new AshException(" AshUnityEntry Instance is exist.");
            }

            var m_goToAttach = gameObjectToAttach;

            if (m_goToAttach == null)
            {
                m_goToAttach = new GameObject("AshUnityEntry");
                //throw new AshException(" AshUnityEntry script attach null Unity GameObject.");
            }

            AshUnityEntry ashUnityEntry = m_goToAttach.AddComponent <AshUnityEntry>();

            ashUnityEntry.m_GameEntry = entry;

            ashUnityEntry.m_ShowChildInHierarchy = showComponentsInHierarchy;
            return(ashUnityEntry);
        }
Exemple #5
0
        public override void Enter(object param)
        {
            base.Enter(param);
            m_Owner = this.m_Statemachine.GetOwner();
            if (m_Owner == null)
            {
                return;
            }

            Utility.Log.Info("GameRun.Enter");

            // 写runVersion
            GameUpgrade.Instance.SaveLocalVersion();

            //加载游戏
            if (GameUpgrade.Instance.callback != null)
            {
                GameUpgrade.Instance.callback(GameUpgrade.UpgradeError.UpgradeError_GameRun, 0, 0, UpgradeDesc.EnterGame);
            }
            // 清理更新模块
            GameUpgrade.Instance.Close();
        }
Exemple #6
0
        private static void CheckGameAssembly()
        {
            var assemblies = AppDomain.CurrentDomain.GetAssemblies();

            GameScriptAttribute gamescriptAttr = null;

            foreach (var assembly in assemblies)
            {
                gamescriptAttr = Attribute.GetCustomAttribute(assembly, typeof(GameScriptAttribute)) as GameScriptAttribute;
                if (gamescriptAttr != null)
                {
                    break;
                }
            }

            var scripttype = gamescriptAttr.entryType;

            if (scripttype == null)
            {
                return;
            }

            s_gamescript = Activator.CreateInstance(scripttype) as IGameEntry;
        }
Exemple #7
0
 public CheckVersion(Utility.StateMachine <IGameEntry> machine)
     : base(machine)
 {
     m_nStateID = (int)GameState.CHKVersion;
     m_owner    = m_Statemachine.GetOwner();
 }