❤️UNITY Actual Combat Advanced-Framework Introduction-2

  • Game Farmework Framework Basics

       The framework is very good, anyone who uses it will know, it is the benefit of small and medium game companies, don't say much, just introduce a wave

        Overview:

Component function name corresponding script
game entry Game Framework GameEntry
Basic components Builtin BaseComponent
global configuration Config ConfigComponent
data node Data Node DataNodeComponent
data sheet Data Table DataTableComponent
Debugger Debugger DebuggerComponent
download Download DownloadComponent
entity Entity EntityComponent
event Event EventComponent
Finite State Machine FSM FsmComponent
localization Localization LocalizationComponent
network Network NetworkComponent
object pool Object Pool ObjectPoolComponent
process Procedure ProcedureComponent
quote pond Reference Pool ReferencePoolComponent
resource management Resource ResourceComponent
scene management Scene SceneComponent
game configuration Setting SettingComponent
interface management UI UIComponent
sound Sound SoundComponent
web request Web Request WebRequestComponent
built-in data Builtin Data BuiltinDataComponent
File system (added in new version)

FileSystem

none

        It looks confusing at first glance, how to use so many components, don't worry, first set this setting, and then run it

(1) Configure Builtins
 

Editor Resource Mode:
Check to directly use the resources under the editor, otherwise, judge whether to read the AB resources in StreamingAssets or the AB resources in PersistentDataPath according to the ResourceMode of Resource

 (2) Configure Localization

 

 (3) Configure Procedure

Check all, select launch main process

(4) Configure Resource

Package: In stand-alone mode, AB resources need to be placed in StreamingAssets
Updatable: In update mode, you need to fill in Update Prefix Uti Your resource storage download address

(5) Configuration UI

Generally speaking, you need to rewrite UGuiGroupHelper by yourself.
I set up 2 layers here. The bottom layer: BaseUI needs UI camera binding. The top layer Overlay is
drawn up according to their own needs.

        private void InitCanvas()
        {
            m_CachedCanvas = gameObject.GetOrAddComponent<Canvas>();
            if (m_Depth == 0)
            {
                m_CachedCanvas.renderMode = RenderMode.ScreenSpaceCamera;
                m_CachedCanvas.worldCamera = GameObject.Find("UICamera").GetComponent<Camera>();
                m_CachedCanvas.planeDistance = m_CachedCanvas.worldCamera.farClipPlane / 2;
                m_CachedCanvas.sortingLayerName = name;
            }
            else
            {
                m_CachedCanvas.renderMode = RenderMode.ScreenSpaceOverlay;
                m_CachedCanvas.overrideSorting = true;
                m_CachedCanvas.sortingOrder = DepthFactor * m_Depth;
            }
            CanvasScaler csc = gameObject.GetOrAddComponent<CanvasScaler>();
            csc.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize;
            csc.referenceResolution = new Vector2(Screen_width, Screen_height);
            csc.screenMatchMode = CanvasScaler.ScreenMatchMode.MatchWidthOrHeight;
            csc.matchWidthOrHeight = MatchWidthOrHeight;
            gameObject.GetOrAddComponent<GraphicRaycaster>();
        }

(6) Configure Web Request

Unity gradually abandoned the www scheme after 2017, and mainly promoted the unityWebRequest scheme

how to read

1. Start reading
        ChangeState<Procedure>(procedureOwner) from ProcedureLaunch;
        used to jump the process
2.ProcedureSplash can make some opening animations, for example:
                I am a serious game,
                not a spiritual opium,
                it is my parents’ inaction,
                but blame me

3. ProcedureCheckVersion Check
   whether the resource process is in editor mode
        : Enter the ProcedurePreload process
        No: Check Resource Mode
                Package: Initialize resources, enter the ProcedurePreload process
                Updatable: Request the version number, check whether the resource needs to be updated
4. ProcedurePreload preload process

            // Preload configs
            LoadConfig("DefaultConfig");
            // Preload data tables
            foreach (string dataTableName in DataTableNames)
            {
                LoadDataTable(dataTableName);
            }
            // Preload dictionaries
            LoadDictionary("Default");
            // Preload fonts
            LoadFont("MainFont");
            // Preload PersistentDataPath image
            // Init Shader
            // Do everything

Load the content you need
5.ProcedureUpdateGame update process
Use GameEntry.Resource.CheckResources to check the resources that need to be updated
Use GameEntry.Resource.UpdateResources to update your resources
Simultaneously listen to OnResourceUpdateStart, OnResourceUpdateChanged, OnResourceUpdateSuccess, OnResourceUpdateFailure to handle what you need
6.ProcedureMainMenu The process of the main menu
has finally entered its own rhythm, and it can be done happily.
7. What process do you need to add yourself, it is all processed by the finite state machine, and you need to judge the timing of entering the next process by yourself

How to load the UI interface

All UI interface scripts inherit the UGuiForm class, and the base class contains     many     basic     function     functions
    . Pause     OnResume interface pause resume     OnCover interface occlusion     OnReveal interface occlusion recovery     OnRefocus interface activation OnUpdate     interface polling     OnDepthChanged interface depth change









    Get instances of other interfaces:
     //Load the UI interface
    GameEntry.UI.OpenUIForm(UIFormId.MenuForm, this);
    //Open the dialog interface
    GameEntry.UI.OpenDialog(new DialogParams()
     {                     Mode = 1,                     Title = GameEntry.Localization .GetString("LoginDemo.Tip"),                     Message = GameEntry.Localization.GetString("LoginDemo.AccountError"),       });



Setting component

For accessing local data, it is implemented using Unity's PlayerPref, and the calling method is similar, but one more layer is encapsulated
    //Setting and saving data
    GameEntry.Setting.SetString(Constant.Setting.Language, language.ToString()) ;
    GameEntry.Setting.Save();
    //Get data
    GameEntry.Setting.GetString(Constant.Setting.Language);
    //Clear the data corresponding to the key
    GameEntry.Setting.RemoveKey(Constant.Setting.Language);

DataTable component


        Load all data in the component ProcedurePreload (preloading process) for loading         and obtaining all table data
        //Get the entire table data
        IDataTable<DRUIForm> dtUIForm = GameEntry.DataTable.GetDataTable<DRUIForm>();
        //According to the number of data table rows To get the data of this row
        DRUIForm drUIForm = dtUIForm.GetDataRow(uiFormId);
        // After getting the table data, remember to judge it empty
        if (drUIForm == null)
        {             return false;         }

Download download component

It is used for resource update and supports resuming uploads.
    Example:
    //Download the required resource file from the url remote address to the local localPath path
    //Note: Both localPath and url require a full path, that is, include the file name and the file name suffix!
    GameEntry.Download.AddDownload(string localPath, string url);
    GameEntry.Download.CurrentSpeed//Current download speed
    //Subscribe download success event
    GameEntry.Event.Subscribe(UnityGameFramework.Runtime.EventId.DownloadSuccess, DownloadSuc);
    void DownloadSuc() {         DownloadSuccessEventArgs ne = (DownloadSuccessEventArgs)e;         if(ne.UserData!=this) return;//Whether it is the currently listening event         ...     }



Entity entity component

All objects in the game are loaded through this component (such as: enemies, bullets, characters, skill effects, etc.)
    Examples:
    (1) Each entity class inherits the EntityObject class to achieve specific logic functions. For example: Bullet inherits EntityObject
    (2 ) At the same time, create a corresponding data class for the entity, and inherit the BulletData class to achieve such as: BulletData inherits EntityData
    (3) Add a row of data for the entity in the entity table Entity.txt
    (4) Add the entity in the extension class EntityExtension.cs The display extension such as: 
        public static void ShowBullet(this EntityComponent entityCompoennt, BulletData data)
        {             entityCompoennt.ShowEntity(typeof(Bullet), "Bullet", data);         }     (5) Call implementation:         GameEntry.Entity.ShowBullet(new BulletData( .......));



Localization language localization component

    All localized languages ​​are stored in a fixed folder using XML files, such as:
    Simplified Chinese is stored in: Assets/GameMain/Localization/ChineseSimplified/Dictionaries/Default.xml
    Add a unique key and value in default.xml to enter the code Get the usage example in
    :
    //Get the corresponding string value according to the key of the text
    GameEntry.Localization.GetString("Dialog.ConfirmButton");

Object Pool object pool component

The corresponding object pool can be created according to the object type:

    //创建一个HPBar的对象类,继承自对象基类
	public class HPBarItemObject : ObjectBase
    {
        public HPBarItemObject(object target)
            : base(target)
        {

        }

        protected override void Release()
        {
            HPBarItem hpBarItem = (HPBarItem)Target;
            if (hpBarItem == null)
            {
                return;
            }

            Object.Destroy(hpBarItem.gameObject);
        }
    }

    //IObjectPool:对象池接口
	private IObjectPool<HPBarItemObject> m_HPBarItemObjectPool = null;
	//CreateSingleSpawnObjectPool 创建允许单次获取的对象,
	//就是说创建出来的对象同时只能有一个地方使用,需要多个地方同时使用的就会创建多个对象
	m_HPBarItemObjectPool = GameEntry.ObjectPool.CreateSingleSpawnObjectPool<HPBarItemObject>("HPBarItem", m_InstancePoolCapacity);
	//CreateMultiSpawnObjectPool 创建允许多次获取的对象,
	//就是说该方法创建的对象可以由多处使用,永远只会存在一个对象,多处共用!
	m_HPBarItemObjectPool = GameEntry.ObjectPool.CreateMultiSpawnObjectPool<HPBarItemObject>("HPBarItem", m_InstancePoolCapacity);
	//创建对象
	m_HPBarItemObjectPool.Register(new HPBarItemObject(hpBarItem), true);
	//获取对象
	HPBarItemObject hpBarItemObject = m_HPBarItemObjectPool.Spawn();
	//回收对象
	m_HPBarItemObjectPool.Unspawn(hpBarItem);

	注:详细参考Starface工程HPBarComponent.cs脚本

 Powerful Utility tool class

After reading all the above, I have also configured it once, and successfully entered the battle of Starface, then congratulations, you have started the basics

 *★,°*:.☆( ̄▽ ̄)/$:*.°★* 。
 *★,°*:.☆( ̄▽ ̄)/$:*.°★* 。
 *★,°*:.☆( ̄▽ ̄)/$:*.°★* 。
 *★,°*:.☆( ̄▽ ̄)/$:*.°★* 。
 *★,°*:.☆( ̄▽ ̄)/$:*.°★* 。
 *★,°*:.☆( ̄▽ ̄)/$:*.°★* 。


  • interface

Let's make a fake frame interface first

PS: Mainly I bought a XGIMI projector. The music listening software on it had bad reviews. Members can’t buy it for nothing, so I decided to use the Internet to suppress the cloud, and I will use it as an example....

Things to do:

  1. Load user avatar image
  2. user name assignment
  3. Dynamically create the button on the left according to your playlist
  4. Previous/Play/Next button response events
  5. Progress bar: current playing event/playing progress/total song time
  6. Volume adjustment
  7. load song image
  8. song title assignment
  9. singer assignment
  10. Search for songs and display the searched song information
  11. Minimize/Maximize/Close

These all need real data to cooperate...


  • Data Sources

The web version of NetEase Cloud Music: NetEase Cloud Music

Method 1: Use F12 Dafa
        to search: Chun Ting Xue, the following songs appear

Select Network in the developer tool interface to view the HTTP request message

        This piece of json data is the real data, the song list and so on are all obtained in this way, find
        a text and save it, and read the text in unity to parse the json 

Method 2: Reptile Dafa

        Find the URL and content of the request, forge a key to open the door
        and make an Http request in Unity

 

Method 3: Git Dafa

        The world is full of wonders, there is nothing you can't find, only what you can't think of!

        There is an API packaged by someone else on Github, which can be used directly... It's very convenient... Really... Anyone who uses it will know...
I don't tell ordinary people



Interested friends can pay attention to a wave

Code tomorrow!

Guess you like

Origin blog.csdn.net/flj135792468/article/details/120210339