public static SmoothLightingManager Create()
    {
        var go = new GameObject("SmoothLightingManager");

        go.transform.position = new Vector3(0, 2, 0);
        var slm = go.AddComponent <SmoothLightingManager>();

        slm.mf = SimpleQuad.ImmediateAdd(go, 10, 10);

        slm.rt = new RenderTexture(Screen.width, Screen.height, 24);

        slm.slc = SmoothLightCamera.Create(slm.rt);
        //slm.slc.GetComponent<Camera>().targetTexture = slm.rt;

        var renderer = go.GetComponent <MeshRenderer>();

        //renderer.material.shader = Shader.Find("Unlit/Transparent");
        renderer.material.shader      = Resources.Load <Shader>("shaders/ShadowShader");
        renderer.material.mainTexture = slm.rt;

        slm.lightTex = Resources.Load <Texture2D>("sprites/light-mask");
        slm.blackTex = createBlackTex();

        return(slm);
    }
Exemple #2
0
 public InputMappingCursor(GameObject go)
 {
     inputManager   = InputManager.Instance;
     mainMenu       = go.GetComponent <MainMenu>();
     cursor         = go.AddComponent <SimpleQuad>();
     cursor.enabled = false;
 }
Exemple #3
0
    // Use this for initialization
    void Start()
    {
        probe = gameObject.AddComponent <SmoothLightProbe>();

        mf = SimpleQuad.ImmediateAdd(gameObject, 0.5f, 0.5f);

        onTex  = Texture2D.whiteTexture;
        offTex = Texture2D.blackTexture;
    }
        public SimpleQuad NewSimpleQuad(string materialName, float left, float top,
                            float width, float height, ColourValue colour, int layer)
        {
            SimpleQuad quad = new SimpleQuad(GetUniqueLabelName(), materialName,
              left, top, width, height, colour);

            Overlays[layer].Add2D(quad.Panel);
            Quads.Add(quad);

            return quad;
        }
Exemple #5
0
    public static Ground Create()
    {
        var go     = new GameObject("Ground");
        var ground = go.AddComponent <Ground>();


        SimpleQuad.ImmediateAdd(go, 20, 20);

        // MeshCollider has trouble with local scale changes, even when added after the scale changes.
        go.AddComponent <MeshCollider>();

        ground.nms = go.AddComponent <NavMeshSurface>();

        ground.nms.BuildNavMesh();

        return(ground);
    }
Exemple #6
0
    public void Update()
    {
        if (radius != lastRadius)
        {
            SimpleQuad.ImmediateAdd(lightModel, radius * 2, radius * 2);
            lastRadius = radius;
            var mr = lightModel.GetComponent <MeshRenderer>();
            mr.material = new Material(Shader.Find("Custom/Circle2"));

            var mf = lightModel.GetComponent <MeshFilter>();
            var mc = lightModel.GetComponent <SphereCollider>();
            mc.radius = radius / 2; // TODO: Because lighthalo's "radius" is actually a diameter (see powerbroadcaster);
            //mc.sharedMesh = mf.sharedMesh;
            // TODO: this causes a "cleaning the mesh failed" error
            // sometimes. This is related to 0 size meshes (like when
            // the lighthalo radius is 0), but a fix is not immediately
            // apparent.
        }
    }
        public HUD()
        {
            _isVisible = false;

            Slot.Width = Slot.Size * 6 / Engine.Singleton.Camera.AspectRatio;
            Slots = new Slot[SlotsCount];
            for (int i = 0; i < SlotsCount; i++)
                Slots[i] = new Slot(SlotsSpacing, SlotsSpacing + i * (Slot.Size + SlotsSpacing));

            DescriptionBg = Engine.Singleton.Labeler.NewSimpleQuad("QuadMaterial", 0.3f, 0.5f, 0.6f, 0.45f, ColourValue.White, 1);
            SelectedPicture = Engine.Singleton.Labeler.NewSimpleQuad("QuadMaterial",
                0.31f,
                0.58f,
                0.3f / Engine.Singleton.Camera.AspectRatio,
                0.3f, ColourValue.White, 2);
            DescriptionLabel = Engine.Singleton.Labeler.NewTextLabel("Primitive", 0.03f, new ColourValue(0.7f, 0.4f, 0), new ColourValue(1, 1.0f, 0.6f), 2);
            DescriptionLabel.SetPosition(0.55f, 0.51f);

            ChosenItemBg = Engine.Singleton.Labeler.NewSimpleQuad("QuadMaterial", 0.0f, 0.0f, 0.2f, 0.05f, ColourValue.White, 1);
            ChosenItemLabel = Engine.Singleton.Labeler.NewTextLabel("Primitive", 0.02f, new ColourValue(0.7f, 0.4f, 0), new ColourValue(1, 1.0f, 0.6f), 2);
            ChosenItemLabel.SetPosition(0.05f, 0.0f);
            ChosenItemPicture = Engine.Singleton.Labeler.NewSimpleQuad("QuadMaterial", 0.0f, 0.0f, 0.05f, 0.05f, ColourValue.White, 2);

            GravityBg = Engine.Singleton.Labeler.NewSimpleQuad("QuadMaterial", 0.5f, 0.0f, 0.3f, 0.07f, ColourValue.White, 1);
            GravityLabel = Engine.Singleton.Labeler.NewTextLabel("Primitive", 0.05f, ColourValue.Green, ColourValue.Green, 2);
            GravityLabel.SetPosition(0.55f, 0.01f);
            GravityLabel.Caption = "Gravity: ON";

            InventoryBg = Engine.Singleton.Labeler.NewSimpleQuad("InventoryBgMaterial", 0.01f, 0.01f, 0.98f, 0.98f, new ColourValue(1, 1, 1), 0);
            ArrowDown = Engine.Singleton.Labeler.NewSimpleQuad("DownArrow", 0.2f, 0.7f, Engine.Singleton.GetFloatFromPxWidth(64), Engine.Singleton.GetFloatFromPxHeight(128), ColourValue.White, 2);
            ArrowUp = Engine.Singleton.Labeler.NewSimpleQuad("UpArrow", 0.2f, 0.1f, Engine.Singleton.GetFloatFromPxWidth(64), Engine.Singleton.GetFloatFromPxHeight(128), ColourValue.Black, 2);
            MouseCursor = Engine.Singleton.Labeler.NewSimpleQuad("Kursor", 0.0f, 0.0f, Engine.Singleton.GetFloatFromPxWidth(32), Engine.Singleton.GetFloatFromPxHeight(32), new ColourValue(1, 1, 1), 4);

            CategoryBg = Engine.Singleton.Labeler.NewSimpleQuad("QuadMaterial", 0.35f, 0.02f, 0.45f, 0.1f, new ColourValue(1, 1, 1), 1);
            CategoryLabel = Engine.Singleton.Labeler.NewTextLabel("Primitive", 0.05f, new ColourValue(0.7f, 0.4f, 0), new ColourValue(1, 1.0f, 0.6f), 2);
            CategoryLabel.SetPosition(0.5f, 0.04f);

            KtoraStrona = 0;
            SelectedOne = -1;

            IsVisible = false;
        }
Exemple #8
0
    public void Update()
    {
        var powerable = GetComponent <Powerable>();

        if (powerable.powered)
        {
            radius = 3; // TODO: radius is always 3
            Collider[] hits = Physics.OverlapSphere(powerField.transform.position, radius, 1 << 9);

            foreach (Collider hit in hits)
            {
                // Get in parent because the collider is on the model
                var hitPowerable = hit.GetComponentInParent <Powerable>();
                if (hitPowerable)
                {
                    hitPowerable.powered = true;
                }
            }
        }
        else
        {
            // "Disable" the field if we aren't powered
            radius = 0;
        }

        if (radius != lastRadius)
        {
            // TODO: instead of remaking quad, maybe resize?

            // radius * 2 because the size is for 1 side of the quad, which
            // will be the diameter of the circle;
            SimpleQuad.ImmediateAdd(powerField, radius * 2, radius * 2);
            lastRadius = radius;
            var mr = powerField.GetComponent <MeshRenderer>();
            mr.material = new Material(Shader.Find("Custom/Circle2"));
            mr.material.SetColor("_Color", new Color(0.0f, 0.0f, 1, 0.2f));
        }
    }
            public Slot(float left, float top)
            {
                BgQuad = Engine.Singleton.Labeler.NewSimpleQuad("QuadMaterial", left, top, Width, Size, new ColourValue(1, 1, 1), 1);
                BlueQuad = Engine.Singleton.Labeler.NewSimpleQuad("HighlightBlueMaterial", left, top, Width, Size, new ColourValue(1, 1, 1), 3);
                ItemLabel = Engine.Singleton.Labeler.NewTextLabel("Primitive", 0.02f, ColourValue.White, ColourValue.Black, 2);
                ItemLabel.SetPosition(left, top + 0.015f);

                BlueQuad.IsVisible = false;
                isSelected = false;
            }
 public bool IsOver(SimpleQuad quad)
 {
     if (Engine.Singleton.GetFloatFromPxWidth(User.Mysz.X.abs) >= quad.Panel.Left && Engine.Singleton.GetFloatFromPxWidth(User.Mysz.X.abs) <= quad.Panel.Left + quad.Panel.Width && Engine.Singleton.GetFloatFromPxHeight(User.Mysz.Y.abs) >= quad.Panel.Top && Engine.Singleton.GetFloatFromPxHeight(User.Mysz.Y.abs) <= quad.Panel.Top + quad.Panel.Height)
         return true;
     return false;
 }