示例#1
0
        public static IEnumerable <IDomainEvent> Handle(InventoryItemStockData d, Placed <CheckInItems> e)
        {
            if (string.IsNullOrEmpty(d.Sku))
            {
                throw new EventualConsistencyException <InventoryItemCreated>();
            }

            if (!d.IsActive)
            {
                return new[] { new InventoryItemActionInvalid {
                                   Action = "CheckIn", Id = e.Command.Id, Reason = "ItemInActive"
                               } }
            }
            ;

            if (d.Count > d.OverStockLimit)
            {
                return new[] { new InventoryItemActionInvalid {
                                   Action = "CheckIn", Id = e.Command.Id, Reason = "OverStocked"
                               } }
            }
            ;

            return(new[] { new ItemsCheckedInToInventory {
                               Id = e.Command.Id, Count = e.Command.Count
                           } });
        }
示例#2
0
文件: MapView.cs 项目: k-t/SharpHaven
        protected override void OnMouseButtonDown(MouseButtonEvent e)
        {
            if (Session == null)
            {
                return;
            }

            camera.OnMouseButtonDown(e);
            if (e.Handled)
            {
                return;
            }

            var sc  = ToAbsolute(e.Position);
            var mc  = Geometry.ScreenToMap(sc);
            var gob = Session.Scene.GetObjectAt(sc);

            if (placeGob != null)
            {
                Placed.Raise(new MapPlaceEvent(e, placeGob.Position));
                Session.Objects.RemoveLocal(placeGob);
                placeGob = null;
            }
            else
            {
                MapClick.Raise(new MapClickEvent(e, mc, e.Position, gob));
            }
            e.Handled = true;
        }
示例#3
0
        public static IEnumerable <IDomainEvent> Handle(InventoryItemStockData d, Placed <RemoveInventoryItems> e)
        {
            if (string.IsNullOrEmpty(d.Sku))
            {
                throw new EventualConsistencyException <InventoryItemCreated>();
            }

            if (!d.IsActive)
            {
                return new[] { new InventoryItemActionInvalid {
                                   Action = "CheckOut", Id = e.Command.Id, Reason = "ItemInActive"
                               } }
            }
            ;

            if (d.Count < e.Command.Count)
            {
                return new[] { new InventoryItemActionInvalid {
                                   Action = "CheckOut", Id = e.Command.Id, Reason = "BelowZeroStock"
                               } }
            }
            ;

            return(new[] { new ItemsRemovedFromInventory {
                               Id = e.Command.Id, Count = e.Command.Count
                           } });
        }
示例#4
0
 public void OnBreak()
 {
     if (destroyedClip != null)
     {
         audioSourceMultichannel.GetChannel().PlayOneShot(destroyedClip);
     }
     isPlaced = true;
     Placed?.Invoke(false, transform.position);
     rigidbody2D.mass        = 10;
     snapOpen                = false;
     sprite.enabled          = false;
     breakingSprite.enabled  = false;
     brokenSprite.enabled    = true;
     highlightSprite.enabled = false;
     isHeld = false;
     placedTrigger.active         = false;
     placedTrigger.pickableObject = null;
     placedTrigger.canBePlaced    = false;
     brokeEffect.SetActive(true);
     brokeEffect.GetComponent <ParticleSystem>().Play();
     health = 0;
     Fallen?.Invoke();
     Broken?.Invoke();
     pickableTrigger.enabled = false;
     StartCoroutine(FadingOutBroken());
 }
示例#5
0
 public void Left()
 {
     isHeld = false;
     highlightSprite.enabled = false;
     if (placedTrigger.canBePlaced)
     {
         rigidbody2D.constraints |= RigidbodyConstraints2D.FreezeAll;
         //rigidbody2D.mass = 10000;
         transform.position = placedTrigger.whereToPlace.position;
         placedTrigger.pickableObject.snapOpen = false;
         placedOn = placedTrigger.pickableObject;
         isPlaced = true;
         if (placedClip != null)
         {
             audioSourceMultichannel.GetChannel().PlayOneShot(placedClip);
         }
         //placedTrigger.whereToPlaceHightlight.SetActive(false);
         Placed?.Invoke(true, transform.position);
     }
     else
     {
         pickableTrigger.enabled = false;
         rigidbody2D.AddForce((currentPosition - previousPosition) * 300f, ForceMode2D.Impulse);
     }
 }
示例#6
0
        public static IEnumerable <IDomainEvent> Handle(InventoryItemStockData d, Placed <CreateInventoryItem> e)
        {
            if (d.Sku?.Equals(e.Command.Id) == true)
            {
                return new[] { new JustSpinningMyWheels() }
            }
            ;

            return(new[] { new InventoryItemCreated {
                               Id = e.Command.Id
                           } });
        }
        private void OnClicked(PlaceArgs args)
        {
            OnInputClose();

            var grid = fieldContainer.Field.Grid;
            var cell = grid.GetGridObject(args.Position);

            if (cell.IsEmpty)
            {
                var buildingPosition = grid.GetCellCenter(cell.X, cell.Y);

                Placed?.Invoke(new PlaceArgs(args.Building, buildingPosition));
            }
        }
示例#8
0
        public void InstantiateModel(Vector3 position, Quaternion rotation)
        {
            GameObject model = Instantiate(ModelPrefab, position, rotation);

            if (RotateModelToCamera)
            {
                model.transform.LookAt(new Vector3(
                                           camera.transform.position.x,
                                           model.transform.position.y,
                                           camera.transform.position.z));
            }

            Placed?.Invoke(model);
        }
示例#9
0
    private void PlaceVariant(BuildingVariant variant, Vector3 pos, Quaternion rot, float xWall, float zWall)
    {
        //to place a building variant first thing that needs to happen is
        //calc of the elevation to which the building foundation will extend
        //which is the highest place within the building area + foundation height
        Vector3    castOrigin = pos.SwapY(buildingsGen.MaxHeight);
        Vector3    halfEx     = new Vector3(xWall * 0.5f, 1f, zWall * 0.5f);
        LayerMask  mask       = Layers.GetMask(Layer.CityBlockTerrain);
        RaycastHit hit;
        float      foundationElev = pos.y;

        if (Physics.BoxCast(castOrigin, halfEx, Vector3.down, out hit, rot, buildingsGen.MaxHeight * 2, mask))
        {
            foundationElev = hit.point.y;
        }
        foundationElev += variant.FoundationHeight;
        float   foundationBottom     = foundationElev - 20;
        float   foundationYSpan      = foundationElev - foundationBottom;
        Vector3 foundationDimentions = new Vector3(xWall, foundationYSpan, zWall);
        Mesh    foundationMesh       = MeshGenerator.GenerateBox(foundationDimentions * 0.5f);

        Vector3    foundationPos  = pos.SwapY(foundationElev - 0.5f * foundationYSpan);
        MeshFilter instFoundation = Instantiate(variant.PrefabFoundation, foundationPos, rot);

        instFoundation.mesh = foundationMesh;
        BoxCollider col = instFoundation.gameObject.AddComponent <BoxCollider>();

        col.size = foundationDimentions;

        Vector2 pos2D          = pos.UnShiftToV2();
        int     storiesMin     = Mathf.Max(variant.StoriesMin, Mathf.FloorToInt(GetHeightMin(pos2D) / variant.StoryHeight));
        int     storiesMax     = Mathf.Min(variant.StoriesMax, Mathf.CeilToInt(GetHeightMax(pos2D) / variant.StoryHeight));
        float   bodyHeight     = Random.Range(storiesMin, storiesMax + 1) * variant.StoryHeight;
        Vector3 bodyDimentions = new Vector3(xWall, bodyHeight, zWall);
        Mesh    bodyMesh       = MeshGenerator.GenerateBox(bodyDimentions * 0.5f);

        Vector3    bodyPosition = pos.SwapY(foundationElev + bodyHeight * 0.5f);
        MeshFilter instBody     = Instantiate(variant.PrefabBody, bodyPosition, rot);

        instBody.mesh = bodyMesh;
        Building newlyPlaced = instBody.gameObject.AddComponent <Building>();

        col      = instBody.gameObject.AddComponent <BoxCollider>();
        col.size = bodyDimentions;

        instFoundation.transform.parent = newlyPlaced.transform;
        Placed.Add(newlyPlaced);
    }
示例#10
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Id.Length != 0)
            {
                hash ^= Id.GetHashCode();
            }
            if (TimesEncountered != 0)
            {
                hash ^= TimesEncountered.GetHashCode();
            }
            if (TimesReturned != 0)
            {
                hash ^= TimesReturned.GetHashCode();
            }
            if (FirstTimeRewardsCollected != false)
            {
                hash ^= FirstTimeRewardsCollected.GetHashCode();
            }
            if (FoundLocation.Length != 0)
            {
                hash ^= FoundLocation.GetHashCode();
            }
            if (FoundTime != 0L)
            {
                hash ^= FoundTime.GetHashCode();
            }
            if (Placed != false)
            {
                hash ^= Placed.GetHashCode();
            }
            if (CurrentReturned != 0)
            {
                hash ^= CurrentReturned.GetHashCode();
            }
            if (Shards != 0)
            {
                hash ^= Shards.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
示例#11
0
        public static IEnumerable <IDomainEvent> Handle(InventoryItemStockData d, Placed <DeactivateInventoryItem> e)
        {
            if (string.IsNullOrEmpty(d.Sku))
            {
                throw new EventualConsistencyException <InventoryItemCreated>();
            }

            if (!d.IsActive)
            {
                return new[] { new JustSpinningMyWheels() }
            }
            ;

            return(new[] { new InventoryItemDeactivated {
                               Id = e.Command.Id
                           } });
        }
示例#12
0
        private static IEnumerable <IDomainEvent> Handle(RefundProductOrderData d, Placed <RefundProductOrder> e)
        {
            if (d.Product == null)
            {
                throw new EventualConsistencyException <ProductOnSale>();
            }

            if (d.Policy == null)
            {
                throw new EventualConsistencyException <PolicyInPlace>();
            }

            if (d.Customer?.CustomerMarkedAsFraud ?? false)
            {
                return new[] { new RefundRejected {
                                   OrderId = d.OrderId
                               } }
            }
            ;

            if (e.When.Value > d.Product.WhenSaleExpires)
            {
                return new[] { new RefundRejected {
                                   OrderId = d.OrderId
                               } }
            }
            ;

            if (e.When.Value.Subtract(d.Order.WhenOrderPlaced.Value).TotalDays > d.Policy.CoolingOffPeriodInDays.Value)
            {
                return new[] { new RefundRejected {
                                   OrderId = d.OrderId
                               } }
            }
            ;

            return(new[] { new RefundApproved {
                               OrderId = d.OrderId
                           } });
        }
    }
示例#13
0
 public void Place()
 {
     //MessageBox.Show("Loď umístěna!");
     Placed?.Invoke();
 }
示例#14
0
 public PlacedAll(Placed p)
 {
     Id = p.Id;
     Fixed = p.Fixed;
     Ordinal = p.Ordinal;
     Place = p.Place;
     Code = p.Code;
     Number = p.Number;
     Time = p.Time;
     State = p.State;
     StateTime = p.StateTime;
     OId = p.OId;
     Amount = p.Amount;
 }
示例#15
0
 public void Place()
 {
     Placed?.Invoke(this);
 }