public void onClick(String b) { switch (b) { case "Play": Dj.getInstant().stop(Dj.Sound.Menu); //SceneManager.LoadScene("MainGame"); SceneManager.LoadScene("MainGame"); break; case "Settings": Dj.getInstant().stop(Dj.Sound.Menu); Settings.who = 0; SceneManager.LoadScene("Settings"); break; } }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Dj = await _context.Djs.FindAsync(id); if (Dj != null) { _context.Djs.Remove(Dj); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
private void init() { audioListener = haveAL.GetComponent <AudioListener>(); P.updaiter = updaiter; A.MainUpdaiter = updaiter; //Asteroid.plane = gameObject.GetComponent<PolygonCollider2D>(); setPause(false); _spriteRenderer = gameObject.GetComponent <SpriteRenderer>(); toUp = false; color = new Color(1f, 1f, 1f, 1f); noDead = false; Asteroid.score = 0; rigidbody = GetComponent <Rigidbody2D>(); tmp = new Vector2(); vector = new Vector2(); Dj.getInstant().play(Dj.Sound.Game); }
public void SetupTileset(SpriteLot tilesetSprites, HashSet <int> solidTileSet, HashSet <int> spawnTileSet) { if (tilesetSprites.Length == 0) { Dj.Crashf("TiledLoader.SetupTileset was passed empty SpriteLot {0}.", tilesetSprites.gameObject.name); } //HashSet<int> solidTileSet = new HashSet<int>(solidTileIds); this.spawnTileSet = spawnTileSet; tileset = new Tile[tilesetSprites.Length]; for (int i = 0; i < tileset.Length; i++) { tileset[i] = ScriptableObject.CreateInstance <Tile>(); tileset[i].sprite = tilesetSprites[i]; tileset[i].colliderType = solidTileSet.Contains(i) ? Tile.ColliderType.Grid : Tile.ColliderType.None; } }
void SpawnTileId(int tile_id, Vector3Int tile_pos) { Dj.Tempf("Spawn Tile {0}", tile_id); var spawn_pos = tilemap.layoutGrid.CellToWorld(tile_pos) + tilemap.layoutGrid.cellSize / 2; switch (tile_id) { case 01: banks["player"].Spawn(players.transform, spawn_pos); break; case 02: banks["dumbdot"].Spawn(dots.transform, spawn_pos); break; case 03: banks["ghostcreep"].Spawn <GenericMazeCreature>(ghosts.transform, spawn_pos).Setup(tile_pos); break; case 04: banks["slippy"].Spawn <GenericMazeCreature>(ghosts.transform, spawn_pos).Setup(tile_pos); break; default: Dj.Warnf("failed to spawn unknown tile_id {0}", tile_id); break; } }
public void BroadcastPlayerDelta(Story <PlayerPage> player, IDelta delta) { var session = GetSession(player.id); if (session != null) { link.Post( session.GetPage().ServerOnly_peerid, bc.PlayerDelta.op, new bc.PlayerDelta { idelta = delta } ); } else { Dj.Warnf("Player#{0} has no valid session", player.id); } }
public void StoryApplyDelta(IDelta delta) { if (delta is D) { this.pagenumber = delta.pagenumber; if (this.ApplyDelta((D)delta)) { // ok, handled } else { Dj.Errorf("Page {0}.ApplyDelta failed on delta {1}\n-- return false", this, delta); } } else { Dj.Crashf("BasePage expected delta of type {0}\n-- but got bad delta {1}", typeof(D), delta); } }
public void InitializeManualTT() { var grid = tilemap.gameObject.GetComponentInParent <Grid>(); this.mazeMaster = grid.gameObject.GetComponent <maze.MazeMaster>(); if (this.mazeMaster == null) { this.mazeMaster = grid.gameObject.AddComponent <maze.MazeMaster>(); } this.mazeMaster.IsTileSolid = cell => { return(SolidTileIds.Contains(Gett(cell))); }; if (sprites.Length == 0) { Dj.Crashf("BaseTilemapXXI '{0}' has no sprites in its SpriteLot '{1}'. TiledLoader.SetupTileset will crash.", this.gameObject.name, sprites.gameObject.name); } loader.SetupTileset(sprites, SolidTileIds, SpawnTileIds); tts = new Dictionary <twin, int>(); }
public Story Read(Pages delta) { if (isAuthor) { Dj.Crashf("Authors can't Read. Failed to Read delta Pages '{0}'.", delta.address); } if (this.stories.TryGetValue(delta.address, out var story)) { story.SetStoryteller(this); story.ReadChanges(delta); StoryChanged(story); return(story); } else { Dj.Warnf("Couldn't find matching story for delta Pages '{0}'.", delta.address); return(null); } }
public void SetPostHandler <ACTION, REPLY>(short opCode, System.Action <PostAssistant <ACTION, REPLY> > PrepareAssistant) where ACTION : struct where REPLY : struct { master.SetHandler(opCode, (message) => { var assistant = new PostAssistant <ACTION, REPLY>(message); PrepareAssistant(assistant); if (assistant.Done) { } else if (assistant.Delayed) { // if (assistant.responseStatus == ResponseStatus.Success) message.Respond(Capn.Crunchatize(assistant.reply), ResponseStatus.Success); // else message.Respond(assistant.responseStatus); } else { throw Dj.Crashf("generic action PrepareAssistant terminated illegally on opcode '{0}'!\nYou must call REPLY, REJECT, or PENDING before the action is done.", opCode); } }); }
public ActionResult Index() { string usersID = User.Identity.GetUserId(); using (RelayDJDevEntities db = new RelayDJDevEntities()) { Dj dj = db.Djs.Where(x => x.DjUserId == usersID).FirstOrDefault(); //string userName = await GetUsersSpotifyUserName(); if (dj != null) { //set location of playlist return(View()); } else { return(RedirectToAction("RegisterDJ", "Account", new { id = usersID })); } } }
public void Unregister(GameObject gameObject) { if (objectsToTilePositions.TryGetValue(gameObject, out var tile_pos)) { if (tilePositionsToHeaps.TryGetValue(tile_pos, out var heap)) { heap.Remove(gameObject); } else { Dj.Warnf("GenericMazeMaster unregistered {0} but couldn't unheap it from tilePosition {1}", gameObject, tile_pos); } objectsToTilePositions.Remove(gameObject); } else { Dj.Warnf("GenericMazeMaster couldn't unregister {0}", gameObject); } }
// Start is called before the first frame update void Start() { loopin.loop = true; volume = 0f; DontDestroyOnLoad(this); dea = dead; if (instant == null) { instant = this; } else { Destroy(this.gameObject); } loopin.clip = warnin; loopin.Play(); loopin.volume = 0f; }
public void Write(Story story) { if (!isAuthor) { Dj.Crashf("Non-Authors can't Write. Failed to Write Story '{0}'.", story.address); } if (story.SetStoryteller(this)) { this.stories.Add(story.address, story); StoryChanged(story); } else if (this.stories[story.address] == story) { StoryChanged(story); } else { Dj.Warnf("WARNING: Write story@{0} failed, please implement", story.address); } }
override protected void Initialize() { ins = this; this.options = InitializeOptions(); if (authorCell == null) { throw Dj.Crash("AuthorXXI requires [authorCell] to be set in inspector"); } this.authorCellBank = GetBank(authorCell.name); if (authorCursor == null) { throw Dj.Crash("AuthorXXI requires [authorCursor] to be set in inspector"); } this.authorCursorBank = GetBank(authorCursor.name); this.currentRoomGridString = ""; SetRoomCoord(options.pos_startingRoom, null); this.keyToCellValue = new Dictionary <KeyCode, ushort>(); Input_SetKeyCellValue(KeyCode.Q, 0); for (int i = 0; i < 9; i++) { Input_SetKeyCellValue(KeyCode.Alpha1 + i, (ushort)(1 + i)); } this.InitializeStates(); if (this.state_play == null) { throw Dj.Crash(name + ".state_play is null. did you override InitializeStates badly?"); } if (this.state_edit == null) { throw Dj.Crash(name + ".state_edit is null. did you override InitializeStates badly?"); } if (this.state_editpalette == null) { throw Dj.Crash(name + ".state_editpalette is null. did you override InitializeStates badly?"); } SetState(state_edit); }
private void Update() { // read ratio, apply to cam orthographic size if (!cam.orthographic) { cam.orthographic = true; Dj.Warnf("Camera {0} has a RatioKeeper and must be Orthographic.", gameObject.name); } int largestValidRatio = Mathf.Min(Screen.width / gameSize.x, Screen.height / gameSize.y); if (largestValidRatio < 1) { largestValidRatio = 1; } transform.localScale = new Vector3(1f * gameSize.x / gameSize.y, 1, 1); cam.orthographicSize = Screen.height * 1f / gameSize.y / largestValidRatio; //cam.orthographicSize = Screen.height * 1f / largestValidRatio; }
public IMessage Post(short opCode, object serializableObject, ResponseCallback responseCallback) { IMessage message = MessageHelper.Create(opCode, Capn.Crunchatize(serializableObject)); if (IsConnected) { Peer.SendMessage( message, responseCallback, 3, DeliveryMethod.Reliable ); } else { Dj.Warn("Post to server failed (Not connected)"); message.Status = ResponseStatus.NotConnected; } // Dj.Temp("Message status = "+message.Status); return(message); }
private void Start() { worldmap = new Dictionary <twin, TiledLevelData>(); var levelAssets = Resources.LoadAll <TextAsset>("sadgoldlevels"); foreach (var levelAsset in levelAssets) { var map_coords = levelAsset.name.Split(','); if (map_coords.Length > 1 && int.TryParse(map_coords[0], out int map_x) && int.TryParse(map_coords[1], out int map_y)) { worldmap.Add(new twin(map_x, map_y), loader.Load(levelAsset)); } else { Dj.Warnf("SadGoldXXI didn't register level {0}", levelAsset.name); } } //Dj.Tempf("Hi {0} {1}", Resources.Load("sadgoldlevels/0,0") == null, null == null); loader.SetupTileset(sprites, GetSolidTileIds(), GetSpawnTileIds()); //loader.PlaceTiles(loader.Load(firstLevel), tilemap, this.SpawnTileId); loader.PlaceTiles(currentMapLevelData, tilemap, this.SpawnTileId); }
public Bank this[string bankName] { get { if (banks == null) { SetupBanks(); } try { if (!banks.ContainsKey(bankName)) { banks.Add(bankName, transform.Find(bankName).GetComponent <Bank>()); } } catch (System.NullReferenceException exc) { Dj.Tempf("NullReference in BankLot. Debug A\nbanks - {0}\ntransform {1}\nbankName - {2}", banks, transform, bankName); throw exc; } return(banks[bankName]); } }
public void ReadChanges(Pages delta) { if (delta.address != this.address) { throw Dj.Crashf("Story '{0}' can't read from mismatched delta '{1}'.", this.address, delta.address); } if (storyteller == null) { throw Dj.Crashf("Story '{0}' has no storyteller.", this.address); } if (storyteller.isAuthor) { Dj.Warnf("Story '{0}' can't ReadChanges, it's an author.", this.address); } else { foreach (var kvp in delta.data) { this.pages.data[kvp.Key] = kvp.Value; } } }
virtual public void ChooseNextMove() { if (last_move != twin.zero && Random.value < .5f) { if (TryMoveDir(last_move)) { return; } } if (TryChooseRandomNon180Move()) { return; } if (TryMoveDir(-last_move)) { return; } Dj.Warnf("mazecreature {0} is stuck", name); }
public Pages WriteChanges() { if (storyteller == null) { throw Dj.Crashf("Story '{0}' has no storyteller.", this.address); } if (storyteller.isAuthor) { lastWrittenDelta = new Pages(); lastWrittenDelta.address = this.address; lastWrittenDelta.data = new Dictionary <string, byte[]>(); foreach (var kvp in this.pages.data) { if (lastWrittenData.TryGetValue(kvp.Key, out var lastWrittenBytes)) { if (lastWrittenBytes.Equals(kvp.Value)) { // skip } else { lastWrittenDelta.data.Add(kvp.Key, kvp.Value); } } } storyteller.Write(this); MemorizeLastWrittenPagesData(); } else { Dj.Warnf("Story '{0}' can't WriteChanges, it's attached a non-author storyteller.", this.address); } return(lastWrittenDelta); }
public void UpdateAgentCellPos(BoardAgent agent, twin cellpos) { if (agents.Contains(agent)) { if (agent2cellpos.TryGetValue(agent, out var prevpos)) { if (cellpos2agents.ContainsKey(prevpos)) { cellpos2agents[prevpos].Remove(agent); } } agent2cellpos[agent] = cellpos; if (!cellpos2agents.ContainsKey(cellpos)) { cellpos2agents[cellpos] = new HashSet <BoardAgent>(); } cellpos2agents[cellpos].Add(agent); } else { Dj.Warn("UpdateAgentCellPos called on nonadded agent"); } }
private void FixedUpdate() { if (IsWithinDistOfCentered(fullSpeedDist, offset: subtileOffset)) { var agents = 0; // what's in this cell? foreach (var agent in board.GetAgentsAt(my_cell_pos)) { agents++; if (agent is BaFoodSource) { if (pathNestToFood.Contains(this.my_cell_pos)) { // only take food if i know how to get back home with it. ((BaFoodSource)agent).TakeFood(); isCarryingFood = true; isWandering = false; isGoingHome = true; frustration = 0; } Dj.Tempf("Ant found food. Path has length {0}", this.pathNestToFood.Count); SnapMyCellPos(); } if (agent is BaNeonNest) { this.homeNest = (BaNeonNest)agent; if (isCarryingFood) { this.homeNest.ReceiveFood(); isCarryingFood = false; } isGoingHome = false; if (frustration > 100 + this.maxPathLength) { isWandering = true; } frustration = 0; if (isWandering) { this.maxPathLength += Random.Range(1, 3 + 1); // try a longer path this.pathNestToFood.Clear(); this.pathNestToFood.Add(my_cell_pos); } SnapMyCellPos(); } } bool do_wander = false; var on_path_index = pathNestToFood.IndexOf(my_cell_pos); if (isGoingHome && on_path_index > 0 && pathNestToFood.Count > 0 && TryMove(pathNestToFood[on_path_index - 1] - my_cell_pos)) { // ok, followed path! } else if (!isGoingHome && on_path_index >= 0 && on_path_index < pathNestToFood.Count - 1 && TryMove(pathNestToFood[on_path_index + 1] - my_cell_pos)) { // ok, followed path! } else { do_wander = true; } if (!isCarryingFood && pathNestToFood.Count > 0 && my_cell_pos == pathNestToFood[pathNestToFood.Count - 1]) { frustration = 1000; } if (do_wander) { ChoiceStack <twin> dirs = new ChoiceStack <twin>(); if (!isWandering) { // always prefer cells on the path! foreach (var dir in twin.compass) { if (pathNestToFood.Contains(my_cell_pos + dir)) { dirs.Add(dir); } } dirs.Lock(); } // move like a ghost. List <twin> forward_compass = new List <twin>(twin.compass); forward_compass.Remove(-lastMove); dirs.AddManyThenLock(forward_compass); lastMove = dirs.GetFirstTrue(TryMove); } } else { SetVelocityApproachTarget(); GetComponent <SpriteRenderer>().flipX = body.velocity.x < 0; if (bodyStuckFrames > 20) { frustration++; if (!isCarryingFood && frustration > 20) { isGoingHome = true; } bodyStuckFrames = 0; SnapMyCellPos(); RandomizeSubtileOffset(); if (Random.value < (isGoingHome?.75f : .25f)) { TryMove(-lastMove); } } } if (isCarryingFood) { GetComponent <BitsyAni>().spriteIds = new int[] { 54, 55, }; GetComponent <BitsyAni>().speed = 0.087f; } else { GetComponent <BitsyAni>().spriteIds = new int[] { 52, 53, }; GetComponent <BitsyAni>().speed = 0.050f; } }
////internal functions private IEnumerator StartConnection(System.Action <bool> Callback, string serverIp = "", int serverPort = 0) { if (serverIp != "") { this.ServerIp = serverIp; } if (serverPort > 0) { this.ServerPort = serverPort; } ConnectionAttemptActive = true; // Wait a fraction of a second, in case we're also starting a master server? yield return(new WaitForSeconds(0.2f)); var connection = GetConnection(); if (!connectionInitialized) { connectionInitialized = true; connection.Connected += Connected; connection.Disconnected += Disconnected; } for (int i = 0; i < MaxConnectTries; i++) { // Skip one frame yield return(null); if (connection.IsConnected) { // If connected, wait a second before checking the status //yield return new WaitForSeconds(1); //continue; // yield break; break; } // If we got here, we're not connected if (connection.IsConnecting) { Dj.Temp("Retrying to connect to server at: " + ServerIp + ":" + ServerPort); } else { Dj.Temp("Connecting to server at: " + ServerIp + ":" + ServerPort); } connection.Connect(ServerIp, ServerPort); // Give a few seconds to try and connect yield return(new WaitForSeconds(TimeToConnect)); // If we're still not connected if (!connection.IsConnected) { TimeToConnect = Mathf.Min(TimeToConnect * 2, MaxTimeToConnect); } } if (connection.IsConnected) { // try to log in Callback(true); Peer.MessageReceived += PeerOnMessageCallHandlers; } else { Dj.Temp("All connection attempts timed out"); Callback(false); } ConnectionAttemptActive = false; }
private void Connected() { TimeToConnect = MinTimeToConnect; Dj.Temp("Connected to: " + ServerIp + ":" + ServerPort); }
private void Start() { Dj.Temp("Hi"); }
private void Start() { link = GetComponent <ClientsideLink>(); sessions = new ClientsideSessions(link); link.AttemptConnection(success => { if (success) { sessions.DoLogin("droqen"); } else { Dj.Warnf("Login failed. TODO: Implement retry"); } }); sessions.AddStoryfan(Session.OPCODE, new LambdaStoryfan <Session>(session => { if (currentSession == null || currentSession.Username != session.Username) { currentSession = session; link.Post <OK>(RequestStories.OPCODE, new RequestStories { message = "Hello from " + currentSession.Username, }, reply => { }, failStatus => { Dj.Tempf("RequestStories rejected with status {0}. Recommended to either request again, or disconnect.", failStatus); }); } Dj.Tempf("My session says my name is '{0}'", currentSession.Username); })); sessions.AddStoryfan(TowerZone.OPCODE, new LambdaStoryfan <TowerZone>(zone => { currentZone = zone; visibleEntities.Clear(); })); sessions.AddStoryfan(TowerEntity.OPCODE, new LambdaStoryfan <TowerEntity>(ent => { bool its_me = false; try { if (currentSession.EntityId == ent.EntityId) { myEntity = ent; its_me = true; } } catch { } if (!its_me) { if (ent.WorldPos == currentZone.WorldPos) { visibleEntities.Add(ent); } else { visibleEntities.Remove(ent); } } })); sessions.PushStorydecoder(new TowerStoryDecoder()); }
private void DestroyAndSpawn(Collider2D collision) { if (name != "boom" || collision.name == "bulletMiniG(Clone)" || collision.name == "Bullet(Clone)" || (collision.name == "plane" && Player.noDead)) { Dj.getInstant().play(Dj.Sound.Boom); if (collision.name != "ulta(Clone)") { switch (num) { case 2: score += 10; ProgresBarUlta.addTime(0.08f); break; case 1: score += 20; ProgresBarUlta.addTime(0.1f); break; case 0: score += 30; ProgresBarUlta.addTime(0.13f); break; } } if (random.Next(100) > 95) { GameObject perk = Instantiate(p); perk.transform.position = this.gameObject.transform.position; perk.GetComponent <Rigidbody2D>().AddForce(saveRotate * 50, ForceMode2D.Force); } else if (random.Next(100) > 87) { GameObject perk = Instantiate(a); perk.transform.position = this.gameObject.transform.position; perk.GetComponent <Rigidbody2D>().AddForce(saveRotate * 50, ForceMode2D.Force); } if (num > 0) { spawnOtherAsteroid(num - 1, collision); } UI.UI.getUI().setScore(score); Destroy(this.gameObject); switch (collision.name) { case "ulta(Clone)": break; case "plane": break; default: Destroy(collision.gameObject); break; } } }
private void Start() { string s = "hello"; Dj.Temp("Begin size test"); byte[] b = Capn.Crunchatize(s); for (var i = 0; i < 5; i++) { Dj.Tempf("Iter #{0}, size {1}", i, b.Length); b = Capn.Crunchatize(b); } backupTimer = backupFreqInSeconds; worldData = new WorldData(true); link = GetComponent <ServersideLink>(); sessions = new ServersideSessions(link); sessionToTowerEntities = new Dictionary <string, TowerEntity>(); entGenerator = new EntGenerator(); decoder = new TowerStoryDecoder(); sessions.SetFunctionToAddStoryListeners <TowerEntity>(TowerEntity.OPCODE, this.GetWhoCanSeeMe_UpdateTracking); sessions.SetFunctionToAddStoryListeners <TowerZone>(TowerZone.OPCODE, this.GetWhosListeningHere); sessions.storyteller.AddStoryfan(Session.OPCODE, new LambdaStoryfan <Session>(session => { if (sessionToTowerEntities.ContainsKey(session.address)) { if (session.PeerId < 0) { // you're disconnected but your body is still in the world. // bye now! } } else { if (session.PeerId >= 0) { // you're connected but don't have a body. let's remedy that! // int EntityId = (nextTowerEntityId++); var playerTowerEntity = entGenerator.NewPlayerEntity(); //playerTowerEntity.EntityId = EntityId; //playerTowerEntity.WorldPos = twin.zero; //playerTowerEntity.Position = twin.zero; session.EntityId = playerTowerEntity.EntityId; sessionToTowerEntities[session.address] = playerTowerEntity; session.WriteChanges(); sessions.storyteller.Write(playerTowerEntity); // suddenly, you're embodied } } } )); link.SetPostHandler <RequestStories, OK>(RequestStories.OPCODE, poster => { if (sessions.UsingPeer(poster.Peer.Id, out var session)) { Dj.Tempf("Server heard request from client"); poster.Reply(); PushStoriesToSession(session); } }); link.SetPostHandler <WorldMove, OK>(WorldMove.OPCODE, poster => { try { sessions.UsingPeer(poster.Peer.Id, out var session); var ent = sessionToTowerEntities[session.address]; ent.WorldPos += poster.action.dir; ent.WriteChanges(); poster.Reply(); PushEntitiesToSession(session); } catch { poster.Reject(Barebones.Networking.ResponseStatus.Failed); } }); SetupStartingZones(); }