Exemplo n.º 1
0
    // PUBLIC METHODS
    // -------------------------------------------------------------------------

    public bool Pickup(Types.PickupType pickupPickupType, GameObject pickupObject)
    {
        if (m_pickedUp != null)
        {
            return(false);
        }

        m_pickedUpType = pickupPickupType;

        switch (pickupPickupType)
        {
        case Types.PickupType.WOOD:
            m_pickedUp = pickupObject;
            m_pickedUp.transform.parent        = transform;
            m_pickedUp.transform.localPosition = new Vector3(0, 1f, 0);
            m_pickedUp.transform.rotation      = Quaternion.identity;
            m_pickedUp.GetComponent <Rigidbody2D>().bodyType = RigidbodyType2D.Kinematic;
            m_pickedUp.GetComponent <Collider2D>().enabled   = false;
            break;

        case Types.PickupType.AXE:
            m_pickedUp = pickupObject;
            m_pickedUp.SetActive(false);
            break;
        }

        return(true);
    }
Exemplo n.º 2
0
    public void OnCannotWalk()
    {
        m_isDrowning = true;

        if (m_pickedUp == null || m_pickedUpType == Types.PickupType.AXE)
        {
            return;
        }

        Vector3 throwForce = m_throwForce;

        if (!m_isFacingRight)
        {
            throwForce.x *= -1f;
        }

        m_pickedUp.transform.parent = transform.parent;
        m_pickedUp.GetComponent <Collider2D>().enabled = true;
        Rigidbody2D pickedUpRigidBody = m_pickedUp.GetComponent <Rigidbody2D>();

        pickedUpRigidBody.bodyType = RigidbodyType2D.Dynamic;
        pickedUpRigidBody.AddForce(throwForce);

        m_pickedUp     = null;
        m_pickedUpType = Types.PickupType.NONE;
    }
Exemplo n.º 3
0
    public void OnThrowAttack()
    {
        if (m_pickedUp == null || m_pickedUpType == Types.PickupType.AXE)
        {
            m_weapon.Attack();
            GameController.instance.PlayAttackTree();
            return;
        }

        Vector3 throwForce = m_throwForce;

        if (Random.value < m_chanceOfShowOffAfterThrow)
        {
            m_shouldShowOff = true;
            throwForce      = Vector2.up * m_throwForce.magnitude;
            GameController.instance.PlayShowOff();
        }

        if (!m_isFacingRight)
        {
            throwForce.x *= -1f;
        }

        m_pickedUp.transform.parent = transform.parent;
        m_pickedUp.GetComponent <Collider2D>().enabled = true;
        Rigidbody2D pickedUpRigidBody = m_pickedUp.GetComponent <Rigidbody2D>();

        pickedUpRigidBody.bodyType = RigidbodyType2D.Dynamic;
        pickedUpRigidBody.AddForce(throwForce);

        m_pickedUp     = null;
        m_pickedUpType = Types.PickupType.NONE;

        GameController.instance.PlayThrow();
    }