예제 #1
0
    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;
    }
예제 #2
0
    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;
    }
예제 #3
0
 public void UpdateItemData(BaseItemScript item)
 {
     this._gameData.sceneData.AddOrUpdateItem(item.instanceId, item.itemData.id, item.GetPositionX(), item.GetPositionZ());
     this.SaveDataBase();
 }