//применяем подобранный бонус //в зависимости от типа, передаем одну из подсистем корабля, к которым применяется бонус public void ApplyBonus(IPickable <IShipSystem> bonus) { if (bonus is HealthBonus) { bonus.PickUp(base.SpaceshipSystems.HealthSystem as PlayerHealthSystem); } else if (bonus is WeaponBonus) { bonus.PickUp(base.SpaceshipSystems.WeaponSystem as PlayerWeaponSystem); } }
// TODO refactor void tryPickUpObject() { Collider2D[] collidersInRange = Physics2D.OverlapCircleAll(transform.position, 1); foreach (Collider2D col in collidersInRange) { IPickable pickable = col.GetComponent <IPickable>(); if (pickable != null) { Coin coin; if (col.TryGetComponent <Coin>(out coin)) { coin.PickUp(); pocketCoins += 1; return; } var item = pickable.PickUp(); if (item != null) { item.parent = transform; item.localPosition = new Vector3(0, 1f); _heldItem = item; return; } } } }
private void OnTriggerStay(Collider other) { // cannot bring more than one box if (Pickable != null || IsDisabled) { return; } if (Input.GetButtonDown(("PickupDeploy") + PlayerNumber)) { IPickable otherPickable = other.GetComponent <IPickable>(); // it is not a pickable object if (otherPickable == null) { return; } // pickable object has already been picked up if (otherPickable.IsPickedUp) { return; } // caching pickable object Pickable = otherPickable; Pickable.PickUp(this); skipInputCall = true; } }
private void OnTriggerEnter2D(Collider2D collision) { IPickable item = collision.gameObject.GetComponent <IPickable>(); if (item != null) { item.PickUp(character); } }
public void PickUpItem(Path path) { Tile t = path.GetCurrentTile(); IPickable item = t.GetPickable(); if (item != null) { item.PickUp(this); } }
private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.layer == projectileLayer) { Die(); return; } IPickable pickable = collision.gameObject.GetComponent <IPickable>(); pickable?.PickUp(); }
private void OnTriggerEnter(Collider other) { _pickable = other.GetComponent <IPickable>(); if (_pickable != null) { _pickable.PickUp(); if (other.tag == "Bonus") { TasksManager.Instance.CheckTasks(TasksTypes.CollectBonus); } } }
private void GrabPickable() { Ray ray = _myCam.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, 1000f)) { _currentPickable = GetPickableFromCollider(hit.collider); if (_currentPickable != null) { _currentPickable.PickUp(); Main.instance.eventManager.TriggerEvent(GameEvent.OnGrabPickable); } } }
/// <summary> /// Called from Controller, if target available proceed. /// </summary> internal void PickUp() { if (m_target == null || m_upgradeableTarget == null) { return; } if (Upgrade) { m_upgradeableTarget?.Upgrade(); } else { m_target?.PickUp(m_weapon); } m_target = null; m_upgradeableTarget = null; m_photonView.RPC("ChangeStateRPC", RpcTarget.All, false); PickedWeapon?.Invoke(); }
public void Visit(IPickable pickable) { pickable.PickUp(); }