综述
本次主要介绍小组最后一个游戏,本人主要参与部分道具的开发。
下面介绍这些道具信息以及代码实现。
内容
道具
在该游戏中,道具是随机生成的,有地雷、导弹、随机(里面有疾跑和隐身)和血瓶。他们的控制都是由一个脚本来决定的。
//生成道具
if(PhotonNetwork.IsMasterClient && PropsGameManager.instance.isGameStart)
{
//计时
if(currentTime > 0)
{
currentTime -= Time.deltaTime;
}
else
{
//判断道具数是否到达上限
if (currentCountInScene < maxSpawnCountPermit)
{
for (int i = 0; i < spawnCountOneTime; i++)
{
Vector3 pos = new Vector3(Random.Range(-18f, 18f), 1, Random.Range(-18f, 18f));
PhotonNetwork.Instantiate(Const.PUN_PROPS_GAME_PREFABS_BASEPATH
+ propsPrefabNameWithRandom[Random.Range(0, propsPrefabNameWithRandom.Length)]
, pos
, Quaternion.identity);
currentCountInScene++;
}
}
currentTime = spawnInterval;
}
}
通过一个属性来判断是哪一种类型的道具
public enum PropsType
{
None,
MissileProp, //炮弹
LandmineProp, //地雷
CloakProp,
HealthBottleProp, //血瓶