Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        //	Example of creating an object from the pool
        if (Input.GetKeyDown(KeyCode.G))
        {
            RollingBall go = gameObjectPool.Get();
            if (go != null)
            {
                Debug.Log("Spawned an object from the pool.");

                //	Do not destroy your object with GameObject.Destroy,
                //	instead deactivate it with go.SetActive(false)
                //	this will keep it in the pool
            }
        }
    }
Exemple #2
0
    public void OnSceneGUI()
    {
        serializedObject.Update();
        RollingBall throwObj = (RollingBall)target;
        Vector3     pointA   = throwObj.transform.position;
        //-------------------------------------------------------------------
        //PointB handles and line
        Vector3 pointB = throwObj.transform.TransformPoint(force_SP.vector3Value / -100);

        Handles.color = Color.blue;
        pointB        = Handles.FreeMoveHandle(
            pointB,
            Quaternion.identity,
            HandleUtility.GetHandleSize(pointB) * 0.08f,
            Vector3.one * 0.1f,
            Handles.DotCap);

        force_SP.vector3Value = throwObj.transform.InverseTransformPoint(pointB) * -100;
        Handles.DrawDottedLine(pointA, pointB, 20f);
        serializedObject.ApplyModifiedProperties();
    }
Exemple #3
0
 private void OnTriggerStay(Collider other)
 {
     if (other.transform.tag == "Player")
     {
         RollingBall rb = other.gameObject.GetComponent <RollingBall>();
         if (ownerID != rb.playerId)
         {
             value -= 1;
             if (value <= 0)
             {
                 t           = 0;
                 ownerID     = rb.playerId;
                 ownerScript = other.GetComponent <RollingBall>();
                 value       = 100;
                 GetComponent <MeshRenderer>().material.color = GameManager.instance.playerColor[ownerID];
                 sprite.color = new Color(GameManager.instance.playerColor[ownerID].r, GameManager.instance.playerColor[ownerID].g, GameManager.instance.playerColor[ownerID].b, sprite.color.a);
             }
         }
         if (ownerID == rb.playerId)
         {
             value = Mathf.Min(100, value + 1.5f);
         }
     }
 }