void UpdateTimer() { ArtGallery ag = ArtGallery.GetArtGallery(); CountdownTextBox ctb = countdownObject.GetComponent <CountdownTextBox>(); float timer = Mathf.Abs(ag.gameTimer); int timerMin = (int)timer / 60; int timerSec = (int)timer % 60; string timerOutMin = timerMin.ToString() + ":"; string timerOutSec = ""; if (timer > 60) { ctb.SetCounterTextColor(Color.white); } else { ctb.SetCounterTextColor(Color.red); } if (timerSec < 10) { timerOutSec = "0" + timerSec.ToString(); } else { timerOutSec = timerSec.ToString(); } string timeOutFinal = timerOutMin + timerOutSec; ctb.SetCounterText(timeOutFinal); }
// Use this for initialization void Start() { ArtGallery ag = FindObjectOfType <ArtGallery>(); testerID = ag.testerID; testerIDObject.GetComponent <TesterIDTextBox>().SetTesterID(testerID.ToString()); }
private void RedrawSculpture() { needsRedraw = false; for (int x = 0; x < SCULP_X; x++) { for (int z = 0; z < SCULP_Z; z++) { for (int y = 0; y < SCULP_Y; y++) { GameObject voxelProp = vox[x, z, y]; Renderer rend = voxelProp.gameObject.GetComponent <Renderer>(); if (voxArray[x, z, y] == new Color(0f, 0f, 0f, 0f)) { rend.enabled = false; } else { rend.material.color = voxArray[x, z, y]; rend.enabled = true; } } } } ArtGallery ag = ArtGallery.GetArtGallery(); //FIXME PROTOTYPE disabling to build new method ag.SaveVox(voxArray); }
private int MUTATION_CYCLES = 12; // maximum mutations per evolution public RoomConfiguration(RoomConfiguration parentRoom, int returnPortalID, int championPortalID, Artwork[] artworksPassed, Sculpture[] sculptures) { ArtGallery ag = ArtGallery.GetArtGallery(); Artwork champion = artworksPassed[championPortalID]; if (ArtGallery.DEBUG_LEVEL < ArtGallery.DEBUG.NONE) { Debug.Log("Creating a new room with " + artworksPassed.Length + " artworks"); } this.parentRoom = parentRoom; rooms = new RoomConfiguration[artworksPassed.Length]; if (ArtGallery.DEBUG_LEVEL < ArtGallery.DEBUG.NONE) { Debug.Log("Clearing artworks and sculptures..."); } artworks = new Artwork[artworksPassed.Length]; this.sculptures = sculptures; if (ArtGallery.DEBUG_LEVEL < ArtGallery.DEBUG.NONE) { Debug.Log("Created new artworks: " + artworksPassed.Length); } rooms[returnPortalID] = parentRoom; // clone champion to each artwork and mutate for (int i = 0; i < artworksPassed.Length; i++) { TWEANNGenotype geno = new TWEANNGenotype(champion.GetGenotype().Copy()); // champion art if (i == championPortalID) { //do little geno.Mutate(); } // return art else if (i == returnPortalID) { // do nothing - save some cpu } else { // all other art TWEANNCrossover cross = new TWEANNCrossover(false) { Sucessful = false }; //HACK PROTOTYPE hardcoded value //TWEANNGenotype crossedGeno = cross.Crossover(new TWEANNGenotype(geno.Copy()), new TWEANNGenotype(champion.GetGenotype().Copy())); //geno = crossedGeno; for (int m = 0; m < Random.Range(2, ag.artworkMutationChances); m++) { geno.Mutate(); } } artworks[i] = new Artwork(geno); } MutateSculptures(); }
/// <summary> /// Tells this portal that the player has chosen it /// </summary> /// <param name="player">Player that selected the portal</param> public void ActivatePortal(Player player) { ArtGallery pc = FindObjectOfType <ArtGallery>(); //pc.DoTeleport(player, portalID); // pc.DoColorChange(); //Teleport(player); }
// Use this for initialization void Start() { camera = FindObjectOfType <Camera>(); ag = FindObjectOfType <ArtGallery>(); slots = new List <FunctionSlot>(); hud = HUD.GetComponent <HUD>(); hud.AddSlots(tray, numberOfFunctionSlots); ActiveSlot = 0; hud.SelectSlot(tray, ActiveSlot); functions = new IFunctionItem[numberOfFunctionSlots]; ag.player.functions = this; /*** TESTING SECTION * Adding functions to the hud ***/ SavedFunction testFunction0 = new SavedFunction { fTYPE = FTYPE.ID, }; testFunction0.GenerateThumbnail(); AddFunction(testFunction0); //CycleActiveSlot(1); //SavedFunction testFunction1 = new SavedFunction //{ // fTYPE = FTYPE.GAUSS, //}; //testFunction1.GenerateThumbnail(); //AddFunction(testFunction1); //CycleActiveSlot(1); //SavedFunction testFunction2 = new SavedFunction //{ // fTYPE = FTYPE.SINE, //}; //testFunction2.GenerateThumbnail(); //AddFunction(testFunction2); //CycleActiveSlot(1); //SavedFunction testFunction3 = new SavedFunction //{ // fTYPE = FTYPE.SAWTOOTH, //}; //testFunction3.GenerateThumbnail(); //AddFunction(testFunction3); //CycleActiveSlot(1); //SavedFunction testFunction4 = new SavedFunction //{ // fTYPE = FTYPE.SQUAREWAVE, //}; //testFunction4.GenerateThumbnail(); //AddFunction(testFunction4); //CycleActiveSlot(1); }
/// <summary> /// Create a new artwork in a room with a given genotype /// </summary> /// <param name="geno">Genotype for this artwrok to use</param> public Artwork(TWEANNGenotype geno) { ag = ArtGallery.GetArtGallery(); needsRedraw = false; processingCPPN = false; this.geno = geno; cppnProcess = new Thread(new ThreadStart(GenerateImageFromCPPN)); img = new Texture2D(width, height, TextureFormat.ARGB32, false); pixels = new Color[width * height]; //GenerateImageFromCPPN(); // non threaded version of generation cppnProcess.Start(); }
private void Start() { camera = FindObjectOfType <Camera>(); ag = FindObjectOfType <ArtGallery>(); slots = new List <InventorySlot>(); items = new IInventoryItem[numberOfInventorySlots]; // item storage - contains geno and other data we want to save as well as the thumbnail hud = HUD.GetComponent <HUD>(); hud.AddSlots(tray, numberOfInventorySlots); ActiveSlot = 0; hud.SelectSlot(tray, ActiveSlot); ag.player.inventory = this; }
public void MutateSculptures() { ArtGallery ag = ArtGallery.GetArtGallery(); //Sort Sculptures Sculpture[] toMutate = new Sculpture[sculptures.Length]; TWEANNGenotype sculptureChampion = null; for (int s = 0; s < sculptures.Length; s++) { if (sculptures[s].GetSelected()) { sculptureChampion = new TWEANNGenotype(sculptures[s].GetGenotype().Copy()); sculptures[s].SetSelected(false); toMutate[s] = sculptures[s]; } else { toMutate[s] = sculptures[s]; } } //Select sculpture champion and crossover / mutate if (sculptureChampion != null) { for (int m = 0; m < sculptures.Length; m++) { Sculpture ms = toMutate[m]; if (ms != null) { TWEANNGenotype crossedGeno = new TWEANNGenotype(sculptureChampion.Copy()); TWEANNCrossover cross = new TWEANNCrossover(false) { Sucessful = false }; // HACK PROTOTYPE hardcoded value //TWEANNGenotype crossedmgeno = cross.Crossover(new TWEANNGenotype(sculptureChampion.Copy()), new TWEANNGenotype(ms.GetGenotype().Copy())); //crossedGeno = crossedmgeno; for (int mr = 0; mr < Random.Range(2, ag.sculptureMutationChances); mr++) //HACK PROTOTYPE hardcoded value for mutation rate { crossedGeno.Mutate(); } ms.NewSculpture(new TWEANNGenotype(crossedGeno)); } } } }
// Use this for initialization void Start() { artgallery = this; //FIXME PROTOTYPE set a random seed value here instead and save that value for a play session seed = testerID; //testerID //seed = UnityEngine.Random.Range(0, 9999999); UnityEngine.Random.InitState(seed); //RunExternalScript("test.bat", ""); // Build the game room GameObject roomProp = Instantiate(roomObject) as GameObject; gameRoom = roomProp.GetComponent <Room>(); gameRoom.SetArtGallery(this); // starting functions availableFunctions = new List <FTYPE> { FTYPE.ID, FTYPE.TANH, FTYPE.SQUAREWAVE, FTYPE.GAUSS, FTYPE.SINE, FTYPE.SAWTOOTH, FTYPE.ABSVAL }; if (activeFunctions == null) { activeFunctions = new List <FTYPE>(); ActivateFunction(FTYPE.ID); } //activate functions // Testing: activating all functions //ActivationFunctions.ActivateAllFunctions(); ActivationFunctions.ActivateFunction(activeFunctions); // build the lobby lobby = new RoomConfiguration(STARTING_NUM_ARTWORKS); room = lobby; gameRoom.InitializeRoom(GetImagesFromArtworks(room.GetArtworks())); List <Artwork> artToSave = new List <Artwork>(); lobby.SetSculptures(gameRoom.GetSculptures()); }
float interactionDistance = 30f; // maximum distance to check for raycast collision public void Start() { camera = FindObjectOfType <Camera>(); ag = FindObjectOfType <ArtGallery>(); ag.player = this; //FPC = gameObject; isInverted = ag.invertY; float yAxis = FPC.GetComponent <UnityStandardAssets.Characters.FirstPerson.FirstPersonController>().m_MouseLook.YSensitivity; if (!isInverted && Mathf.Sign(yAxis) < 0) { yAxis = yAxis * -1; FPC.GetComponent <UnityStandardAssets.Characters.FirstPerson.FirstPersonController>().m_MouseLook.YSensitivity = yAxis; } else if (isInverted && Mathf.Sign(yAxis) > 0) { yAxis = yAxis * -1; FPC.GetComponent <UnityStandardAssets.Characters.FirstPerson.FirstPersonController>().m_MouseLook.YSensitivity = yAxis; } }
public ActionResult Upload(HttpPostedFileBase imgfile, ArtGallery pics) { /* * string filename = Path.GetFileName(file.FileName); * string _filename = DateTime.Now.ToString("yymmssff") + filename; * * string path = Path.Combine(Server.MapPath("~/Content/Data"), _filename); * * pics.ArtPic = "~/Content/Data" + _filename; * * db.ArtGalleries.Add(pics); * * if (db.SaveChanges()>0) * { * file.SaveAs(path); * ViewBag.msg = "Picture Added to GAllery"; * ModelState.Clear(); * } */ string path = Uploadimage(imgfile); if (path.Equals("-1")) { ViewBag.error = "image could not be uploaded"; } else { ArtGallery gal = new ArtGallery(); gal.ArtTitle = pics.ArtTitle; gal.ArtDescription = pics.ArtDescription; gal.ArtPrice = pics.ArtPrice; gal.ArtCategory = pics.ArtCategory; gal.ArtPic = path; //ssasa gal.IsSold = false; gal.approvalDate = pics.approvalDate; //DateTime.Now; gal.artistId_FK = Convert.ToInt32(Session["UserId"].ToString()); //sessionid db.ArtGalleries.Add(gal); db.SaveChanges(); ViewBag.msg = "Pic Uploaded Sucessfully"; Response.Redirect("Index"); } /*if (ModelState.IsValid) * { * db.ArtGalleries.Add(pics); * if (db.SaveChanges() > 0) * { * TempData["msg"] = "Pic Uploaded"; * return RedirectToAction("Index"); * } * else * { * return View(); * } * }*/ return(RedirectToAction("Upload")); }
public GalleryDataService(ArtGallery g) { gallery = g; }
public static void Save(ArtGallery artGallery) { /* roomconfig * artwork[] artworks * - tweanngenotype geno * - list<nodes> nodes * - long innovation * - FTYPE fTYPE * - NTYPE nTYPE * - float bias * - list<links> links * - long innovation * - long sourceInnovation * - long targetInnovation * - float weight * - bool active (not in use) * - long id * - int numberInputs * - int numberOutputs * - int archetypeIndex * sculpture[] sculptures * - tweanngenotype geno * - list<nodes> nodes * - long innovation * - FTYPE fTYPE * - NTYPE nTYPE * - float bias * - list<links> links * - long innovation * - long sourceInnovation * - long targetInnovation * - float weight * - bool active (not in use) * - long id * - int numberInputs * - int numberOutputs * - int archetypeIndex * - bool transparency * Roomconfiguration ParentRoom * RoomConfiguration[] linkedRooms */ //FIXME This needs to be recursive! This will take a bit of planning. // Get the lobby RoomConfiguration lobby = artGallery.GetLobby(); // Build a new save for the room config SaveGameRoomConfiguration newRoom = new SaveGameRoomConfiguration { ParentRoom = null, LinkedRooms = new SaveGameRoomConfiguration[lobby.rooms.Length], Artworks = new SaveGameArtwork[lobby.artworks.Length], //Sculptures = new SaveGameSculpture[lobby.sculptures.Length], }; // Add the rooom roomTree.Add(newRoom); //Now get each linked room to the lobby (traverse the tree) SaveGameRoomConfiguration[] tempLinkedRooms = new SaveGameRoomConfiguration[lobby.rooms.Length]; for (int i = 0; i < tempLinkedRooms.Length; i++) { tempLinkedRooms[i] = new SaveGameRoomConfiguration { ParentRoom = newRoom }; } // Get a reference to the index given to the new room int newRoomIndex = roomTree.IndexOf(newRoom); }
/* Public methods */ public void SetArtGallery(ArtGallery artGallery) { this.ag = artGallery; }