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

        if (item != null)
        {
            item.PickUp(character);
        }
    }
Exemplo n.º 5
0
    public void PickUpItem(Path path)
    {
        Tile      t    = path.GetCurrentTile();
        IPickable item = t.GetPickable();

        if (item != null)
        {
            item.PickUp(this);
        }
    }
Exemplo n.º 6
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.layer == projectileLayer)
        {
            Die();
            return;
        }
        IPickable pickable = collision.gameObject.GetComponent <IPickable>();

        pickable?.PickUp();
    }
Exemplo n.º 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);
            }
        }
    }
Exemplo n.º 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);
            }
        }
    }
Exemplo n.º 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();
        }
Exemplo n.º 10
0
 public void Visit(IPickable pickable)
 {
     pickable.PickUp();
 }