如果您无法下载资料,请参考说明:
1、部分资料下载需要金币,请确保您的账户上有足够的金币
2、已购买过的文档,再次下载不重复扣费
3、资料包下载后请先用软件解压,在使用对应软件打开
HYPERLINK"http://www.gopedu.com/"\t"http://unity.gopedu.com/_blank"背包系统(三)10、修改物品脚本,完成物品个数加1的功能publicUISpritesprite;publicUILabellabel;privateintcount=1;publicvoidAddCount(intnumber){count+=number;label.text=count+"";}11、修改格子脚本,功能完成当前游戏物品的名字和我们捡到到的游戏物品的名字一样时,物品个数加1;当前游戏物品的名字和我们捡到到的游戏物品的名字不一样时,向新的格子里面添加物品【HYPERLINK"http://www.gopedu.com/"\t"http://unity.gopedu.com/_blank"狗刨学习网】boolflag=false;for(inti=0;i<cells.Length;i++){if(cells[i].transform.childCount>0)//当前格子里面有物品{Knapsackkn=cells[i].GetComponentInChildren<Knapsack>();//当前游戏物品的名字和我们捡到到的游戏物品的名字一样if(kn.sprite.spriteName==name){flag=true;kn.AddCount(1);break;}}}//当前游戏物品的名字和我们捡到到的游戏物品的名字不一样if(flag==false){for(inti=0;i<cells.Length;i++){if(cells[i].transform.childCount==0)//当前格子里面没有背包{GameObjectgo=NGUITools.AddChild(cells[i],item);//把新生成的背包放入格子里面go.GetComponent<UISprite>().spriteName=name;//为新生成的背包添加名称go.transform.localPosition=Vector3.zero;//把背包居中break;}}}这篇文章来自HYPERLINK"http://www.gopedu.com/"狗刨学习网