Example #1
0
    // Update is called once per frame
    void Update()
    {
        if (art != null && art.NeedsRedraw())
        {
            art.ApplyImageProcess();
            img = art.GetArtwork();
            renderer.material.mainTexture = img;
            Debug.Log("Image applied");
        }

        if (!PauseMenu.isPaused && Input.GetButtonDown("Fire2"))
        {
            img = new Texture2D(width, height, TextureFormat.ARGB32, true);
            art = new Artwork();
            textbox.Text("New image and genome");
        }

        if (!PauseMenu.isPaused && Input.GetButtonDown("Fire1"))
        {
            TWEANNGenotype geno = art.GetGenotype();
            geno.Mutate();
            textbox.Text("Mutating...");
            art = new Artwork(geno);
        }
    }
Example #2
0
    // Update is called once per frame
    void Update()
    {
        if (leftArt.NeedsRedraw())
        {
            leftArt.ApplyImageProcess();
            leftImg = leftArt.GetArtwork();
            leftRenderer.material.mainTexture = leftImg;
            Debug.Log("leftImg applied");
        }
        if (rightArt.NeedsRedraw())
        {
            rightArt.ApplyImageProcess();
            rightImg = rightArt.GetArtwork();
            rightRenderer.material.mainTexture = rightImg;
            Debug.Log("rightImg applied");
        }

        if (!PauseMenu.isPaused && Input.GetButtonDown("Fire2"))
        {
            leftImg  = new Texture2D(width, height, TextureFormat.ARGB32, true);
            rightImg = new Texture2D(width, height, TextureFormat.ARGB32, true);
            BuildArtworks();
            //leftArt = new Artwork(leftGeno);
            //rightArt = new Artwork(rightGeno);
        }

        if (!PauseMenu.isPaused && Input.GetButtonDown("Fire1"))
        {
            leftGeno  = new TWEANNGenotype(leftArt.GetGenotype().Copy());
            rightGeno = new TWEANNGenotype(rightArt.GetGenotype().Copy());


            TWEANNCrossover cr = new TWEANNCrossover(false);
            cr.Crossover(leftGeno, rightGeno);
            leftImg  = new Texture2D(width, height, TextureFormat.ARGB32, true);
            rightImg = new Texture2D(width, height, TextureFormat.ARGB32, true);
            leftArt  = new Artwork(leftGeno);
            rightArt = new Artwork(rightGeno);
        }
    }
Example #3
0
    private void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit hit;
            Ray        ray = new Ray(camera.transform.position, camera.transform.forward * interactionDistance);
            if (Physics.Raycast(ray, out hit))
            {
                Transform objectHit = hit.transform;
                if (hit.collider.tag == "portal")
                {
                    Portal    p   = hit.collider.gameObject.GetComponent <Portal>();
                    Texture2D img = new Texture2D(p.GetImage().width, p.GetImage().height, TextureFormat.ARGB32, false);
                    Graphics.CopyTexture(p.GetImage(), img);
                    int            portalID = p.GetPortalID();
                    TWEANNGenotype geno     = new TWEANNGenotype(ag.GetArtwork(portalID).GetGenotype().Copy());

                    SavedArtwork newArtwork = new SavedArtwork
                    {
                        Image = Sprite.Create(img, new Rect(0, 0, img.width, img.height), new Vector2(0.5f, 0.5f)) as Sprite,
                        Geno  = geno
                    };
                    AddItem(newArtwork);
                    FindNextEmptySlot();
                }

                if (hit.collider.tag == "sculpture")
                {
                    Sculpture s = hit.collider.gameObject.GetComponent <Sculpture>();

                    sculptureGeno = s.GetComponent <Sculpture>().GetGenotype();

                    ag.SelectSculpture(s);
                    //s.GetComponent<Sculpture>().SetSelected(!s.GetComponent<Sculpture>().GetSelected());
                }
            }
        }

        if (Input.GetMouseButtonDown(1))
        {
            RaycastHit hit;
            Ray        ray = new Ray(camera.transform.position, camera.transform.forward * interactionDistance);
            if (Physics.Raycast(ray, out hit))
            {
                Transform objectHit = hit.transform;
                if (hit.collider.tag == "portal")
                {
                    Portal  p        = hit.collider.gameObject.GetComponent <Portal>();
                    int     portalID = p.GetPortalID();
                    Artwork art      = ag.GetArtwork(portalID);
                    if (GetActiveSlotItem() != null)
                    {
                        ag.RemoveRoom(portalID);
                        art.SetGenotype(GetActiveSlotItem().Geno); // FIXME Null ref possible here - add checks
                        art.Refresh();
                        art.ApplyImageProcess();
                        items[ActiveSlot] = null;
                        hud.UpdateInventoryThumbnail(ActiveSlot, null);
                    }
                    else
                    {
                        // do nothing for now
                    }
                }

                if (hit.collider.tag == "sculpture")
                {
                    Sculpture s = hit.collider.gameObject.GetComponent <Sculpture>();

                    sculptureGeno = s.GetComponent <Sculpture>().GetGenotype();

                    ag.ResetSculpture(s);
                    //s.GetComponent<Sculpture>().SetSelected(!s.GetComponent<Sculpture>().GetSelected());
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.Keypad4))
        {
            CycleActiveSlot(-1);
        }
        if (Input.GetKeyDown(KeyCode.Keypad6))
        {
            CycleActiveSlot(1);
        }

        float wheel = Input.GetAxis("Mouse ScrollWheel");

        if (wheel < 0f)
        {
            //scroll down
            CycleActiveSlot(-1);
        }
        else if (wheel > 0f)
        {
            //scroll up
            CycleActiveSlot(1);
        }
    }