{
//declare a static instance
Public static Player Instance;
//get a static instance
Public static Player GetInstance ()
{
If (the Instance==null)
{
Player ins=new Player ();
The Instance=ins.
Return the Instance.
}
The else
{
Return the Instance.
}
}
Private string playerName="zhang SAN";
Private float maxHp=1000;
Private float currentHp=1000;
Private float maxMp=1000;
Private float currentMp=1000;
//public set access method
Public void Set_playName (string value)
{
PlayerName=value;
}
Public string Get_playerame ()
{
Return playerName;
}
Public void Set_maxHp (float value)
{
MaxHp=value;
}
Public float Get_maxHp ()
{
Return maxHp;
}
Public void Set_currentHp (float value)
{
CurrentHp=Mathf. Min (value, maxHp);
}
Public float Get_currentHp ()
{
Return currentHp;
}
Public void Set_maxMp (float value)
{
MaxMp=Mathf. Min (value, maxMp);
}
Public float Get_maxMp ()
{
Return maxMp;
}
Public void Set_currentMp (float value)
{
CurrentMp=Mathf. Min (value, maxMp);
}
Public float Get_currentMp ()
{
Return currentMp;
}
}
CodePudding user response:
This is not the unity of content and this is the most basic c # syntax defines some properties and methodsCodePudding user response:
C # basic grammar, defines some properties and methodsCodePudding user response:
This is a c # basic contentCodePudding user response:
Defines the attributes and the method of read and write several attributesCodePudding user response:
This is a singleton, and some properties and methodsCodePudding user response:
You send the wrong place,,, there is no answer, c #,,CodePudding user response:
Unity is rubbish, don't waste time, be inferior to learn UE4 (released UE5 is expected to the end), id Tech 7 engine, these is a high level of FPS game engineCodePudding user response:
how to commentCodePudding user response:
don't waste timeCodePudding user response:
Send the wrong placeCodePudding user response:
B stand a wheat buckle teach unity basedAlso explain the code
You can see