void OnValidate() { if (movableItem == null || movableItem.gameObject != gameObject) { movableItem = GetComponent <MovableItem>(); } }
void Start() { if (movableItem == null) { movableItem = GetComponent <MovableItem>(); } }
void GrabMovableItem(MovableItem item) { // todo: grab the object // best way would be to add the functionality into holdable item // attach a fixed joint (or maybe a loose joint with the object hanging around?) // anyway, what is }
void Start() { if (movableItem == null) { movableItem = GetComponent <MovableItem>(); } if (space == null) { space = transform; } }
void OnValidate() { if (movableItem == null || movableItem.gameObject != gameObject) { movableItem = GetComponent <MovableItem>(); } if (space == null) { space = transform; } }
public void StopVehicle() { if (AppManager.Instance.SelectedItem != null) { MovableItem selectedItem = AppManager.Instance.SelectedItem.GetComponent <MovableItem>(); if (selectedItem != null) { selectedItem.Stop(); } } }
void OnValidate() { if (movableItem == null || movableItem.gameObject != gameObject) { movableItem = GetComponent <MovableItem>(); } if (!selectableTypes.Contains(parameterType)) { parameterType = selectableTypes[0]; } if (space == null) { space = transform; } }
public void PickeupMovable(MovableItem item) { if (_heldItem != null || !item.CanPlace) { return; } _heldItem = item; _heldItem.transform.SetParent(_cachedTransform); SetHeldItemBehaviorsDisabled(true); _dropTimer = _timeToDrop; //Play audio for picking up item GameObject.Find("Main Camera").GetComponent <SoundManager>().pickUpSource.PlayOneShot(GameObject.Find("Main Camera").GetComponent <SoundManager>().pickUpClip, 0.5f); }
private void Update() { if (_heldItem == null) { return; } _dropTimer -= Time.deltaTime; if (_dropTimer <= 0) { // Reparent to scene root SetHeldItemBehaviorsDisabled(false); _heldItem.transform.SetParent(null); _heldItem = null; } }
public bool TryPlaceMovable(MovableItem movableItem) { if (IsAtCapacity()) { return(false); } _placedMovables.Add(movableItem); PlaceMovable(movableItem); if (IsAtCapacity()) { HandleReachedCapacity(); OnReachedCapacity?.Invoke(); } return(true); }
private MovableItem GetClosestItem(IntVector position) { var closestDistance = double.PositiveInfinity; MovableItem closestItem = null; foreach (var item in ApplicationViewModel.World.Items) { var itemPosition = item.Bounds.Center - position; var itemDistance = itemPosition.X * itemPosition.X + itemPosition.Y * itemPosition.Y; if (itemDistance <= Math.Pow(Player.ItemPickupRange, 2) && itemDistance < closestDistance) { closestDistance = itemDistance; closestItem = item; } } return(closestItem); }
public void PlaceMovable(TargetObject targetObject) { if (_heldItem == null) { return; } if (_movableTargetPairs.IsMatch(_heldItem.MovableType, targetObject.TargetType)) { var placedMovable = targetObject.TryPlaceMovable(_heldItem); if (placedMovable) { _heldItem.Place(); _heldItem = null; //Play audio for putting down item GameObject.Find("Main Camera").GetComponent <SoundManager>().pickUpSource.PlayOneShot(GameObject.Find("Main Camera").GetComponent <SoundManager>().putDownClip, 0.5f); } } }
bool Collisions(Vector3Int direction) { Vector3Int newPosition = new Vector3Int((int)transform.position.x, (int)transform.position.y, (int)transform.position.z) + direction; Tile tileToMoveTo = Level.GetTileAt(newPosition.x, newPosition.y); if (tileToMoveTo.Type == TileType.WALL) { return(true); } else if (tileToMoveTo.itemOnTop != null) { switch (tileToMoveTo.itemOnTop.tag) { case "MovableItem": MovableItem item = tileToMoveTo.itemOnTop.GetComponent <MovableItem>(); // You add direction again because this is what the item will be moving to. Basically checking your position + 2 if (item.CanMoveItem(newPosition + direction)) { // If you can move the item that direction then move it and move character item.MoveItem(newPosition + direction); } else { // If you can't move the item that direction then don't do anything return(true); } break; case "CollectibleItem": CollectibleItem collectible = tileToMoveTo.itemOnTop.GetComponent <CollectibleItem>(); collectible.CollectItem(); break; } } return(false); }
public IHttpActionResult PostMoveItem([FromBody] MovableItem item) { if (!ModelState.IsValid) { return(BadRequest("Invalid data.")); } GeocachesEntities db = new GeocachesEntities(); // Users can identify an item either by its id or its name. Both options, however, cannot be null if (item.id == null && item.name == null) { return(BadRequest("Both item id and name cannot be null.")); } // We will use this query later, so save it. We are checking if there any items that match the name or id var query = db.Items.Where(i => (i.id == item.id || i.name.Equals(item.name))); if (!query.Any()) { return(BadRequest("Both item id and name are invalid.")); } if (query.Count() > 1) { return(BadRequest("Entered an item id and name that do not match to the same item.")); } // Active items don't have an end time if (!query.Where(i => i.end_time == null).Any()) { return(BadRequest("Only active items can be moved.")); } // We want to check that there is an existing geocache matching either the name or id given // Both the geocache name and id cannot be null, otherwise we cannot add it to any geocache if (item.geocacheName == null && item.geocacheID == null) { return(BadRequest("Both geocache name and geocache id cannot be null.")); } // Get a guid that either matches to geocache ID or geocache name var guidQuery = db.Geocaches.Where(g => (g.id == item.geocacheID || g.name.Equals(item.geocacheName))).Select(g => g.id); if (guidQuery.Count() > 1) { return(BadRequest("Entered a geocache id and geocache name that do not match to same geoecache.")); } Guid guid = guidQuery.FirstOrDefault(); if (guid == Guid.Empty) { return(BadRequest("Both geocache name and geocache id are not valid.")); } // Check how many items are in the specific geocache. If it is more than 3, then we cannot // add any more items if (db.Items.Where(i => i.geocache_id == guid).Count() >= 3) { return(BadRequest("Cannot move item to desired geocache because there are already 3+ items in there.")); } // There should only be a single result anyways bc both the id and the name must be unique var result = query.Single(); result.geocache_id = guid; db.SaveChanges(); db.Dispose(); return(Ok()); }
void Reset() { movableItem = GetComponent <MovableItem>(); }
private void PlaceMovable(MovableItem movableItem) { var slot = Random.Range(0, _movableLocators.Length); movableItem.transform.SetParent(_movableLocators[slot], false); }
private void HandleMovableFound(MovableItem movable) { _mover.PickeupMovable(movable); }
void ReleaseMovableItem(MovableItem item) { }