Exemple #1
0
    public void ThrowBag()
    {
        if (CS.GetDonePaning())
        {
            Vector3 mousePos = Input.mousePosition;
            mousePos = new Vector3(mousePos.x, mousePos.y, 1);
            Vector3 objectPos = Camera.main.ScreenToWorldPoint(mousePos);
            Vector2 direction;
            PS.Play();

            direction = objectPos - bagTempPos;
            direction.Normalize();
            BS = BagState.flying;
            DecideThrowStrenght(objectPos, bagTempPos);
            bagRB.gravityScale    = 1;
            bagRB.velocity        = direction * throwPower * throwStrenght;
            BagCollider.isTrigger = false;
        }
    }
Exemple #2
0
    public void SetBagState(BagState state)
    {
        m_BagState = state;

        ShowFail(false);

        switch (m_BagState)
        {
        case BagState.Locked:
            m_UnlockResult.SetActive(false);
            break;

        case BagState.Unlocked:
            m_UnlockResult.SetActive(true);
            m_UnlockResultMessage.text = c_MessYes;
            break;

        case BagState.Blocked:
            m_UnlockResult.SetActive(true);
            m_UnlockResultMessage.text = c_MessNo;
            break;
        }
    }
Exemple #3
0
    void Awake()
    {
        extraThrow            = false;
        throwExtraOnce        = true;
        startScale            = transform.localScale.x;
        hasTakenPosInput      = false;
        BagCollider           = GetComponent <BoxCollider2D>();
        BagCollider.isTrigger = true;
        GM     = GameObject.Find("GameManager").GetComponent <scr_GameManager>();
        CS     = Camera.main.GetComponent <scr_CameraScript>();
        PS     = GetComponent <ParticleSystem>();
        PSGold = GameObject.Find("goldPickup").GetComponent <ParticleSystem>();


        if (GameObject.Find("BagBoundaries").GetComponent <BoxCollider2D>() != null)
        {
            bagThrowBoundaries = GameObject.Find("BagBoundaries").GetComponent <BoxCollider2D>();
        }
        else
        {
            Debug.LogError("BagBoundaries need BoxCollider2D");
        }
        aimingArrow = GameObject.FindGameObjectWithTag("aimarrow");
        aimingArrow.SetActive(false);
        BS                = BagState.idle;
        bag               = this.gameObject;
        bagRB             = bag.GetComponent <Rigidbody2D>();
        bagRB.isKinematic = true;
        SP                = gameObject.GetComponent <spawnParticles>();
        PS.Stop();
        PSGold.Stop();

        bagMaterial            = bag.GetComponent <BoxCollider2D>().sharedMaterial;
        bagMaterial.bounciness = bouncePower;
        remainingBounces       = bounces;
        ISG = GameObject.Find("GameManager").GetComponent <scr_IngameSoundManager>();
    }
Exemple #4
0
    void InputManager()
    {
        if (isThrown == false)
        {
            if (Input.GetMouseButtonDown(0))
            {
                bagTempPos         = bag.transform.position;
                bagRB.gravityScale = 0;
                aimingArrow.SetActive(true);
                hasTakenPosInput = true;
            }
            if (Input.GetMouseButton(0) && hasTakenPosInput == true)
            {
                bag.transform.position = bagTempPos;
                Vector3 mousePos = Input.mousePosition;
                mousePos.z = 5.23f;

                Vector3 objectPos = Camera.main.WorldToScreenPoint(transform.position);
                mousePos.x = mousePos.x - objectPos.x;
                mousePos.y = mousePos.y - objectPos.y;
                float angle = Mathf.Atan2(mousePos.y, mousePos.x) * Mathf.Rad2Deg;
                transform.rotation = Quaternion.Euler(new Vector3(0, 0, angle));
                BS = BagState.flying;
            }
            if (Input.GetMouseButtonUp(0) && hasTakenPosInput == true)
            {
                ThrowBag();
                aimingArrow.SetActive(false);
                bagRB.gravityScale = 1;
                isThrown           = true;
                ISG.PlayBagShootSound();
                CS.SetCameraOrtographicSize(8.0f);
                CS.SetCameraRestriction(false, true);
                hasTakenPosInput = false;
            }
        }
    }
Exemple #5
0
 public void SetBagState(BagState state)
 {
     BS = state;
 }