Exemple #1
0
    protected void ResetState(Vector3 position, Quaternion rotation)
    {
        m_slowTime = 0;
        m_state    = State.IDLE;
        Vector3 v = transform.position;

        m_rigidbody.isKinematic = false;
        v.y = m_MaxYAxis;
        transform.position          = position;
        transform.rotation          = rotation;
        m_rigidbody.constraints     = RigidbodyConstraints.None;
        m_rigidbody.angularVelocity = Vector3.zero;
        m_rigidbody.velocity        = Vector3.zero;
        m_rigidbody.useGravity      = true;
        renderer.enabled            = true;
        collider.enabled            = true;
        LightRenderer.Open();
        OpenRenderer();
        ReversePhysicalMaterial();
        PhysicalSupportTools.Remove(gameObject, PhysicalSupportType.MaxSpeedLimit);
        RackBallCollision rb;

        if (rb = GetComponent <RackBallCollision>())
        {
            Destroy(rb);
        }
        enabled = true;
    }
Exemple #2
0
 void Update()
 {
     if (m_BallQueue.Count > 0)
     {
         m_Time -= Time.deltaTime;
         if (m_Time < 0)
         {
             Rigidbody rb = m_BallQueue.Dequeue();
             WhiteBall cueball;
             if ((cueball = rb.GetComponent <WhiteBall>()) && cueball.BallState != PoolBall.State.POTTED) //ball has already reset
             {
                 return;
             }
             rb.GetComponent <PoolBall>().LightRenderer.Open();
             rb.collider.enabled = true;
             rb.isKinematic      = false;
             rb.useGravity       = true;
             rb.velocity         = m_Force;
             rb.renderer.enabled = true;
             rb.gameObject.AddComponent <RackBallCollision>();
             PhysicalSupportTools.MaxSpeedLimitTo(rb.gameObject, m_BallMaxSpeed);
             m_Time = m_TimeInterval;
         }
     }
 }
Exemple #3
0
    private static PhysicalSupportTools AddSupportTools(GameObject o, PhysicalSupportType supportType, IPhysicalSupport support)
    {
        PhysicalSupportTools ps = o.GetComponent <PhysicalSupportTools>();

        if (!ps || ps.m_SupportType != supportType)
        {
            ps = o.AddComponent <PhysicalSupportTools>();
            ps.m_SupportType = supportType;
        }
        ps.m_Support = support;
        return(ps);
    }
Exemple #4
0
 public virtual void Awake()
 {
     m_rigidbody      = gameObject.GetComponent <Rigidbody>();
     m_ShadowRenderer = GetComponent <BallShadowRenderer>();
     m_LightRenderer  = transform.FindChild("RefLight").GetComponent <Follower>();
     m_FocusRenderer  = transform.FindChild("Focus").GetComponent <Follower>();
     sphereCollider   = gameObject.GetComponent <SphereCollider>();
     m_Mesh           = GetComponent <MeshRenderer>();
     //m_BallPhysicalDrag = GetComponent<BallPhysicalDrag>();
     m_Radius           = sphereCollider.radius * transform.localScale.x;
     m_BallPhysicalDrag = PhysicalSupportTools.PhysicalDragTo(gameObject, ConstantData.GetPoolDatas().BallDrag, ConstantData.GetPoolDatas().BallAngularDrag);
     //m_AngularVelocityCorrection = PhysicalSupportTools.AngularVelocityCorrectionTo(gameObject, m_rigidbody, m_Radius);
     m_PhysicMaterial = collider.sharedMaterial;
 }
Exemple #5
0
    public void FixedCall()
    {
        if (m_Rigidbody.isKinematic)
        {
            return;
        }

        m_Velocity        = m_Rigidbody.velocity;
        m_AngularVelocity = PhysicalSupportTools.CalculateAngularVelocity(m_Radius, m_Velocity);
        if (m_Rigidbody.angularVelocity.sqrMagnitude <= m_AngularVelocity.sqrMagnitude)
        {
            m_Rigidbody.angularVelocity = m_AngularVelocity;
        }
    }
 public virtual void Awake()
 {
     m_rigidbody = gameObject.GetComponent<Rigidbody>();
     m_ShadowRenderer = GetComponent<BallShadowRenderer>();
     m_LightRenderer = transform.FindChild("RefLight").GetComponent<Follower>();
     m_FocusRenderer = transform.FindChild("Focus").GetComponent<Follower>();
     sphereCollider = gameObject.GetComponent<SphereCollider>();
     m_Mesh = GetComponent<MeshRenderer>();
     //m_BallPhysicalDrag = GetComponent<BallPhysicalDrag>();
     m_Radius = sphereCollider.radius * transform.localScale.x;
     m_BallPhysicalDrag = PhysicalSupportTools.PhysicalDragTo(gameObject, ConstantData.GetPoolDatas().BallDrag, ConstantData.GetPoolDatas().BallAngularDrag);
     //m_AngularVelocityCorrection = PhysicalSupportTools.AngularVelocityCorrectionTo(gameObject, m_rigidbody, m_Radius);
     m_PhysicMaterial = collider.sharedMaterial;
 }