private static void LockExit(CharacterInstance ch, ExitData exit, string txt) { exit.Flags = exit.Flags.SetBit(ExitFlags.Locked); comm.act(ATTypes.AT_PLAIN, "You hear a faint click $T.", ch, null, txt, ToTypes.Character); comm.act(ATTypes.AT_PLAIN, "You hear a faint click $T.", ch, null, txt, ToTypes.Room); exit.SetFlagOnSelfAndReverseExit(ExitFlags.Locked); }
public BarrierMovementOutputCommand(ExitData exit, ExitUsageRequirements requirements) { this.exitData = exit; this.startingRoom = exit.Room.RoomNumber; this.destinationRoom = exit.AdjacentRoomNumber; this.requirements = requirements; }
private static bool IsPassable(ExitData exit, CharacterInstance victim) { return(exit.Flags.IsSet(ExitFlags.Closed) && (!victim.IsAffected(AffectedByTypes.PassDoor) || exit.Flags.IsSet(ExitFlags.NoPassDoor))); }
private static void CloseExit(CharacterInstance ch, ObjectInstance obj, ExitData exit, string txt) { exit.Flags = exit.Flags.SetBit(ExitFlags.Closed); var room = RepositoryManager.Instance.ROOMS.Get(obj.Value.ToList()[1]); if (room == null) { throw new InvalidDataException($"Room {obj.Value.ToList()[1]} was null"); } foreach (var rch in room.Persons) { comm.act(ATTypes.AT_ACTION, "The $d closes.", rch, null, exit.Keywords, ToTypes.Character); } var reverseExit = exit.GetReverse(); if (reverseExit != null && reverseExit.Destination == exit.Destination) { reverseExit.Flags = reverseExit.Flags.SetBit(ExitFlags.Closed); var destRoom = exit.GetDestination(RepositoryManager.Instance); foreach (var rch in destRoom.Persons) { comm.act(ATTypes.AT_ACTION, "The $d closes.", rch, null, reverseExit.Keywords, ToTypes.Character); } } // TODO Check room for traps }
public static bool valid_edge(ExitData exit) { return(exit.Destination != null #if !TRACK_THROUGH_DOORS && !exit.Flags.IsSet((int)ExitFlags.Closed) #endif && !IS_MARKED(exit.GetDestination())); }
public void SetExitPoint(int exitPoint) { if (data == null) { data = new ExitData(); } this.data.exitPoint = exitPoint; }
public static ExitData GetReverse(this ExitData exit) { if (exit.Reverse == 0) { return(null); } return(exit.GetDestination() == null ? null : exit.GetDestination().GetExit((int)exit.Reverse)); }
public static void Extract(this ExitData exit) { var room = RepositoryManager.Instance.ROOMS.Get(exit.Room_vnum); room.Exits.Remove(exit); var reverseExit = exit.GetReverse(); reverseExit.Reverse = 0; }
private static void BashExit(ExitData exit) { exit.Flags.RemoveBit(ExitFlags.Closed); if (exit.Flags.IsSet(ExitFlags.Locked)) { exit.Flags.RemoveBit(ExitFlags.Locked); } exit.Flags.SetBit(ExitFlags.Bashed); }
public void AddExitObject(ExitData exit) { if (Exits.Any(x => x.Direction == exit.Direction)) { return; } Exits.Add(exit); }
private void Update() { // timeShown.text = ((int)((Time.time - Timeline.ins.startTime) * 1000)).ToString(); if (Input.GetKeyDown(KeyCode.Escape)) { OnPauseButtonPressed(); } ExitData.CheckInput(); }
/// <summary> /// Was formerly remove_bexit_flag /// </summary> /// <param name="exit"></param> /// <param name="flag"></param> public static void RemoveFlagFromSelfAndReverseExit(this ExitData exit, ExitFlags flag) { exit.Flags = exit.Flags.RemoveBit(flag); var reverseExit = exit.GetReverse(); if (reverseExit != null && reverseExit != exit) { reverseExit.Flags = reverseExit.Flags.RemoveBit(flag); } }
/// <summary> /// Was formerly toggle_bexit_flag /// </summary> /// <param name="exit"></param> /// <param name="flag"></param> public static void ToggleFlagOnSelfAndReverseExit(this ExitData exit, ExitFlags flag) { exit.Flags = exit.Flags.ToggleBit(flag); var reverseExit = exit.GetReverse(); if (reverseExit != null && reverseExit != exit) { reverseExit.Flags = reverseExit.Flags.ToggleBit(flag); } }
public static void ExitGameSave(GameManager4x4 gameManager4x4) { BinaryFormatter formatter = new BinaryFormatter(); string path = Application.persistentDataPath + "/Exit.data"; FileStream stream = new FileStream(path, FileMode.Create); ExitData data = new ExitData(gameManager4x4); formatter.Serialize(stream, data); stream.Close(); }
private static void OpenDoor(CharacterInstance ch, ExitData exit, string arg) { if (exit.Flags.IsSet(ExitFlags.Secret) && !exit.Keywords.IsAnyEqual(arg)) { ch.Printf("You see no %s here.", arg); return; } if (CheckFunctions.CheckIfTrue(ch, !exit.Flags.IsSet(ExitFlags.IsDoor) || exit.Flags.IsSet(ExitFlags.Dig), "You can't do that.")) { return; } if (CheckFunctions.CheckIfNotSet(ch, exit.Flags, ExitFlags.Closed, "It's already open.")) { return; } if (CheckFunctions.CheckIfTrue(ch, exit.Flags.IsSet(ExitFlags.Locked) && exit.Flags.IsSet(ExitFlags.Bolted), "The bolt is locked.")) { return; } if (CheckFunctions.CheckIfSet(ch, exit.Flags, ExitFlags.Bolted, "It's bolted.")) { return; } if (CheckFunctions.CheckIfSet(ch, exit.Flags, ExitFlags.Locked, "It's locked.")) { return; } if (!exit.Flags.IsSet(ExitFlags.Secret) || exit.Keywords.IsAnyEqual(arg)) { comm.act(ATTypes.AT_ACTION, "$n opens the $d.", ch, null, exit.Keywords, ToTypes.Room); comm.act(ATTypes.AT_ACTION, "You open the $d.", ch, null, exit.Keywords, ToTypes.Character); var reverseExit = exit.GetReverse(); if (reverseExit != null) { var room = exit.GetDestination(RepositoryManager.Instance); foreach (var vch in room.Persons) { comm.act(ATTypes.AT_ACTION, "The $d opens.", vch, null, reverseExit.Keywords, ToTypes.Character); } } exit.RemoveFlagFromSelfAndReverseExit(ExitFlags.Closed); // TODO Check for traps } }
public void LoadData(ExitData data, InspectionManager manager, SpeechManager speech) { transform.position = data.position; transform.localScale = data.scale; transform.rotation = data.rotation; this.data = data; SetCursorDirection(data.iCursor); childText.text = data.title; this.manager = manager; this.speech = speech; }
public ExitData GetData() { if (data == null) { data = new ExitData(); } data.position = transform.position; data.scale = transform.localScale; data.rotation = transform.rotation; return(data); }
public void BuildRoomFromExit(ExitData exitData) { bool leftRoom = false; bool rightRoom = false; bool upRoom = false; bool downRoom = false; switch (exitData.Direction) { case ExitDirection.North: { downRoom = true; break; } case ExitDirection.South: { upRoom = true; break; } case ExitDirection.East: { leftRoom = true; break; } case ExitDirection.West: { rightRoom = true; break; } } if (!leftRoom) { leftRoom = (Random.value > 0.5f); } if (!rightRoom) { rightRoom = (Random.value > 0.5f); } if (!upRoom) { upRoom = (Random.value > 0.5f); } if (!downRoom) { downRoom = (Random.value > 0.5f); } CreateRoom(leftRoom, rightRoom, upRoom, downRoom); }
private static void UnlockDoor(CharacterInstance ch, ExitData exit, string firstArg) { if (exit.Flags.IsSet(ExitFlags.Secret) && !exit.Keywords.IsAnyEqual(firstArg)) { ch.Printf("You see no %s here.", firstArg); return; } if (CheckFunctions.CheckIfNotSet(ch, exit.Flags, ExitFlags.IsDoor, "You can't do that.")) { return; } if (CheckFunctions.CheckIfNotSet(ch, exit.Flags, ExitFlags.Closed, "It's not closed.")) { return; } if (CheckFunctions.CheckIfTrue(ch, exit.Key < 0, "It can't be unlocked.")) { return; } var key = ch.HasKey(exit.Key); if (CheckFunctions.CheckIfNullObject(ch, key, "You lack the key.")) { return; } if (CheckFunctions.CheckIfNotSet(ch, exit.Flags, ExitFlags.Locked, "It's already unlocked.")) { return; } if (!exit.Flags.IsSet(ExitFlags.Secret) || exit.Keywords.IsAnyEqual(firstArg)) { ch.SendTo("*Click*"); var count = key.Count; key.Count = 1; comm.act(ATTypes.AT_ACTION, "$n unlocks the $d with $p.", ch, key, exit.Keywords, ToTypes.Room); key.Count = count; if (exit.Flags.IsSet(ExitFlags.EatKey)) { key.Split(); key.Extract(); } exit.RemoveFlagFromSelfAndReverseExit(ExitFlags.Locked); } }
public static ExitData LuaCreateExit(string direction, long destination, string name) { var dir = EnumerationExtensions.GetEnumIgnoreCase <DirectionTypes>(direction); var newExit = new ExitData((int)dir, name) { Destination = destination, Direction = dir, Keywords = direction }; _luaManager.Proxy.CreateTable("exit"); AddLastObject(newExit); _logManager.Boot("Exit '{0}' created in direction {1} to room {2}", name, direction, destination); return(newExit); }
private static void BashSomething(CharacterInstance actor, ExitData exit, SkillData skill, string arg) { if (CheckFunctions.CheckIfSet(actor, exit.Flags, ExitFlags.Closed, "Calm down. It is already open.")) { return; } Macros.WAIT_STATE(actor, skill.Rounds); var keyword = exit.Flags.IsSet(ExitFlags.Secret) ? "wall" : exit.Keywords; var chance = !actor.IsNpc() ? Macros.LEARNED(actor, (int)skill.ID) / 2 : 90; if (exit.Flags.IsSet(ExitFlags.Locked)) { chance /= 3; } if (exit.Flags.IsSet(ExitFlags.BashProof) || actor.CurrentMovement < 15 || SmaugRandom.D100() >= chance + 4 * (actor.GetCurrentStrength() - 19)) { Bash(actor, skill, arg); return; } BashExit(exit); comm.act(ATTypes.AT_SKILL, "Crash! You bashed open the $d!", actor, null, keyword, ToTypes.Character); comm.act(ATTypes.AT_SKILL, "$n bashes open the $d!", actor, null, keyword, ToTypes.Room); skill.LearnFromSuccess(actor); var reverseExit = exit.GetReverse(); BashExit(reverseExit); var destination = exit.GetDestination(RepositoryManager.Instance); foreach (var ch in destination.Persons) { comm.act(ATTypes.AT_SKILL, "The $d crashes open!", ch, null, reverseExit.Keywords, ToTypes.Character); } actor.CauseDamageTo(actor, actor.CurrentHealth / 20, (int)skill.ID); }
// Update is called once per frame void Update() { if (data == null) { data = new ExitData(); } childText.text = data.title; if (mouseOver) { alpha += (1 - alpha) / 5f; } else { alpha += (0 - alpha) / 5f; } if (innerGroup != null) { Vector3 localPos = innerGroup.transform.localPosition; localPos.y = alpha * 5; innerGroup.transform.localPosition = localPos; innerGroup.GetComponentInChildren <Image>().sprite = manager.textureManager.GetSpritePista(data.icon_frame); #if UNITY_EDITOR if (!Application.isPlaying) { return; //or whatever script needs to be run when in edition mode. } #endif innerGroup.GetComponentInChildren <Text>().color = new Color(1, 1, 1, alpha); if (data.enabled) { innerGroup.GetComponentInChildren <Image>().color = new Color(1, 1, 1, alpha); } else { innerGroup.GetComponentInChildren <Image>().color = new Color(0, 0, 0, alpha); } } }
public void AddExit(string direction, long destination, string description) { DirectionTypes dir = Realm.Library.Common.Extensions.EnumerationExtensions.GetEnumIgnoreCase <DirectionTypes>(direction); if (Exits.Any(x => x.Direction == dir)) { return; } ExitData newExit = new ExitData((int)dir, direction) { Destination = destination, Description = description, Direction = dir, Keywords = direction }; Exits.Add(newExit); }
/// <summary> /// Checks if given exit data is ready to process - first in the process queue and exit timestamp older than current block timestamp. /// </summary> /// <param name="currency">currency of exit data to check</param> /// <param name="exitData">exit data to check</param> /// <param name="checkFirstInQueue">if false ignores predecessors check and checks only if enough time has passed. defaults to true</param> /// <returns></returns> public async Task <bool> IsExitable(string currency, ExitData exitData, bool checkFirstInQueue = true) { HexBigInteger blockNumber = await web3.Eth.Blocks.GetBlockNumber.SendRequestAsync(); var txs = await web3.Eth.Blocks.GetBlockWithTransactionsHashesByNumber.SendRequestAsync(blockNumber); bool canExit = exitData.ProcessTimestamp < txs.Timestamp.Value; if (canExit && checkFirstInQueue) { var exitId = await rootChainContract.GetStandardExitId(web3, rootChainVersion, exitData.Position, exitData.TxBytes.HexToByteArray()); var nextExitData = await rootChainContract.GetNextExit(web3, currency); canExit = nextExitData.ExitId == exitId; } return(canExit); }
public bool CompareDirStruct(ExitData input, ExitData comparable) { bool result = false; if (input.NorthExit == comparable.NorthExit) { if (input.SouthExit == comparable.SouthExit) { if (input.EastExit == comparable.EastExit) { if (input.WestExit == comparable.WestExit) { result = true; } } } } return(result); }
public static ExitData ExitGameLoad() { string path = Application.persistentDataPath + "/Exit.data"; if (File.Exists(path)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Open); ExitData data = formatter.Deserialize(stream) as ExitData; stream.Close(); return(data); } else { Debug.Log("Save File Cannot be found in " + path); return(null); } }
/// <summary> /// Starts standard exit on the root chain of given utxo /// </summary> /// <param name="profileFrom">profile of the sender</param> /// <param name="utxoPositions">exit utxo position list</param> /// <param name="exitBond">exit transaction bond per utxo</param> /// <param name="tokenSource">cancellation token source</param> /// <returns>list of exit data (or null if unsuccessful) per each utxoPosition given</returns> public async Task <ExitData[]> StartStandardExitBulk(Profile profileFrom, BigInteger[] utxoPositions, BigInteger?exitBond = null, CancellationTokenSource tokenSource = null) { if (rootChainContract != null) { ExitData[] exitsData = new ExitData[utxoPositions.Length]; BCTransaction[] txs = new BCTransaction[utxoPositions.Length]; //submit all transactions for (int i = 0; i < utxoPositions.Length; ++i) { BigInteger utxoPosition = utxoPositions[i]; ExitData exitData = await plasmaApiService.GetExitData(utxoPosition); var transaction = await rootChainContract.StartStandardExit(web3, profileFrom.ID, exitData, exitBond); string signedTransaction = await SignTransaction(profileFrom, transaction); txs[i] = await SubmitTransactionOnRootChain(web3, signedTransaction); exitsData[i] = exitData; } BigInteger maxUtxoPosition = exitsData.Where(x => x != null).Max(x => x.Position); BigInteger processTimestamp = await rootChainContract.GetExitableTimestamp(web3, maxUtxoPosition); //now wait for all transaction to finish for (int i = 0; i < utxoPositions.Length; ++i) { var receipt = await txs[i].Wait(tokenSource); if (receipt.Status.Value != 1) { exitsData[i] = null; } else { exitsData[i].ProcessTimestamp = processTimestamp; } } return(exitsData); } return(null); }
/// <summary> /// Starts standard exit on the root chain of given utxo /// </summary> /// <param name="profileFrom">profile of the sender</param> /// <param name="utxoPosition">exit utxo position</param> /// <param name="exitBond">exit transaction bond</param> /// <param name="tokenSource">cancellation token source</param> /// <returns>exit data (null if unsuccessful)</returns> public async Task <ExitData> StartStandardExit(Profile profileFrom, BigInteger utxoPosition, BigInteger?exitBond = null, CancellationTokenSource tokenSource = null) { if (rootChainContract != null) { ExitData exitData = await plasmaApiService.GetExitData(utxoPosition); var transaction = await rootChainContract.StartStandardExit(web3, profileFrom.ID, exitData, exitBond); string signedTransaction = await SignTransaction(profileFrom, transaction); var receipt = await(await SubmitTransactionOnRootChain(web3, signedTransaction)).Wait(tokenSource); if (receipt.Status.Value == 1) { exitData.ProcessTimestamp = await rootChainContract.GetExitableTimestamp(web3, exitData.Position); return(exitData); } } return(null); }
public void ExitLoad(int index) { ExitData data = SavingSystem.ExitGameLoad(); string Tile = "Tiles"; if (PlayerPrefs.GetInt("Theme") == 0 || PlayerPrefs.GetInt("FirstTime") == 1) { foreach (Transform tile in PlayGrid) { Destroy(tile.gameObject); } } else if (PlayerPrefs.GetInt("Theme") == 1) { foreach (Transform tile in PlayGrid) { Destroy(tile.gameObject); } } for (i = 0; i < data.exitX.Count; i++) { x = data.exitX[index]; y = data.exitY[index]; Grid[x, y] = (GameObject)Instantiate(Resources.Load(Tile), new Vector2(data.exitX[index] * 1.1f, data.exitY[index] * 1.1f), Quaternion.identity); if (PlayerPrefs.GetInt("Theme") == 0 || PlayerPrefs.GetInt("FirstTime") == 1) { Grid[x, y].transform.SetParent(PlayGrid); } else if (PlayerPrefs.GetInt("Theme") == 1) { Grid[x, y].transform.SetParent(PlayGrid); } Grid[x, y].GetComponent <Tiles>().Number = data.exitTileNumber[index]; index++; } theScore = data.exitScore; }
/*public static void delete_room(RoomTemplate room) * { * RoomTemplate limbo = RepositoryManager.Instance.ROOMS.CastAs<Repository<long, RoomTemplate>>().Get(VnumConstants.ROOM_VNUM_LIMBO); * * CharacterInstance ch; * while ((ch = room.Persons.FirstOrDefault()) != null) * { * if (!ch.IsNpc()) * { * room.RemoveFrom(ch); * limbo.AddTo(ch); * } * else * CharacterInstanceExtensions.Extract(ch, true); * } * * foreach (CharacterInstance och in RepositoryManager.Instance.CHARACTERS.CastAs<Repository<long, CharacterInstance>>().Values) * { * if (och.PreviousRoom == room) * och.PreviousRoom = och.CurrentRoom; * if (och.SubState == CharacterSubStates.RoomDescription * && och.DestinationBuffer == room) * { * ch.SetColor("The room is no more.\r\n", och); * build.stop_editing(och); * och.SubState = CharacterSubStates.None; * och.DestinationBuffer = null; * } * else if (och.SubState == CharacterSubStates.RoomExtra * && och.DestinationBuffer != null) * { * if (room.ExtraDescriptions.Any(e => e == och.DestinationBuffer)) * { * ch.SetColor("The room is no more.\r\n", och); * build.stop_editing(och); * och.SubState = CharacterSubStates.None; * och.DestinationBuffer = null; * } * } * } * * room.Contents.ForEach(handler.extract_obj); * reset.wipe_resets(room); * room.ExtraDescriptions.Clear(); * room.Affects.Clear(); * room.PermanentAffects.Clear(); * room.Exits.ForEach(x => handler.extract_exit(room, x)); * room.MudProgActs.Clear(); * room.MudProgs.Clear(); * RepositoryManager.Instance.ROOMS.CastAs<Repository<long, RoomTemplate>>().Delete(room.Vnum); * * // TODO: Room hash stuff here, but can be removed? * } * * public static void delete_obj(ObjectTemplate obj) * { * RepositoryManager.Instance.OBJECTS.CastAs<Repository<long, ObjectInstance>>().Values.Where(x => x.ObjectIndex == obj).ToList().ForEach(handler.extract_obj); * obj.ExtraDescriptions.Clear(); * obj.Affects.Clear(); * obj.MudProgs.Clear(); * RepositoryManager.Instance.OBJECT_INDEXES.CastAs<Repository<long, ObjectTemplate>>().Delete(obj.Vnum); * * // TODO Object hash stuff here, but can be removed? * } * * public static void delete_mob(MobTemplate mob) * { * foreach (CharacterInstance ch in RepositoryManager.Instance.CHARACTERS.CastAs<Repository<long, CharacterInstance>>().Values) * { * if (ch.MobIndex == mob) * CharacterInstanceExtensions.Extract(ch, true); * else if (ch.SubState == CharacterSubStates.MProgEditing * && ch.DestinationBuffer != null) * { * if (mob.MudProgs.Any(mp => mp == ch.DestinationBuffer)) * { * ch.SetColor("Your victim has departed.\r\n", ch); * build.stop_editing(ch); * ch.DestinationBuffer = null; * ch.SubState = CharacterSubStates.MProgEditing; * } * } * } * * mob.MudProgs.Clear(); * if (mob.Shop != null) * SHOP.Remove(mob.Shop); * if (mob.RepairShop != null) * REPAIR.Remove(mob.RepairShop); * RepositoryManager.Instance.MOBILE_INDEXES.CastAs<Repository<long, MobTemplate>>().Delete(mob.Vnum); * * // TODO Mob hash stuff here, but can be removed? * }*/ public static ExitData make_exit(RoomTemplate room, RoomTemplate to_room, int door) { var newExit = new ExitData(door, "An exit") { Direction = EnumerationExtensions.GetEnum <DirectionTypes>(door), Room_vnum = room.ID, Destination = to_room.ID, Distance = 1, Key = -1 }; var reverseExit = to_room.GetExitTo(LookupConstants.rev_dir[door], room.ID); if (reverseExit != null) { reverseExit.Reverse = newExit.ID; newExit.Reverse = reverseExit.ID; } var broke = room.Exits.Any(exit => door < (int)exit.Direction); if (room.Exits == null) { room.Exits.Add(newExit); } else { if (broke && reverseExit != null) { room.Exits.ToList().Insert(room.Exits.First() == reverseExit ? 0 : 1, newExit); return(newExit); } } return(newExit); }