void OnCollisionEnter(Collision col)
    {
        rb.velocity = rb.velocity * 0.90f;

        if (!firstCollision && launched && Time.time > timeOfShot + Time.deltaTime * 2)
        {
            firstCollision = true;
        }

        if (Time.time > timeOfShot + Time.deltaTime * 2)
        {
            if (col.gameObject.name == "Fairway")
            {
                lie     = Lies.Fairway;
                rb.drag = 0.30f;
            }
            else if (col.gameObject.name == "Green")
            {
                lie     = Lies.Green;
                rb.drag = 0.40f;
            }
            else if (col.gameObject.name == "Rough")
            {
                lie     = Lies.Rough;
                rb.drag = 0.50f;
            }
            else if (col.gameObject.name == "Sand")
            {
                lie     = Lies.Sand;
                rb.drag = 0.65f;
            }
            else
            {
                lie     = Lies.Tee;
                rb.drag = 0.30f;
            }
        }

        if (col.gameObject.name == "Sign100")
        {
            addPoints(100);
            MakeAnnouncement("100 Points! x2", Time.time + 1.5f, Color.red);
        }
        else if (col.gameObject.name == "Sign150")
        {
            addPoints(150);
            MakeAnnouncement("150 Points! x2", Time.time + 1.5f, Color.white);
        }
        else if (col.gameObject.name == "Sign200")
        {
            addPoints(200);
            MakeAnnouncement("200 Points! x2", Time.time + 1.5f, Color.blue);
        }
        else if (col.gameObject.name == "Sign250")
        {
            addPoints(250);
            MakeAnnouncement("250 Points! x2", Time.time + 1.5f, Color.yellow);
        }
    }
 public void SetWorldState(WorldState State)
 {
     if (Stand != null)
     {
         Stand.SetActive(State == WorldState.Stand);
     }
     if (Lies != null)
     {
         Lies.SetActive(State == WorldState.Lies);
     }
     CurrentState = State;
 }
Example #3
0
    //Determine next lie. Add drag once first collision happens
    void OnCollisionEnter(Collision col)
    {
        rb.velocity = rb.velocity * 0.90f;

        if (!firstCollision && launched && Time.time > timeOfShot + Time.deltaTime * 2)
        {
            firstCollision = true;
        }

        if (Time.time > timeOfShot + Time.deltaTime * 2)
        {
            if (col.gameObject.name == "Fairway")
            {
                lie     = Lies.Fairway;
                rb.drag = 0.30f;
            }
            else if (col.gameObject.name == "Green")
            {
                lie     = Lies.Green;
                rb.drag = 0.40f;
            }
            else if (col.gameObject.name == "Rough")
            {
                lie     = Lies.Rough;
                rb.drag = 0.50f;
            }
            else if (col.gameObject.name == "Sand")
            {
                lie     = Lies.Sand;
                rb.drag = 0.65f;
            }
            else
            {
                lie     = Lies.Tee;
                rb.drag = 0.30f;
            }
        }
    }
Example #4
0
    // Use this for initialization
    void Start()
    {
        restPosition                 = transform.position;
        rb                           = gameObject.GetComponent <Rigidbody> ();
        follow                       = GameObject.Find("FollowCamerap1").GetComponent <Camera> ();
        high                         = GameObject.Find("HighCamerap1").GetComponent <Camera> ();
        cupheight                    = GameObject.Find("CupHeight");
        offset                       = follow.transform.position - transform.position;
        degreeChange                 = 0.0f;
        oldFace                      = 0.0f;
        newFace                      = 0.0f;
        turnspeed                    = 0.2f;
        yardage                      = GameObject.Find("Yardage").GetComponent <Text> ();
        club                         = GameObject.Find("Club").GetComponent <Text> ();
        clubSelection                = 0;
        power                        = 1.0f;
        powerbar                     = GameObject.Find("PowerBar").GetComponent <RectTransform> ();
        accuracybar                  = GameObject.Find("AccuracyBar").GetComponent <RectTransform> ();
        golfclub                     = GameObject.Find("GolfClub");
        initialGolfClubRotation      = golfclub.transform.eulerAngles;
        resetGolfClubRotation        = golfclub.transform.localRotation;
        currentGolfClubWorldPosition = golfclub.transform.position;
        initialGolfClubLocalPosition = golfclub.transform.localPosition;
        ballTrail                    = gameObject.GetComponent <TrailRenderer> ();

        wood  = GameObject.Find("wood").GetComponent <AudioSource>();
        wedge = GameObject.Find("wedge").GetComponent <AudioSource>();
        putt  = GameObject.Find("putt").GetComponent <AudioSource>();

        drawFade = 0;
        drawBar  = GameObject.Find("DrawBar").GetComponent <RectTransform> ();
        fadeBar  = GameObject.Find("FadeBar").GetComponent <RectTransform> ();

        lie = Lies.Tee;
        //Setup Draw and Fade UI
        GameObject.Find("D").GetComponent <Text> ().text = "D";
        GameObject.Find("F").GetComponent <Text> ().text = "F";

        //Lie UI
        lieText          = GameObject.Find("LieText").GetComponent <Text> ();
        lie              = Lies.Tee;
        liePowerModifier = 1.0f;

        //Tee
        tee = GameObject.Find("Tee");

        //Wind
        wind       = GameObject.Find("Wind").GetComponent <WindScript>().wind;
        pinPreview = GameObject.Find("PinPreview").GetComponent <Camera> ();

        //Stroke
        strokeText = GameObject.Find("StrokeCount").GetComponent <Text> ();

        //Power and Accuracy Text
        powerText    = GameObject.Find("PowerDisplay").GetComponent <Text> ();
        accuracyText = GameObject.Find("AccuracyDisplay").GetComponent <Text> ();

        powerText.text    = "";
        accuracyText.text = "";

        announcementText = GameObject.Find("Announcement").GetComponent <Text> ();

        sandBlastObj = GameObject.Find("SandBlast");

        Display_Yardage();
    }