Example #1
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.GetPositionY();
            int sizeX = (int)parentItem.GetSize().x;
            int sizeY = (int)parentItem.GetSize().y;

            pos.x = Random.Range(posX, posX + sizeX);
            pos.y = Random.Range(posZ, posZ + sizeY);
        }

        this.Walker.WalkToPosition(pos);
        this.Walker.OnFinishWalk += this.WalkRandomLoop;
    }
Example #2
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.GetPositionY();
            int sizeX = (int)_randomWalkParentItem.GetSize().x;
            int sizeY = (int)_randomWalkParentItem.GetSize().y;

            pos.x = Random.Range(posX, posX + sizeX);
            pos.y = Random.Range(posZ, posZ + sizeY);
        }

        this.Walker.WalkToPosition(pos);
        this.Walker.OnFinishWalk += this.WalkRandomLoop;
    }
Example #3
0
 public void UpdateItemData(BaseItemScript item)
 {
     this._gameData.sceneData.AddOrUpdateItem(item.instanceId, item.itemData.id, item.GetPositionX(), item.GetPositionY());
     this.SaveDataBase();
 }