本文整理汇总了C#中Bullet.updatePosition方法的典型用法代码示例。如果您正苦于以下问题:C# Bullet.updatePosition方法的具体用法?C# Bullet.updatePosition怎么用?C# Bullet.updatePosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bullet
的用法示例。
在下文中一共展示了Bullet.updatePosition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: onBulletSpawn
private void onBulletSpawn(Packet<IScenePeer> packet)
{
Debug.Log("receiving bullet");
var reader = new BinaryReader(packet.Stream);
var id = reader.ReadInt64();
var pid = reader.ReadInt64();
var x = reader.ReadSingle();
var y = reader.ReadSingle();
var vx = reader.ReadSingle();
var vy = reader.ReadSingle();
Debug.Log(id + " | " + pid + " | " + x + " | " + y + " | " + vx + " | " + vy);
if (_players.ContainsKey(pid) == true && _bullets.ContainsKey(id) == false)
{
Debug.Log("new bullet received");
StormancerActionHandler.Post(() =>
{
Player temp = _players[pid];
GameObject bulletGO = Instantiate(bulletToSpawn);
bulletGO.GetComponent<Renderer>().material.color = temp.ship.GetComponent<Renderer>().material.color;
bulletGO.GetComponentInChildren<Light>().color = bulletGO.GetComponent<Renderer>().material.color;
Bullet bullet = new Bullet(id, temp, client.Clock, bulletGO);
bullet.updatePosition(x, y, vx, vy, client.Clock);
_bullets.TryAdd(id, bullet);
});
}
else if (pid == localPlayer.id && _bullets.ContainsKey(id) == false)
{
Debug.Log("new bullet received");
StormancerActionHandler.Post(() =>
{
Player temp = localPlayer;
GameObject bulletGO = Instantiate(bulletToSpawn);
bulletGO.GetComponent<Renderer>().material.color = temp.ship.GetComponent<Renderer>().material.color;
bulletGO.GetComponentInChildren<Light>().color = bulletGO.GetComponent<Renderer>().material.color;
Bullet bullet = new Bullet(id, temp, client.Clock, bulletGO);
bullet.updatePosition(x, y, vx, vy, client.Clock);
_bullets.TryAdd(id, bullet);
});
}
}