Ejemplo n.º 1
0
//--------------------------------------------------------------------------METHODS:

//--------------------------------------------------------------------------HELPERS:
    private void MakeDecision()
    {
        float     Highestval       = 1.3f;
        ParamCube highestDirection = direction[1];

        foreach (ParamCube directions in direction)
        {
            //Debug.Log("Direction: " + directions);
            if (Highestval < directions.yAxis)
            {
                Highestval       = directions.yAxis;
                highestDirection = directions;
            }
        }

        //Move to that direction. Maybe make an enum or something
        if (highestDirection.gameObject.name == "Up")
        {
            directionWinner = "Up";
        }
        else if (highestDirection.gameObject.name == "Right")
        {
            directionWinner = "Right";
        }
        else if (highestDirection.gameObject.name == "Left")
        {
            directionWinner = "Left";
        }
        else        //If there's a tie, it goes down
        {
            directionWinner = "Down";
        }
    }
Ejemplo n.º 2
0
    // Make sure not to alter the prefab itself
    public void instantiateInCircle(GameObject prefab, Vector3 location, int num_objects)
    {
        GameObject go;

        // float angleSection = Mathf.PI * 2f / num_objects;
        float angleSection = Mathf.PI / num_objects;

        for (int i = -num_objects + 1; i < num_objects; i++)
        {
            float   angle    = i * angleSection - Mathf.PI / 2; // radians
            Vector3 newPos   = location + new Vector3(Mathf.Cos(angle), Mathf.Sin(angle), 0) * radius;
            Vector3 rotation = new Vector3(0, 0, angle);
            go = Instantiate(prefab, newPos, prefab.transform.rotation);
            // go.transform.localScale = new Vector3(1, 1, 1);
            go.transform.name = "CircleBar" + i;
            // go.transform.Rotate(new Vector3(0, 0, -90)); // d    egrees
            go.transform.Rotate(new Vector3(0, 0, angle * 180 / Mathf.PI + 90)); // degrees

            // assign paramcube inspector values
            go.AddComponent <ParamCube>();
            ParamCube p = go.GetComponent <ParamCube>();
            p.band            = Mathf.Abs(i);
            p.scaleMultiplier = 25;
            p.startScale      = 1;
            p.maxScale        = maxScale;
        }
    }
Ejemplo n.º 3
0
 public void makeHorizontal(GameObject prefab, Vector3 location, int num_objects)
 {
     for (int i = -num_objects + 1; i < num_objects; i++)
     {
         float      xPos   = i;
         Vector3    newPos = location + new Vector3(xPos, 0, 0);
         GameObject go     = Instantiate(prefab, newPos, prefab.transform.rotation);
         prefab.transform.localScale = new Vector3(1, 1, 1);
         prefab.transform.name       = "Bar" + i;
         // animate scale
         go.AddComponent <ParamCube>();
         ParamCube p = go.GetComponent <ParamCube>();
         p.band            = Mathf.Abs(i);
         p.scaleMultiplier = 25f;
         p.startScale      = 1f;
         p.maxScale        = 8f;
     }
 }
    private void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.tag == "Contaminable")
        {
            GameObject contaminable = collision.gameObject;

            if (collision.gameObject.GetComponent <ParamCubeScale>() == null)
            {
                ParamCube paramCube = contaminable.AddComponent <ParamCubeScale>();
                contaminable.GetComponent <Renderer>().material.color = Color.green;
                contaminable.tag = "Contaminated";
            }

            StartCoroutine(Contamination());
            StartCoroutine(TeleportContaminate(contaminable));
        }
        else
        {
            audioSource.clip = errorClip;
            audioSource.Play();
        }
    }