Example #1
0
        private void CompletePlacement(bool wasPlaced)
        {
            if (OnPlacementComplete != null)
            {
                OnPlacementComplete(wasPlaced ? _toPlaceInventoryId : 0);
            }

            _toPlaceInventoryId = 0;
            Destroy(_toPlaceGo);
            _toPlaceGo             = null;
            _toPlaceableScriptable = null;
            enabled = false;
        }
Example #2
0
        public void BindToScriptable(PlaceableScriptable scriptable)
        {
            _scriptable  = scriptable;
            Layer        = scriptable.Layer;
            _baseProduct = ProductLookup.Instance.GetProduct(scriptable.ProductName);

            gameObject.TrimCloneFromName();
            var rend = this.gameObject.AddComponent <SpriteRenderer>();

            rend.sprite           = scriptable.PlacedSprite;
            rend.sortingLayerName = Layer.ToString();
            rend.sortingOrder     = 1;
        }
Example #3
0
        public void BeginPlacement(string placeableName, int inventoryId)
        {
            var placeable = _lookup.Placeables.FirstOrDefault(i => i.ProductName == placeableName);

            if (placeable == null)
            {
                throw new UnityException(string.Format("Placer asked to place {0}: Has no entry in PlaceablesLookup", placeableName));
            }

            _toPlaceInventoryId    = inventoryId;
            _toPlaceableScriptable = placeable;
            var go   = new GameObject();
            var rend = go.AddComponent <SpriteRenderer>();

            rend.sprite           = placeable.PlacedSprite;
            rend.sortingLayerName = placeable.Layer.ToString();
            rend.sortingOrder     = 1;
            _toPlaceGo            = go;

            enabled = true;
        }