public void CanGetResourceByKey() { var newResource = CreateResource("CanGetExistingResourceByKey"); var gotResources = _resourceController.Get(Platform.GlobalGameId, Platform.GlobalActorId, new[] { newResource.Key }); Assert.True(gotResources.Count(r => IsMatch(r, newResource)) == 1); }
private void delete(object sender, RoutedEventArgs e) { if (isNewResource) { NavigationService.Navigate(new Page()); return; } ResourceView newResource = null; foreach (var resource in ResourcePage.ResourceList) { if (resource.Id == Int32.Parse(idLabel.Content.ToString())) { newResource = resource; break; } } MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("Da li ste sigurni da zelite da izbrišete ovaj resurs?", "Delete Confirmation", System.Windows.MessageBoxButton.YesNo); if (messageBoxResult == MessageBoxResult.Yes) { if (_resourceController.Get(newResource.Id) != null) { _resourceController.Remove(newResource.Convert().Id); } ResourcePage.ResourceList.Remove(newResource); System.Windows.MessageBox.Show("Promene uspešno sačuvane"); NavigationService.Navigate(new Page()); return; } }
public static void Create(string name, string spritePath, Vector2 position, Vector2?scale = null, float rotation = 0, int order = 0) { var gameElement = new GameObject(name); var spriteComponent = gameElement.AddComponent <SpriteRenderer>(); var element = gameElement.AddComponent <Element>(); spriteComponent.sortingOrder = order; spriteComponent.sprite = ResourceController.Get <Sprite>(spritePath); element.Position = position; element.Scale = scale ?? Vector2.one; element.Rotation = rotation; element.transform.SetParent(stage.transform); instances[name] = gameElement; }
private void ProcessLoop() { while (true) { // If held, break as not to cause infinite loop :3 if (hold == HoldState.Held) { break; } // Using XPath, finds current label, finds the step (any type) with the current step no (Note: XPath order selector starts at 1, not 0) var command = vnScript.SelectSingleNode($"/Script/Label[@name='{route}']/*[{step}]"); switch (command.Name) // wew thats a large switch { case "Text": // A plain VN Dialogue, nothing hard view.SetDialogue(command.InnerText); break; case "Element-Create": XMLElementAction.Create(command); break; case "Element-Destroy": Element.Destroy(command.Attributes["name"].Value); break; case "Music-Play": // TODO: Not sure what this does, replace! var clip = ResourceController.Get <AudioClip>(command.InnerText); musicPlayer.PlayOneShot(clip); break; case "Load": if (command.Attributes?["type"]?.Value == "sprite") { ResourceController.Load <Sprite>(command.InnerText); } else { ResourceController.Load(command.InnerText); } break; case "Unload": ResourceController.Unload(command.InnerText); break; case "Jump": route = command.Attributes["label"].Value; step = 0; // somewhat hacky way to handle the increment at the end, will fix if this errs or something break; case "JS": // JS Exec jsEngine.Execute(command.InnerText); break; default: throw new Exception($"{command.Name} is not a valid tag"); } hold = Hold.GetHoldState(command); if (hold == HoldState.Clear) { step++; // Only progress to next step when HoldState is clear. } } }