本文整理汇总了C#中Tile.SetObject方法的典型用法代码示例。如果您正苦于以下问题:C# Tile.SetObject方法的具体用法?C# Tile.SetObject怎么用?C# Tile.SetObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tile
的用法示例。
在下文中一共展示了Tile.SetObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetDestinationTile
bool SetDestinationTile()
{
if (nextTile != null && currentTile != nextTile)
{
currentTile.ReserveNode(false, false);
currentTile.SetObject(null);
currentTile = nextTile;
currentTile.SetObject(this.gameObject);
moving = true;
endPos = nextTile.GetNodePos();
return true;
}
return false;
}
示例2: Update
// Update is called once per frame
void Update()
{
if (currentTile == null)
{
// Find nearest x increment in .5s and y increment in 1s
Vector3 pos = transform.position;
float x = Mathf.Floor(pos.x*2f + 0.5f) / 2f;
if( x % 1 != 0.5f ) {
//x = ( x < pos.x ) ? x + .5f : x - .5f;
}
float z = Mathf.Round(pos.z);
currentTile = tileManager.GetTileAtPosition(new Vector3(x, 0.5f, z));
if(currentTile != null)
{
currentTile.SetObject(this.gameObject);
currentTile.ReserveNode(true, true);
transform.position = currentTile.GetNodePos();
}
}
if(moving)
{
if( !myAudioSource.isPlaying )
audio.Play();
transform.position = Vector3.MoveTowards(transform.position, endPos, Time.deltaTime * pushSpeed);
if(transform.position == endPos)
{
currentTile.SetObject(this.gameObject);
moving = false;
}
}
}