public void ReturnRune(Rune rune) { int index = Runes.IndexOf(rune); var gridSpot = Slots[index]; rune.MoveTo(gridSpot); }
public void AddRune(Rune rune) { if (runesAdded.Count < 2) { runesAdded.Add(rune); } }
Ritual(string name, int priority, Rune[] runes, Action effect, string animation) { this.name = name; this.priority = priority; this.runes = runes; this.effect = effect; this.animation = animation; }
public void useRunes(Rune[] used) { foreach (Rune r in used) { runeBucket.Remove(r); } sprRend.sprite = cast; GetComponent<Animator>().enabled = false; Invoke("Reanimate", 1.5f); }
private int RuneCount(Rune[] runes, Rune rune) { int count = 0; foreach (Rune r in runes) { if (r == rune) { count++; } } return count; }
public bool PlaceRuneInHand(Rune rune, int position) { Rune runeToDelete; if (_runesInHand.TryGetValue(position, out runeToDelete)) _runesInHand.Remove(position); rune.PositionInHand = position; _runesInHand.Add(position, rune); Logger.Debug("Rune placed at " + position); return true; }
public bool Castable(Rune[] bucket) { foreach (Rune r in System.Enum.GetValues(typeof(Rune))) { int min = RuneCount(runes, r); if (RuneCount(bucket, r) < min){ return false; } } return true; }
// Use this for initialization void Start () { state = new bool[10]; GameObject runeObject = gameObject.transform.Find ("Rune").gameObject; if (runeObject != null) { rune = runeObject.GetComponent<Rune> (); } GameObject runeObject2 = gameObject.transform.Find ("Candles").gameObject; if (runeObject2 != null) { candles = runeObject2.GetComponent<Candles> (); } changed (); }
private void MainForm_Load(object sender, EventArgs e) { client = ClientChooser.ShowBox(); if (client == null || !client.LoggedIn) { MessageBox.Show("You must have at least one client open and logged in to start this program."); Application.Exit(); } else { rune = RuneChooser.ShowBox(); notifyIcon.Icon = new System.Drawing.Icon(GetType(), "icon.ico"); start(); } }
public RunePage(RiotSharp.SummonerEndpoint.RunePage runePage) { InitializeComponent(); Rune = LoadJson(); images = new Image[] { imgRune1, imgRune2, imgRune3, imgRune4, imgRune5, imgRune6, imgRune7, imgRune8, imgRune9, imgRune10, imgRune11, imgRune12, imgRune13, imgRune14, imgRune15, imgRune16, imgRune17, imgRune18, imgRune19, imgRune20, imgRune21, imgRune22, imgRune23, imgRune24, imgRune25, imgRune26, imgRune27, imgRune28, imgRune29, imgRune30 }; //labelName.Content = runePage.Name; SetupImages(); SetupRunePage(runePage); }
public bool AddRune(Rune rune) { var slot = Slots.FirstOrDefault(s => s.Rune == null); if (slot == null) { return false; } rune.MoveTo(slot); if (Slots.All(s => s.Rune != null)) { CompleteButton.gameObject.SetActive(true); Verbal.Runes = Slots.Select(s => s.Rune.Prefab).ToList(); CompleteButton.GetComponent<EndVerbalButton>().Verbal = Verbal; } else { CompleteButton.gameObject.SetActive(false); } return true; }
public static void TryCreate_SurrogateChars_Valid(char highSurrogate, char lowSurrogate, int expectedValue) { Assert.True(Rune.TryCreate(highSurrogate, lowSurrogate, out Rune result)); Assert.Equal(expectedValue, result.Value); }
public static void IsUpper(UnicodeInfoTestData testData) { Assert.Equal(testData.IsUpper, Rune.IsUpper(testData.ScalarValue)); }
public static void IsWhiteSpace(UnicodeInfoTestData testData) { Assert.Equal(testData.IsWhiteSpace, Rune.IsWhiteSpace(testData.ScalarValue)); }
public static void GetUnicodeCategory(UnicodeInfoTestData testData) { Assert.Equal(testData.UnicodeCategory, Rune.GetUnicodeCategory(testData.ScalarValue)); }
public static void IsPunctuation(UnicodeInfoTestData testData) { Assert.Equal(testData.IsPunctuation, Rune.IsPunctuation(testData.ScalarValue)); }
private bool EatAble(Rune n, Rune o) { if (n.ResData.type == RUNE_EXP && o.ResData.type != RUNE_EXP) { return false; } if (o.ResData.type == RUNE_EXP && n.ResData.type != RUNE_EXP) { return true; } if (n.ResData.quality < o.ResData.quality) { return false; } if (n.ResData.quality > o.ResData.quality) { return true; } if (n.currExp >= o.currExp) { return true; } return false; }
[InlineData(new byte[] { 0xF0, 0x9F, 0x98, }, OperationStatus.NeedMoreData, 0xFFFD, 3)] // [ F0 9F 98 ] is valid 3-byte start of 4-byte sequence public static void DecodeLastFromUtf8(byte[] data, OperationStatus expectedOperationStatus, int expectedRuneValue, int expectedBytesConsumed) { Assert.Equal(expectedOperationStatus, Rune.DecodeLastFromUtf8(data, out Rune actualRune, out int actualBytesConsumed)); Assert.Equal(expectedRuneValue, actualRune.Value); Assert.Equal(expectedBytesConsumed, actualBytesConsumed); }
public static void InitRune(Rune rune, List <Nodes.Connection> result) { for (int i = 0; i < result.Count; i++) //add all the lines to rune.lines { if (result[i].tag != NodeTags.None) { continue; } //Skip it, it's a tagged node entry rune.lines.Add(result[i].line); } /* * //Print result * string s = "Result printout: \n"; * for (int i = 0; i < result.Count; i++)//Add all the nodes to rune.nodes * { * s += "\n" + i; * s += ", x: " + result[i].x; * s += ", y: " + result[i].y; * s += ", z: " + result[i].z; * s += ", x2: " + result[i].x2; * s += ", y2: " + result[i].y2; * s += ", z2: " + result[i].z2; * s += ", n1: " + (result[i].n1 != null); * s += ", n2: " + (result[i].n2 != null); * s += ", line: " + (result[i].line != null); * s += ", tag: " + result[i].tag; * } * Debug.Log(s); */ for (int i = 0; i < result.Count; i++) //Add all the nodes to rune.nodes { bool doubles = false; NodeAndTag nodeAndTag; if (result[i].n1 != null) { for (int a = 0; a < rune.nodes.Count; a++) { if (rune.nodes[a].node.uId == result[i].n1.uId) { doubles = true; } } if (!doubles) { nodeAndTag = new NodeAndTag(); nodeAndTag.node = result[i].n1; nodeAndTag.tag = nodeAndTag.node.tag; rune.nodes.Add(nodeAndTag); } } if (result[i].n2 != null) { doubles = false; for (int a = 0; a < rune.nodes.Count; a++) { if (rune.nodes[a].node.uId == result[i].n2.uId) { doubles = true; } } if (!doubles) { nodeAndTag = new NodeAndTag(); nodeAndTag.node = result[i].n2; nodeAndTag.tag = nodeAndTag.node.tag; rune.nodes.Add(nodeAndTag); } } } //go through all lines in this rune for (int i = 0; i < rune.lines.Count; i++) { rune.lines[i].rune = rune; //go through all nodes used by this line for (int a = 0; a < rune.lines[i].points.Count; a++) { rune.lines[i].points[a].node.rune = rune; rune.lines[i].points[a].node.usedByRune = true; } } }
public static void HandleRuneAction(Rune rune) { switch (rune.type) { case RuneTypes.RuneOfHarvest: if (Time.timeSinceLevelLoad >= (rune.timeSet + 5)) { rune.timeSet = Time.timeSinceLevelLoad; Nodes.Node n = rune.GetNodeForTag(NodeTags.SpawnPointNode); if (n != null) { if (n.mana == null) //If this node is clear, create mana on it. { Debug.Log("Spawned! Time: " + Time.timeSinceLevelLoad + ", TimeSet: " + rune.timeSet + ", delay: 5"); Manas.CreateMana(n, rune.manaType); } } } //Push mana Nodes.Node n1 = null; Nodes.Node n2 = null; n1 = rune.GetNodeForTag(NodeTags.SpawnPointNode); n2 = rune.GetNodeForTag(NodeTags.PassToNode); PushMana(n1, n2); break; case RuneTypes.RuneOfMomentum: //Push mana PushMana(rune.GetNodeForTag(NodeTags.ConveyanceNode1), rune.GetNodeForTag(NodeTags.CenterNode)); PushMana(rune.GetNodeForTag(NodeTags.CenterNode), rune.GetNodeForTag(NodeTags.ConveyanceNode2)); PushMana(rune.GetNodeForTag(NodeTags.ConveyanceNode2), rune.GetNodeForTag(NodeTags.ConveyanceNode3)); PushMana(rune.GetNodeForTag(NodeTags.ConveyanceNode3), rune.GetNodeForTag(NodeTags.ConveyanceNode4)); PushMana(rune.GetNodeForTag(NodeTags.ConveyanceNode4), rune.GetNodeForTag(NodeTags.ConveyanceNode5)); PushMana(rune.GetNodeForTag(NodeTags.ConveyanceNode5), rune.GetNodeForTag(NodeTags.ConveyanceNode6)); //Is there mana on me? /* * nodeIndex = Nodes.GetIndexForNodePos(positionsOfInterest[0]); * if (nodeIndex != -1)//If this node exists (it probably does, it has lines on it) * { * if (Nodes.nodes[nodeIndex].mana != null) * { * Nodes.nodes[nodeIndex].mana.momentum = 2; * } * } * nodeIndex = Nodes.GetIndexForNodePos(positionsOfInterest[1]); * if (nodeIndex != -1)//If this node exists (it probably does, it has lines on it) * { * if (Nodes.nodes[nodeIndex].mana != null) * { * Nodes.nodes[nodeIndex].mana.momentum = 2; * } * }*/ break; } }
public async Task AddRuneAsync(Rune rune) { await this.runeRepo.AddAsync(rune); await this.runeRepo.SaveChangesAsync(); }
// Update is called once per frame void Update () { //put in new rune if (Input.GetMouseButtonDown (0)) { //click on inventory for (int i = 0; i < 4; i++) { if (runeList [i] != null) { if (isNear (runeList [i].transform.position, Input.mousePosition) && playerStatus.runeCounts [i] > 0) { current = runeList [i]; runeList [i] = null; //pick up a rune: -1 playerStatus.RemoveRuneFromInventory (current.id); break; } } } // click on major slots for (int i = 0; i < 8; i++) { if (isNear (slots [i], Input.mousePosition) && slots [i].rune != null) { current = slots [i].rune; slots [i].rune = null; break; } } // click on minor slots for (int i = 0; i < 8; i++) { //Debug.Log("Distance :") if (isNear (minorSlots [i], Input.mousePosition) && minorSlots [i].rune != null) { current = minorSlots [i].rune; // sfx.enabled = true; minorSlots [i].rune = null; break; } } if (current != null) { runeSFX [current.id].enabled = true; } } if (Input.GetMouseButton (0) && current != null) { //make sure the rune is always on top, use water symbol since it's the last element on canvas current.img.transform.SetParent (topLayer.transform); current.transform.position = Input.mousePosition; } if (Input.GetMouseButtonUp (0)) { if (current != null) { runeSFX [current.id].enabled = false; //check minor slots for (int i = 0; i < 8; i++) { if (isNear (minorSlots [i], Input.mousePosition)) { // Rune temp = (Rune)Instantiate (current, minorSlots [i].transform.position, Quaternion.identity); // temp.transform.SetParent (minorSlots [i].transform); current.transform.SetParent (minorSlots [i].transform); if (minorSlots [i].rune != null) { playerStatus.AddRuneToInventory (minorSlots [i].rune.id); runeList [minorSlots [i].rune.id] = minorSlots [i].rune; runeList [minorSlots [i].rune.id].transform.position = runePositions [minorSlots [i].rune.id]; } else if (playerStatus.runeCounts [current.id] > 0) { Debug.Log ("new rune generated in runePosition[ " + current.id + " ]"); runeList [current.id] = (Rune)Instantiate (current, runePositions [current.id], current.transform.rotation); runeList [current.id].transform.position = runePositions [current.id]; runeList [current.id].transform.SetParent (runeListSlots [current.id].transform); } minorSlots [i].rune = current; minorSlots [i].rune.transform.position = minorSlots [i].transform.position; // holding--; // current.transform.position = runePositions [current.id]; current = null; break; } } //check major slots for (int i = 0; i < 8; i++) { if (isNear (slots [i], Input.mousePosition)) { // Rune temp = (Rune)Instantiate (current, slots [i].transform.position, Quaternion.identity); // temp.transform.SetParent (slots [i].transform); current.transform.SetParent (slots [i].transform); if (slots [i].rune != null) { //move the rune on the magical circle back to inventory playerStatus.AddRuneToInventory (slots [i].rune.id); runeList [slots [i].rune.id] = slots [i].rune; runeList [slots [i].rune.id].transform.position = runePositions [slots [i].rune.id]; } else if (playerStatus.runeCounts [current.id] > 0) { Debug.Log ("new rune generated in runePosition[ " + current.id + " ]"); runeList [current.id] = (Rune)Instantiate (current, runePositions [current.id], current.transform.rotation); runeList [current.id].transform.position = runePositions [current.id]; runeList [current.id].transform.SetParent (runeListSlots [current.id].transform); } slots [i].rune = current; slots [i].rune.transform.position = slots [i].transform.position; // current.transform.position = runePositions [current.id]; current = null; break; } } } //release rune from hand will always increase the inventory, no matter where it goes, handle the drop on circle somewhere else if (current != null) { playerStatus.AddRuneToInventory (current.id); current.transform.position = runePositions [current.id]; runeList [current.id] = current; current = null; } for (int i = 0; i < 4; i++) { // setTextByIndex (i); } } }
/// <summary> /// Trim and replace multiple <paramref name="rune"/> with a single <paramref name="rune"/> /// </summary> /// <param name="string">String to clean</param> /// <param name="rune">The rune to clean</param> /// <returns>Cleaned up string</returns> public static String Clean(this String @string, Rune rune) { Guard.NotNull(@string, nameof(@string)); return(@string.AsSpan().Clean(rune)); }
/// <summary> /// Trim and replace multiple <paramref name="rune"/> with a single <paramref name="rune"/> /// </summary> /// <param name="span"><see cref="Span{T}"/> of <see cref="Char"/> to clean</param> /// <param name="rune">The rune to clean</param> /// <returns>Cleaned up string</returns> public static String Clean(this Span <Char> span, Rune rune) => ((ReadOnlySpan <Char>)span).Clean(rune);
//增加一个符文到背包 public void AddRuneToBag(string uuid, int idx, int resID, int exp) { LoggerHelper.Debug("add idx: " + idx + " " + resID + " " + exp); Rune rune = new Rune(uuid, resID, exp); rune.index = idx; rune.inBag = true; bag[rune.index] = rune; //todo更新UI string name = "no name"; if (LanguageData.dataMap.ContainsKey(rune.ResData.name)) { name = LanguageData.dataMap[rune.ResData.name].content; name = GetRuneNameString(rune.ResData.quality, name); } IconData _t = IconData.dataMap[rune.ResData.icon]; if (idx < 16) { if (wishCnt <= 0) { if (DragonUIViewManager.Instance != null) { DragonUIViewManager.Instance.AddDragonItem(rune.ResData.level, name, idx, _t.path, _t.color); } wishCnt = 0; } else { wishCnt--; if (DragonUIViewManager.Instance != null) { DragonUIViewManager.Instance.WishAddDragonItem(rune.ResData.level, name, idx, _t.path, _t.color); } } } else { if (RuneUIViewManager.Instance == null) { return; } RuneUIViewManager.Instance.AddPackageGridItem(rune.ResData.level, name, idx % 16, _t.path, _t.color); } }
public static void TryCreate_UInt32_Invalid(int scalarValue) { Assert.False(Rune.TryCreate((uint)scalarValue, out Rune result)); Assert.Equal(0, result.Value); }
[InlineData(GRINNING_FACE_UTF16 + EURO_SYMBOL_UTF16)] // 4-byte surrogate char pair, cannot read next DWORD, falls down to slow drain loop public void ToBytes_WithLargeValidBuffers(string utf16Input) { // These test cases are for the "fast processing" code which is the main loop of TranscodeToUtf8, // so inputs should be at least 2 chars. Assert.True(utf16Input.Length >= 2); // We're going to run the tests with destination buffer lengths ranging from 0 all the way // to buffers large enough to hold the full output. This allows us to test logic that // detects whether we're about to overrun our destination buffer and instead returns DestinationTooSmall. Rune[] enumeratedScalars = utf16Input.EnumerateRunes().ToArray(); // 0-length buffer test ToBytes_Test_Core( utf16Input: utf16Input, destinationSize: 0, replaceInvalidSequences: false, isFinalChunk: false, expectedOperationStatus: OperationStatus.DestinationTooSmall, expectedNumCharsRead: 0, expectedUtf8Transcoding: ReadOnlySpan <byte> .Empty); int expectedNumCharsConsumed = 0; byte[] concatenatedUtf8 = Array.Empty <byte>(); for (int i = 0; i < enumeratedScalars.Length; i++) { Rune thisScalar = enumeratedScalars[i]; // provide partial destination buffers all the way up to (but not including) enough to hold the next full scalar encoding for (int j = 1; j < thisScalar.Utf8SequenceLength; j++) { ToBytes_Test_Core( utf16Input: utf16Input, destinationSize: concatenatedUtf8.Length + j, replaceInvalidSequences: false, isFinalChunk: false, expectedOperationStatus: OperationStatus.DestinationTooSmall, expectedNumCharsRead: expectedNumCharsConsumed, expectedUtf8Transcoding: concatenatedUtf8); } // now provide a destination buffer large enough to hold the next full scalar encoding expectedNumCharsConsumed += thisScalar.Utf16SequenceLength; concatenatedUtf8 = concatenatedUtf8.Concat(ToUtf8(thisScalar)).ToArray(); ToBytes_Test_Core( utf16Input: utf16Input, destinationSize: concatenatedUtf8.Length, replaceInvalidSequences: false, isFinalChunk: false, expectedOperationStatus: (i == enumeratedScalars.Length - 1) ? OperationStatus.Done : OperationStatus.DestinationTooSmall, expectedNumCharsRead: expectedNumCharsConsumed, expectedUtf8Transcoding: concatenatedUtf8); } // now throw lots of ASCII data at the beginning so that we exercise the vectorized code paths utf16Input = new string('x', 64) + utf16Input; concatenatedUtf8 = utf16Input.EnumerateRunes().SelectMany(ToUtf8).ToArray(); ToBytes_Test_Core( utf16Input: utf16Input, destinationSize: concatenatedUtf8.Length, replaceInvalidSequences: false, isFinalChunk: true, expectedOperationStatus: OperationStatus.Done, expectedNumCharsRead: utf16Input.Length, expectedUtf8Transcoding: concatenatedUtf8); // now throw some non-ASCII data at the beginning so that we *don't* exercise the vectorized code paths utf16Input = WOMAN_CARTWHEELING_MEDSKIN_UTF16 + utf16Input[64..];
public void addRune(Rune rune) { if (currentView == currentPhase) { if (currentPhase == Phase.Player1) { player1.getTurn().AddRune(rune); } else { player2.getTurn().AddRune(rune); } runeDisplay(); } }
protected abstract Rune UpdateCore(int id, Rune newRune);
[InlineData(new char[] { '\ud800', '\u1234' }, OperationStatus.InvalidData, 0xFFFD, 1)] // standalone high surrogate public static void DecodeFromUtf16(char[] data, OperationStatus expectedOperationStatus, int expectedRuneValue, int expectedCharsConsumed) { Assert.Equal(expectedOperationStatus, Rune.DecodeFromUtf16(data, out Rune actualRune, out int actualCharsConsumed)); Assert.Equal(expectedRuneValue, actualRune.Value); Assert.Equal(expectedCharsConsumed, actualCharsConsumed); }
protected abstract Rune AddCore(Rune rune);
public static void GetNumericValue(UnicodeInfoTestData testData) { Assert.Equal(testData.NumericValue, Rune.GetNumericValue(testData.ScalarValue)); }
public void StartGameRune(Rune rune, System.Action action) { GetComponent <Image>().enabled = true; text.SetActive(true); action(); }
public static void IsLetterOrDigit(UnicodeInfoTestData testData) { Assert.Equal(testData.IsLetterOrDigit, Rune.IsLetterOrDigit(testData.ScalarValue)); }
// Set Player Bonuses based on Player's Runes // 0 is sword, 1 is bow, 2 is armour public void SetBonuses(int _runeType) { switch (_runeType) { case 0: { // Set for sword // Var to keep track of bonus int swordBonus = 0; // Check first Rune slot if it is empty if (!RuneMenu.Instance.m_SwordSlot_1.IsEmpty()) { // Cast item as a sword rune Rune swordRune = (Rune)RuneMenu.Instance.m_SwordSlot_1.m_item.Peek(); // Add sword bonus to the sword bonus var swordBonus += swordRune.m_runePower; } // Check second rune slot if it is empty if (!RuneMenu.Instance.m_SwordSlot_2.IsEmpty()) { // Cast item as a sword rune Rune swordRune = (Rune)RuneMenu.Instance.m_SwordSlot_2.m_item.Peek(); // Add sword bonus to the sword bonus var swordBonus += swordRune.m_runePower; } // Set sword bonus m_swordBonus = swordBonus; string newBonusText = "Sword Damage Bonus: +" + m_swordBonus.ToString(); if (m_swordBonusText == null) { // Set Sword Bonus Text m_swordBonusText = GameObject.FindGameObjectWithTag("SwordBonusText").GetComponent <Text>(); } m_swordBonusText.text = newBonusText; Debug.Log("Sword WHAT"); break; } case 1: { // Set for Bow // Var to keep track of bonus int bowBonus = 0; // Check first Rune slot if it is empty if (!RuneMenu.Instance.m_BowSlot_1.IsEmpty()) { // Cast item as a sword rune Rune bowRune = (Rune)RuneMenu.Instance.m_BowSlot_1.m_item.Peek(); // Add sword bonus to the sword bonus var bowBonus += bowRune.m_runePower; } // Check second rune slot if it is empty if (!RuneMenu.Instance.m_BowSlot_2.IsEmpty()) { // Cast item as a sword rune Rune bowRune = (Rune)RuneMenu.Instance.m_BowSlot_2.m_item.Peek(); // Add sword bonus to the sword bonus var bowBonus += bowRune.m_runePower; } // Set bow bonus m_bowBonus = bowBonus; string newBonusText = "Bow Damage Bonus: +" + m_bowBonus.ToString(); if (m_bowBonusText == null) { // Set Bow Bonus Text m_bowBonusText = GameObject.FindGameObjectWithTag("BowBonusText").GetComponent <Text>(); } m_bowBonusText.text = newBonusText; break; } case 2: { // Set for Armour // Var to keep track of bonus int armourBonus = 0; //Debug.Log("I AM kinda okay"); // Check first Rune slot if it is empty if (!RuneMenu.Instance.m_ArmourSlot_1.IsEmpty()) { // Cast item as a sword rune Rune armourRune = (Rune)RuneMenu.Instance.m_ArmourSlot_1.m_item.Peek(); Debug.Log(armourRune); // Add sword bonus to the sword bonus var armourBonus += armourRune.m_runePower; } // Check second rune slot if it is empty if (!RuneMenu.Instance.m_ArmourSlot_2.IsEmpty()) { Debug.Log("I AM getting somewhere okay 2"); // Cast item as a sword rune Rune armourRune = (Rune)RuneMenu.Instance.m_ArmourSlot_2.m_item.Peek(); // Add sword bonus to the sword bonus var armourBonus += armourRune.m_runePower; Debug.Log(armourRune.m_runePower); } // Set health bonus m_healthBonus = armourBonus; string newBonusText = "Health Bonus: +" + m_healthBonus.ToString(); // Check if the text is null if (m_armourBonusText == null) { // Set Armour Bonus Text m_armourBonusText = GameObject.FindGameObjectWithTag("ArmourBonusText").GetComponent <Text>(); } m_armourBonusText.text = newBonusText; break; } default: { break; } } }
public static void IsSymbol(UnicodeInfoTestData testData) { Assert.Equal(testData.IsSymbol, Rune.IsSymbol(testData.ScalarValue)); }
public void addRune(Rune rune) { this.runes.Add (rune); }
public static void IsValid(int scalarValue, bool expectedIsValid) { Assert.Equal(expectedIsValid, Rune.IsValid(scalarValue)); Assert.Equal(expectedIsValid, Rune.IsValid((uint)scalarValue)); }
/// <summary> /// Creates a new <see cref="VirtualChar"/> from the provided <paramref name="rune"/>. This operation cannot /// fail. /// </summary> public static VirtualChar Create(Rune rune, TextSpan span) => new(rune, surrogateChar : default, span);
public static void TryCreate_SurrogateChars_Invalid(char highSurrogate, char lowSurrogate) { Assert.False(Rune.TryCreate(highSurrogate, lowSurrogate, out Rune result)); Assert.Equal(0, result.Value); }
public void TakeRune(Rune rune) { Rune = rune; rune.Slot = this; }
public static void TryCreate_UInt32_Valid(GeneralTestData testData) { Assert.True(Rune.TryCreate((uint)testData.ScalarValue, out Rune result)); Assert.Equal(testData.ScalarValue, result.Value); }
public static void NonGenericCompareTo_GivenNonRuneArgument_ThrowsArgumentException() { IComparable rune = new Rune(0); Assert.Throws <ArgumentException>(() => rune.CompareTo(0 /* int32 */)); }
public void Testing() { //Logger.logLvl = Logger.Type.TRACE; //Testing ! Rune r1 = new Rune(Element.GetElement(0), -1, 0); _runesInHand.Add(r1.PositionInHand, r1); Rune r2 = new Rune(Element.GetElement(1), -1, 1); _runesInHand.Add(r2.PositionInHand, r2); Rune r3 = new Rune(Element.GetElement(2), -1, 2); _runesInHand.Add(r3.PositionInHand, r3); Rune r4 = new Rune(Element.GetElement(2), -1, 3); _runesInHand.Add(r4.PositionInHand, r4); Rune r5 = new Rune(Element.GetElement(3), -1, 4); _runesInHand.Add(r5.PositionInHand, r5); Rune r6 = new Rune(Element.GetElement(3), -1, 5); _runesInHand.Add(r6.PositionInHand, r6); //LogHand(); //PlaceRuneOnBoard(0, 12); //PlaceRuneOnBoard(1, 13); //PlaceRuneOnBoard(2, 14); //PlaceRuneOnBoard(3, 6); //PlaceRuneOnBoard(4, 5); //RemoveRuneFromBoard(4); //RemoveAllRunes(); //ChangeRunePosition(4, 15); //List<int> explored = new List<int>(); //Debug.Log("Connected to center ? " + IsConnectedToCenter(0, ref explored, ref runesOnBoard)); //ChangeRunePosition(4, 5); LogHand(); LogRunesOnBoard(); //Logger.Debug("Can launch spell ? " + CanLaunchSpell()); }
/// <summary> /// Returns <paramref name="value"/> if it is null or contains only well-formed UTF-8 data; /// otherwises allocates a new <see cref="Utf8String"/> instance containing the same data as /// <paramref name="value"/> but where all invalid UTF-8 sequences have been replaced /// with U+FFFD. /// </summary> public static Utf8String ValidateAndFixupUtf8String(Utf8String value) { if (value.Length == 0) { return(value); } ReadOnlySpan <byte> valueAsBytes = value.AsBytes(); int idxOfFirstInvalidData = GetIndexOfFirstInvalidUtf8Sequence(valueAsBytes, out _); if (idxOfFirstInvalidData < 0) { return(value); } // TODO_UTF8STRING: Replace this with the faster implementation once it's available. // (The faster implementation is in the dev/utf8string_bak branch currently.) MemoryStream memStream = new MemoryStream(); #if !NETSTANDARD2_0 memStream.Write(valueAsBytes.Slice(0, idxOfFirstInvalidData)); valueAsBytes = valueAsBytes.Slice(idxOfFirstInvalidData); do { if (Rune.DecodeFromUtf8(valueAsBytes, out _, out int bytesConsumed) == OperationStatus.Done) { // Valid scalar value - copy data as-is to MemoryStream memStream.Write(valueAsBytes.Slice(0, bytesConsumed)); } else { // Invalid scalar value - copy U+FFFD to MemoryStream memStream.Write(ReplacementCharSequence); } valueAsBytes = valueAsBytes.Slice(bytesConsumed); } while (!valueAsBytes.IsEmpty); #else if (!MemoryMarshal.TryGetArray(value.AsMemoryBytes(), out ArraySegment <byte> valueArraySegment)) { Debug.Fail("Utf8String on netstandard should always be backed by an array."); } memStream.Write(valueArraySegment.Array, valueArraySegment.Offset, idxOfFirstInvalidData); valueArraySegment = new ArraySegment <byte>( valueArraySegment.Array, idxOfFirstInvalidData, valueArraySegment.Count - idxOfFirstInvalidData); do { if (Rune.DecodeFromUtf8(valueArraySegment, out _, out int bytesConsumed) == OperationStatus.Done) { // Valid scalar value - copy data as-is to MemoryStream memStream.Write(valueArraySegment.Array, valueArraySegment.Offset, bytesConsumed); } else { // Invalid scalar value - copy U+FFFD to MemoryStream memStream.Write(ReplacementCharSequence, 0, ReplacementCharSequence.Length); } valueArraySegment = new ArraySegment <byte>( valueArraySegment.Array, valueArraySegment.Offset + bytesConsumed, valueArraySegment.Count - bytesConsumed); } while (valueArraySegment.Count > 0); #endif bool success = memStream.TryGetBuffer(out ArraySegment <byte> memStreamBuffer); Debug.Assert(success, "Couldn't get underlying MemoryStream buffer."); return(Utf8String.UnsafeCreateWithoutValidation(memStreamBuffer)); }
internal static void Unescape(ReadOnlySpan <byte> source, Span <byte> destination, int idx, out int written) { Debug.Assert(idx >= 0 && idx < source.Length); Debug.Assert(source[idx] == JsonConstants.BackSlash); Debug.Assert(destination.Length >= source.Length); source.Slice(0, idx).CopyTo(destination); written = idx; for (; idx < source.Length; idx++) { byte currentByte = source[idx]; if (currentByte == JsonConstants.BackSlash) { idx++; currentByte = source[idx]; if (currentByte == JsonConstants.Quote) { destination[written++] = JsonConstants.Quote; } else if (currentByte == 'n') { destination[written++] = JsonConstants.LineFeed; } else if (currentByte == 'r') { destination[written++] = JsonConstants.CarriageReturn; } else if (currentByte == JsonConstants.BackSlash) { destination[written++] = JsonConstants.BackSlash; } else if (currentByte == JsonConstants.Slash) { destination[written++] = JsonConstants.Slash; } else if (currentByte == 't') { destination[written++] = JsonConstants.Tab; } else if (currentByte == 'b') { destination[written++] = JsonConstants.BackSpace; } else if (currentByte == 'f') { destination[written++] = JsonConstants.FormFeed; } else if (currentByte == 'u') { // The source is known to be valid JSON, and hence if we see a \u, it is guaranteed to have 4 hex digits following it // Otherwise, the Utf8JsonReader would have alreayd thrown an exception. Debug.Assert(source.Length >= idx + 5); bool result = Utf8Parser.TryParse(source.Slice(idx + 1, 4), out int scalar, out int bytesConsumed, 'x'); Debug.Assert(result); Debug.Assert(bytesConsumed == 4); idx += bytesConsumed; // The loop iteration will increment idx past the last hex digit if (JsonHelpers.IsInRangeInclusive((uint)scalar, JsonConstants.HighSurrogateStartValue, JsonConstants.LowSurrogateEndValue)) { // The first hex value cannot be a low surrogate. if (scalar >= JsonConstants.LowSurrogateStartValue) { ThrowHelper.ThrowInvalidOperationException_ReadInvalidUTF16(scalar); } Debug.Assert(JsonHelpers.IsInRangeInclusive((uint)scalar, JsonConstants.HighSurrogateStartValue, JsonConstants.HighSurrogateEndValue)); idx += 3; // Skip the last hex digit and the next \u // We must have a low surrogate following a high surrogate. if (source.Length < idx + 4 || source[idx - 2] != '\\' || source[idx - 1] != 'u') { ThrowHelper.ThrowInvalidOperationException_ReadInvalidUTF16(); } // The source is known to be valid JSON, and hence if we see a \u, it is guaranteed to have 4 hex digits following it // Otherwise, the Utf8JsonReader would have alreayd thrown an exception. result = Utf8Parser.TryParse(source.Slice(idx, 4), out int lowSurrogate, out bytesConsumed, 'x'); Debug.Assert(result); Debug.Assert(bytesConsumed == 4); // If the first hex value is a high surrogate, the next one must be a low surrogate. if (!JsonHelpers.IsInRangeInclusive((uint)lowSurrogate, JsonConstants.LowSurrogateStartValue, JsonConstants.LowSurrogateEndValue)) { ThrowHelper.ThrowInvalidOperationException_ReadInvalidUTF16(lowSurrogate); } idx += bytesConsumed - 1; // The loop iteration will increment idx past the last hex digit // To find the unicode scalar: // (0x400 * (High surrogate - 0xD800)) + Low surrogate - 0xDC00 + 0x10000 scalar = (JsonConstants.BitShiftBy10 * (scalar - JsonConstants.HighSurrogateStartValue)) + (lowSurrogate - JsonConstants.LowSurrogateStartValue) + JsonConstants.UnicodePlane01StartValue; } #if BUILDING_INBOX_LIBRARY var rune = new Rune(scalar); int bytesWritten = rune.EncodeToUtf8(destination.Slice(written)); #else EncodeToUtf8Bytes((uint)scalar, destination.Slice(written), out int bytesWritten); #endif Debug.Assert(bytesWritten <= 4); written += bytesWritten; } } else { destination[written++] = currentByte; } } }
//增加一个符文到身上 public void AddRuneToBody(string uuid, int posi, int resID, int exp) { LoggerHelper.Debug("add body idx: " + posi + " " + resID + " " + exp); Rune rune = new Rune(uuid, resID, exp); rune.index = posi; rune.inBag = false; BodyRune brune = body[posi]; brune.rune = rune; //todo更新UI string name = "no name"; if (LanguageData.dataMap.ContainsKey(rune.ResData.name)) { name = LanguageData.dataMap[rune.ResData.name].content; name = GetRuneNameString(rune.ResData.quality, name); } IconData _t = IconData.dataMap[rune.ResData.icon]; if (RuneUIViewManager.Instance != null) { RuneUIViewManager.Instance.AddInsetGridItem(rune.ResData.level, name, rune.index, _t.path, _t.color); } CalcuScore(); }
public static Dictionary<int, Rune> ReadRunicBoard(NetworkStream stream) { Dictionary<int, Rune> map = new Dictionary<int, Rune>(); int nbRune = ReadInt(stream); for(int i = 0; i<nbRune; ++i) { int position = ReadInt(stream); Rune rune = new Rune(ReadElement(stream), position); map.Add(position, rune); } return map; }
private static void HandleEffect(Rune rune, string effectName) { if (rune == null) return; Vector2 screenPos; ParticleEffect effect; var enemyPos = rune.Position; if (Drawing.WorldToScreen(enemyPos, out screenPos) && rune.IsVisibleForTeam(_me.GetEnemyTeam()) && rune.IsAlive) { if (VisibileRune.TryGetValue(rune, out effect)) return; effect = rune.AddParticleEffect("particles/" + effectName + ".vpcf"); VisibileRune.Add(rune, effect); } else { if (!VisibileRune.TryGetValue(rune, out effect)) return; effect.Dispose(); VisibileRune.Remove(rune); } }
/// <summary> /// Adds the specified rune to the display at the current cursor position /// </summary> /// <param name="rune">Rune to add.</param> public abstract void AddRune(Rune rune);
/* * GetGraphemeBreakClusterType * =========================== * Data derived from https://unicode.org/reports/tr29/#Default_Grapheme_Cluster_Table. Represents * grapheme cluster boundary information for the given code point. */ internal static GraphemeClusterBreakType GetGraphemeClusterBreakType(Rune rune) { nuint offset = GetNumericGraphemeTableOffsetNoBoundsChecks((uint)rune.Value); return((GraphemeClusterBreakType)Unsafe.AddByteOffset(ref MemoryMarshal.GetReference(GraphemeSegmentationValues), offset)); }