//применяем подобранный бонус
 //в зависимости от типа, передаем одну из подсистем корабля, к которым применяется бонус
 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;
                }
            }
        }
    }
示例#3
0
    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;
        }
    }
示例#4
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        IPickable item = collision.gameObject.GetComponent <IPickable>();

        if (item != null)
        {
            item.PickUp(character);
        }
    }
示例#5
0
    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();
    }
示例#7
0
    private void OnTriggerEnter(Collider other)
    {
        _pickable = other.GetComponent <IPickable>();

        if (_pickable != null)
        {
            _pickable.PickUp();

            if (other.tag == "Bonus")
            {
                TasksManager.Instance.CheckTasks(TasksTypes.CollectBonus);
            }
        }
    }
示例#8
0
    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);
            }
        }
    }
示例#9
0
        /// <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();
        }
示例#10
0
 public void Visit(IPickable pickable)
 {
     pickable.PickUp();
 }