temp.AddComponent(type);
temp.AddComponent(type);
FindObjectofType<>获取场景中类对象
DontDestroyOnLoad(gameObject)不销毁对象
Destroy(gameObject)销毁游戏对象
单例一般要用 C# class,mono可能会有问题
Image 的Raycast Target属性不需要检测射线就设置成false
添加Editor文件夹u3d打包会不打包这个文件夹里的内容
AssetPostprocessor负责资源导入操作
TextureImporter importer = (TextureImporter) assetImporter;
importer.textureType = TextureImporterType.Sprite;
//导入图片资源自动为精灵类型
Read/Write Enabled true会加大内存在用量
Generate Mip Maps true会自动生成低像素图片,3d游戏中会有好处,2d游戏不建议使用,打包会出现图片模糊的现象
public void SwitchMuteState()
{
}
public void PlayClip(AudioClip clip)
public void LoadData()
{
lv = PlayerPrefs.GetInt("lv",1);
w = 20+(lv*3)
h = Random.Range(9,12);
}
public void SaveData()
{
}
public ToolType toolType;
private void OnMouseUp()
{
switch(toolType)[
case
}
public void OnHoeSelected(bool isOn)
{
GameManager.Instance
}
学到这里时,已按FSM和MVC架构,实现所有游戏逻辑。
public void OnLevelButtonClick(){
if(isHide == false){
isHide = true;;
GetComponent<RectTransform>().DOAnchorPosY(-7,0.5f);
}else{
isHide = false;
GetComponent<RectTransform>().DOAnchorPosY(45,0.5f);
}
}
dir = new Vector2Int(Mathf.Clamp)
wo jiu
英语发音稍微有点迷哈哈哈,sderp笑死我了
没看之前,单独写出来了
AddTransition少写了return、;状态中act和Reson没调用。
if(){
float goffset;
if(Math.Abs(direction[i,0])+Math.Abs(direction[i,1]>1){
goffset = 1.4f;
}else{
goffset = 1;
}
if(tempData.g>data.g+goffset)
{
tempData.g = data.g + goffset;
tempData.parent = data;
}
}else{
goffset = 1.4f;
}else{
goffset = 1;
}
double h = HFun(newPoint);
PointData newData = new PointData(newPoint,data.g+goffset,h,data)
openList.Add(newData);
for()
List<PointData>openList = new List<PointData>();
openList.Add(new PointData(START_PNT,0,0,null));
PointData endPoint = null
for(bool finish = false;!finish&&openList.Count>0;)
{
openList.Sort((x,y)=>{return x.F().CompareTo(y.F());});//最小在上最大在下,降序排列
PointData data = openList[0];
openList.RemoveAt(0);//最小值从开列表去除
Point point = data.point;
if(MAP[point.x,point.y] == SPACE)
{
MAP[point.x,point.y] = VISITED;
}
for(int i = 0;i<directs.Rank;i++){
Point newPoint = new Point(point.x+directs[i,0],point.y+directs[i,1]);
if(newPnt.x>=0&&newPnt.x<MAX_PNT.x&&newPnt.y>=0&&newPnt.y<MAX_PNT.y){
char e = MAP[newPoint.x,newPoint.y];
if(e == END){
endPoint = data;
finish = true;
break;
}
if(e!=SPACE){
continue;
}
//扩展后的点若在开表终则更新g值
PointData tempData = openList.Find((x=>{return x.point.Equals(newPoint);}));
if(tempData!=null){
}
}
}
}
private static double H(Point pnt)
{
return HManhattanDistance(pnt);
}