Esempio n. 1
0
    void OnCollisionEnter(Collision col)
    {
        Debug.Log("Ungli " + col.gameObject.name);
        Physics.gravity     = new Vector3(0, -9.81f, 0);
        this.rb.constraints = RigidbodyConstraints.None;
        this.RotateDown     = false;
        this.RotateUp       = false;
        if (col.gameObject.tag.Equals("Environment"))
        {
            this.OnBasket = false;
            if (this.mode.Equals(GameplayMode.StaticDump))
            {
                Invoke("Restore", this.RestoreWait);
                return;
            }
            this.bottleState = BottleStates.Dead;
            this.GameOver();
            this.enabled = false;
        }
        else if (col.gameObject.tag.Equals("Target"))
        {
            Invoke("MoveEnvironment", 0.5f);
            if (col.gameObject.name != "SpawnPoint")
            {
                //this.rb.velocity = Vector3.zero;
            }
            this.OnBasket = false;
            this.PlatForm = col.transform.root.gameObject;
            //if (this.PlatForm.GetComponent<HurdleSpawner>())
            //{
            //    this.PlatForm.GetComponent<HurdleSpawner>().ExtendCollider();
            //}
            this.PlatformOriginalScale = new Vector3(1, 1, 1);
            if (this.PlatForm.gameObject.name != this.CurrentPlatformName)
            {
                //if (col.gameObject.GetComponentInChildren<TargetTest>())
                //{
                this.CoveredDistance += this.GetComponentInChildren <TargetTest>().Distance;
                if (col.gameObject.name != "SpawnPoint")
                {
                    Invoke("RegisterFlip", 0.7f);
                }
                //}
                this.manager.SpawnNextHurdle(this.PlatForm.transform.position, Quaternion.Euler(Vector3.zero));
                Debug.Log("Hurdle Spawned");
                this.CurrentPlatformName = col.gameObject.name;
                if (this.PlatForm.GetComponentInChildren <UnityEngine.UI.Text>())
                {
                    this.PlatForm.GetComponentInChildren <UnityEngine.UI.Text>().transform.parent.gameObject.SetActive(false);
                }
            }
            Invoke("InputOn", 0.4f);
        }

        else if (col.gameObject.tag.Equals("Basket"))
        {
            PrefsManager.AddToCurrentBottleDumps();
            col.gameObject.GetComponent <SphereCollider>().enabled = false;
            PrefsManager.AddToTotalSuccessFullDumps();
            this.OnBasket = false;
            Debug.Log("In Basket");
            this.manager.AddCoins();
            Invoke("Restore", this.RestoreWait);
        }
        else if (col.gameObject.tag.Equals("BasketMain"))
        {
            this.OnBasket = true;
            Invoke("Check", this.RestoreWait);
        }
        //else if (col.gameObject.tag != "Finish" && col.gameObject.tag!="Target" && col.gameObject.tag!="Environment")
        //{
        //    if (this.transform.eulerAngles.x > -2 && this.transform.eulerAngles.x < 2)
        //    {
        //        //this.rb.AddTorque(this.transform.forward* 500f);
        //        AddForce(40, desired);
        //        Debug.Log("INto Else Case");
        //        //Invoke("GameOver", 0.5f);
        //    }
        //}
        //   Invoke("TestAllign", 0.3f);
    }