private IEnumerator _WalkRandomLoop() { yield return(new WaitForSeconds(3)); Vector3 pos = Vector3.zero; if (_randomWalkParentItem == null) { Vector3 randomFreePosition = GroundManager.instance.GetRandomFreePosition(); pos = randomFreePosition; } else { int posX = _randomWalkParentItem.GetPositionX(); int posZ = _randomWalkParentItem.GetPositionZ(); int sizeX = (int)_randomWalkParentItem.GetSize().x; int sizeZ = (int)_randomWalkParentItem.GetSize().z; pos.x = Random.Range(posX, posX + sizeX); pos.z = Random.Range(posZ, posZ + sizeZ); } this.Walker.WalkToPosition(pos); this.Walker.OnFinishWalk += this.WalkRandomLoop; }
public void WalkRandom(BaseItemScript parentItem) { if (!this.itemData.configuration.isCharacter) { return; } this._randomWalkParentItem = parentItem; Vector3 pos = Vector3.zero; if (parentItem == null) { Vector3 randomFreePosition = GroundManager.instance.GetRandomFreePosition(); pos = randomFreePosition; } else { int posX = parentItem.GetPositionX(); int posZ = parentItem.GetPositionZ(); int sizeX = (int)parentItem.GetSize().x; int sizeZ = (int)parentItem.GetSize().z; pos.x = Random.Range(posX, posX + sizeX); pos.z = Random.Range(posZ, posZ + sizeZ); } this.Walker.WalkToPosition(pos); this.Walker.OnFinishWalk += this.WalkRandomLoop; }
public void UpdateItemData(BaseItemScript item) { this._gameData.sceneData.AddOrUpdateItem(item.instanceId, item.itemData.id, item.GetPositionX(), item.GetPositionZ()); this.SaveDataBase(); }