Exemplo n.º 1
0
        public void SetState(BC_State newState)
        {
            state = newState;
            if (state == BC_State.Ghost)
            {
                Color c  = gameObject.GetComponent <Renderer>().material.color;
                Color c2 = new Color(c.r, c.g, c.b, 0.6f);
                gameObject.GetComponent <Renderer>().material.SetColor("_Color", c2);

                /*
                 * TODO : This is ugly. How can I get just a little bit of transparency
                 * Material mat = new Material(Shader.Find("Standard"));
                 * mat.SetColor("_Color", new Color(1, 0, 0, .5f));
                 * mat.SetFloat("_Mode", 3);
                 * mat.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
                 * mat.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
                 * mat.EnableKeyword("_ALPHABLEND_ON");
                 * mat.renderQueue = 3000;
                 */
            }
            if (state == BC_State.Blueprint)
            {
                // Set the material back to the prefab's material to get rid of the green or red colours
                gameObject.GetComponent <Renderer>().material = TemplateController.prefabMaterial(template);
                Color c = gameObject.GetComponent <Renderer>().material.color;
                c.a = 1f;
                gameObject.GetComponent <Renderer>().material.color = c;
            }
        }
Exemplo n.º 2
0
 public SavedComponent(BeyondComponent bc)
 {
     template      = bc.template.name;
     state         = bc.state;
     group         = bc.beyondGroup;
     side          = bc.side;
     groupPosition = bc.groupPosition;
     cells         = bc.cells;
     position      = bc.transform.position;
     rotation      = bc.transform.rotation;
     name          = bc.transform.gameObject.name;
     layer         = bc.transform.gameObject.layer;
     isTrigger     = bc.transform.gameObject.GetComponent <BoxCollider>().isTrigger;
     enabled       = bc.transform.gameObject.GetComponent <BoxCollider>().enabled;
 }
Exemplo n.º 3
0
        public static void PlaceObject(BeyondComponent bc, string name, BC_State state)
        {
            bc.gameObject.name = name;

            // if the object was not snapped to a group, create a new group
            if (bc.beyondGroup == null)
            {
                PlaceController.Instance.CreateNewBeyondGroup(bc);
            }
            // TODO : Really need to think hard about this: will the box collider as trigger really be a general case for all elements ?
            bc.gameObject.GetComponent <BoxCollider>().isTrigger = false;
            bc.gameObject.GetComponent <BoxCollider>().enabled   = true;
            //TODO: Un-hardcode this shit
            bc.gameObject.layer = 9;
            // TODO clean this once dragging is beautiful
            if (state == BC_State.Blueprint)
            {
                bc.SetState(BC_State.Blueprint);
            }
            if (state == BC_State.Ghost)
            { // When dragging, we place ghosts rather than blueprints
                bc.SetState(BC_State.Ghost);
            }
        }