Beispiel #1
0
 public void Activate()
 {
     if (rockState == RockState.UnderGround)
     {
         rockState = RockState.Emerging;
         dirt.SetActive(true);
         //aud.PlayOneShot(emerge);
         aud.PlayOneShot(emerge, .5f);
     }
 }
Beispiel #2
0
    void OnMouseDown()
    {
        if (rockState != RockState.IDEL)
        {
            return;
        }
        rockState = RockState.HOLD;

        screenPoint = MainCamera.WorldToScreenPoint(transform.position);
        offset      = Input.mousePosition - screenPoint;
        offset.z    = 0f;
    }
Beispiel #3
0
    // Update is called once per frame
    new void Update()
    {
        base.Update();

        if (rockState == RockState.Emerging)
        {
            transform.localPosition = Vector3.SmoothDamp(transform.localPosition, aboveGround, ref velocity, 3f);

            if (Vector3.Distance(transform.localPosition, aboveGround) <= .05f)
            {
                dirt.SetActive(false);
                rockState = RockState.AboveGround;
            }
        }
    }
Beispiel #4
0
    void release()
    {
        float   force   = Mathf.Sqrt((transform.position - midPoint).magnitude);
        Vector3 direct3 = midPoint - transform.position;
        Vector2 direct  = new Vector2(direct3.x, direct3.y).normalized;

        if (force > 1.2f)
        {
            rockState          = RockState.RELEASE;
            rigid.gravityScale = 1.0f;
            rigid.AddForce(force * direct * ForceMagn);
            shootSound.Play();
        }
        else
        {
            rockState = RockState.IDEL;
        }
    }
Beispiel #5
0
    // Update is called once per frame
    void Update()
    {
        if (rockState == RockState.IDEL)
        {
            transform.position = midPoint;
            resetElastic();
        }
        else if (rockState == RockState.HOLD)
        {
            Vector3 curScreenPoint = new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z) - offset;
            Vector3 curPos         = MainCamera.ScreenToWorldPoint(curScreenPoint);
            curPos.x           = Mathf.Clamp(curPos.x, MinX, MaxX);
            curPos.y           = Mathf.Clamp(curPos.y, MinY, MaxY);
            transform.position = curPos;
            setElastic();
        }
        else if (rockState == RockState.RELEASE)
        {
            resetElastic();
            if ((rigid.velocity.magnitude <= 0.1f && shootTime > 8f) || shootTime > 15f)
            {
                gm.NextShoot();
                rockState = RockState.DEADBALL;
            }
            else
            {
                shootTime += Time.deltaTime;
            }
        }

        frontElastic.SetPositions(FrontElasticPoints);
        backElastic.SetPositions(BackElasticPoints);

        movement = transform.position - lastPos;
        lastPos  = transform.position;
    }
 public void Awake()
 {
     standardState = new StandardState(this, GetComponent<CharacterController>());
     floatingState = new FloatingState(this, GetComponent<Rigidbody>());
     rockState = new RockState(this, GetComponent<Rigidbody>());
 }
 public void Awake()
 {
     standardState = new StandardState(this, GetComponent <CharacterController>());
     floatingState = new FloatingState(this, GetComponent <Rigidbody>());
     rockState     = new RockState(this, GetComponent <Rigidbody>());
 }