public override void ShowFeedback() { RaycastHit hit; _player.GetEyeSight(out hit); UIGame.GetInstance().ShowCrosshair(false); _digMarker.SetActive(true); _digMarker.transform.position = hit.point; _digMarker.transform.up = Vector3.Lerp(_digMarker.transform.up, hit.normal, 0.05f); }
public virtual void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); } }
public void MarkAnswerForPlayer(Player player, UIGame answer) { player.SetGame(answer); print("player " + player.id + " just marked " + answer.gameIAm.name + " as their answer"); markedAnswers++; //if(markedAnswers == airconsole.players.Count) //{ // LockAnswers(); //} }
//public void LockAnswers() //{ // for (int i = 0; i < airconsole.amountOfPlayers; i++) // { // if (TestAnswer(airconsole.players[i].game)) // { // //they got the right answer! wooh! // print("player " + i + " got the right answer with " + airconsole.players[i].game.gameIAm.name); // } // else // { // print("player " + i + " guessed wrong with " + airconsole.players[i].game.gameIAm.name); // } // } //} public bool TestAnswer(UIGame game) { if (MOBILEMODE) { return(TestAnswerMobile(game)); } else { TestAnswerDesktop(game); return(true); } }
// 显示UI public void ShowUI(string name) { UIGame gui = GetByUIGame(name); if (gui != null) { gui.Visible = true; if (onUpdata != null) { onUpdata(); } } }
public void Init() { m_mouseLeftPressed = false; m_keyUpPressed = false; m_keyDownPressed = false; m_keyLeftPressed = false; m_keyRightPressed = false; m_mousePosition = Vector2.Zero; m_world = new World(); m_world.Initialize(); m_ui = new UIGame(); Update(new TimeSpan()); }
public void DoWrongAnswer(UIGame selectedGame) { selectedGame.Lose(true); if (wrongChoiceCounter >= 1) { EndQuiz(selectedGame.gameIAm, false); } else { wrongChoiceCounter++; } }
public static Vector3 GetFireDirection(Transform playerTransform) { Ray ray; string[] temp = Input.GetJoystickNames(); if (Input.GetJoystickNames().Length > 0) { Vector3 mousePos; Vector3 joystick; joystick.x = Input.GetAxis("CursorHorizontal"); joystick.y = -Input.GetAxis("CursorVertical"); joystick.z = 0f; if (joystick.magnitude > 1f) { joystick.Normalize(); } mousePos.x = Screen.width / 2f + joystick.x * (float)Screen.width * fireZoneRadius; mousePos.y = Screen.height / 2f + joystick.y * (float)Screen.height * fireZoneRadius; mousePos.z = 0f; ray = Camera.main.ScreenPointToRay(mousePos); } else { Vector3 mousePos = Input.mousePosition; mousePos.x -= Screen.width / 2f; mousePos.y -= Screen.height / 2f; mousePos.x /= Screen.width; mousePos.y /= Screen.height; mousePos.z = 0f; if (mousePos.magnitude > fireZoneRadius) { mousePos.Normalize(); mousePos *= fireZoneRadius; } mousePos.x *= Screen.width; mousePos.y *= Screen.height; mousePos.x += Screen.width / 2f; mousePos.y += Screen.height / 2f; ray = Camera.main.ScreenPointToRay(mousePos); } Vector3 playerToRay = ray.origin - playerTransform.position; ray.origin = playerTransform.position; ray.origin += Vector3.Dot(playerTransform.right, playerToRay) * playerTransform.right; ray.origin += Vector3.Dot(playerTransform.up, playerToRay) * playerTransform.up; Vector3 destination = ray.origin + ray.direction * Mathf.Sqrt(UIGame.GetCursorDistance() * UIGame.GetCursorDistance() - (ray.origin - playerTransform.position).sqrMagnitude); return((destination - playerTransform.position).normalized); }
static void Postfix(UIGame __instance) { DspFontPatcher.logDebug("Patching UIGame"); Image[] icons = __instance.GetComponentsInChildren <Image>(true); foreach (Image icon in icons) { if (icon.gameObject.name.Equals("power-icon")) { ((RectTransform)icon.transform).anchoredPosition = new Vector2(-45, 0); } } }
public void DoCorrectAnswer(UIGame game) { foreach (UIGame g in uiGames) { if (g == game) { g.Win(true); } else { g.Win(false); } } EndQuiz(game.gameIAm, true); }
void Awake() { //Check if instance already exists if (instance == null) { //if not, set instance to this instance = this; } //If instance already exists and it's not this: else if (instance != this) { //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager. Destroy(gameObject); } }
public void OnClick(GameObject obj) { if (0 == obj.name.CompareTo("SetClose")) { gameObject.SetActive(false); } else if (0 == obj.name.CompareTo("bgsilence")) { UIGame.StopBGM(); bgMusicOpen = !bgMusicOpen; } else if (0 == obj.name.CompareTo("gamesilence")) { UIGame.StopEffect(); gameMusicOpen = !gameMusicOpen; } }
public void OnTriggerEnter(Collider other) { if (other.tag != TagManager.Get(Tag.Player)) { return; } if (GameState.HasEnded) { UIGame.GetInstance().FadeToBlack(2.5f, () => { Application.OpenURL("https://twitter.com/intent/tweet?button_hashtag=MusesSexton&text=" + Player.GetInstance().GetPlayerTombVerse() + "%0D" + Player.GetInstance().GetPlayerTombVerse() + "%0D" + Player.GetInstance().GetPlayerTombVerse() + "%0D"); Application.Quit(); }); } }
public void Init() { if (!playerGao) { playerGao = Instantiate(playerPrefab); playerGao.transform.SetParent(GameObject.FindGameObjectWithTag("DontDestroyGo").transform); } if (!guiMgr) { guiMgr = Instantiate(guiMgrPrefab); guiMgr.transform.SetParent(GameObject.FindGameObjectWithTag("DontDestroyGo").transform); } player = playerGao.GetComponent <Player>(); uiGame = guiMgr.GetComponent <UIGame>(); uiGame.Init(player); uiGame.transform.GetChild(1).GetComponent <Compass>().Init(player); }
public bool IsGamePanelActive() { if (panelStack == null) { return(false); } var panelArray = panelStack.ToArray(); UIGame panel = panelArray[1] as UIGame; if (panel == null) { return(false); } else { return(true); } }
public static void SetActive(bool bActive) { UIGame ui = null; if (bActive) { ui = Inst; } else { ui = s_inst; if (ui) { if (ui.gameObject.activeSelf) { ui.gameObject.SetActive(false); } Destroy(ui.gameObject); } } }
void Awake() { giftCount = 0; shotCount = 0; //zera a contagem de tiros recebidos starCount = 0; completedMissions = 0; //zera a contagem de missoes completas fail = false; gameOver = false; manager = this; mainCamera = GameObject.Find("MainCamera"); audioManager = GameObject.Find("AudioManager").GetComponent <AudioManager> (); if (!menu) { uiGame = GameObject.Find("EventSystemGame").GetComponent <UIGame>(); shotLight = GameObject.Find("shotLight"); fire = GameObject.Find("fire"); } balloon = GameObject.Find("Balloon"); balloonController = balloon.GetComponent <Balloon> (); }
IEnumerator CheckSelectedSpin() { bool tResult = false; if (((EUtil.Symbol)randNUmList[currentIndex]).ToString() == popupList.value) { tResult = true; // Debug.Log("SUCCESS"); CFunc.successCount++; } else { tResult = false; //Debug.Log("FAILED"); CFunc.failedCount++; } CFunc.SaveScore(); yield return(new WaitForSeconds(0.7f)); UIResult.SetActive(true, tResult); UIGame.SetActive(false); }
public static bool OnPlayerInspecteeChange(UIGame __instance, EObjectType objType, int objId) { if (Instance != null) { if (Instance._inspectingStorage) { if (objType == EObjectType.Entity) { // Trying to inspect another object if (objId != 0) { var factory = GameMain.mainPlayer.factory; var storageId = factory?.entityPool[objId].storageId; var stationId = factory?.entityPool[objId].stationId; // The other object is another storage if (storageId > 0) { Instance.CloseStorage(); return(true); } if (stationId > 0) { Instance.CloseStation(); return(true); } } else // PlayerAction_Inspect.InspectNothing() e.g., in space { // Prevent storage ID set to 0, which closes the window. return(false); } } } } return(true); }
public override void Initialize(params object[] arguments) { base.Initialize(); uigame = UIManager.instance.SwitchScreen <UIGame>(); timer = this.game.gameDuration; targetSpell = game.deckHandler.getRandomSpell(); currentSpell = game.deckHandler.getRandomSpell(); while (currentSpell.hue == targetSpell.hue) { currentSpell = game.deckHandler.getRandomSpell(); } currentCard = game.deckHandler.getRandomCard(); uigame.slider.normalizedValue = 0; UpdateColors(); ShowCurrentCard(); }
public bool TestAnswerMobile(UIGame game) { if (quizType == QuizType.Image) { if (game.gameIAm.name == gameImageWasFrom.name) { return(true); } } else { foreach (KeyValuePair <QuizType, List <Feature> > f in game.gameIAm.featureList) { if (f.Key == quizType) { if (f.Value.Contains(featureAskedAboutInQuestion)) { return(true); } } } } return(false); }
void Start() { mSelected = false; CardCtl = parentCard.transform.GetComponent <UICardControl>(); uigame = uigameObject.transform.GetComponent <UIGame>(); }
private void OpenStorage(int factoryIndex, int storageId) { if (factoryIndex < 0 || storageId < 0) { return; } if (!GameMain.isRunning || GameMain.instance.isMenuDemo) { return; } _lastFactoryIndex = factoryIndex; _lastStorageId = storageId; if (_uiGame == null || _uiStorage == null) { _uiGame = UIRoot.instance.uiGame; _uiStorage = _uiGame.storageWindow; } if (!_uiStorage.inited) { return; } // Not replacing current opened storage window to avoid potential problems if (_uiStorage.active) { UIRealtimeTip.Popup("请先关闭目前存储箱".Translate()); return; } if (GameMain.data.factories != null && GameMain.data.factories.Length > factoryIndex && GameMain.data.factories[factoryIndex] != null) { try { var factory = GameMain.data.factories[factoryIndex]; var factoryStorage = factory.factoryStorage; if (factoryStorage.storagePool != null && factoryStorage.storagePool.Length > storageId && factoryStorage.storagePool[storageId] != null ) { _uiStorage.storageId = storageId; _uiStorage.active = true; if (!_uiStorage.gameObject.activeSelf) { _uiStorage.gameObject.SetActive(true); } _uiStorage.factory = factory; _uiStorage.factoryStorage = factoryStorage; _uiStorage.player = GameMain.mainPlayer; _uiStorage.OnStorageIdChange(); _uiStorage.eventLock = true; _uiStorage.transform.SetAsLastSibling(); _uiGame.OpenPlayerInventory(); _inspectingStorage = true; } else { UIRealtimeTip.Popup("存储箱ID不存在".Translate()); } } catch (Exception message) { _inspectingStorage = false; Debug.Log(message.StackTrace); } } else { UIRealtimeTip.Popup("工厂不存在".Translate()); } }
private void OpenStation(int factoryIndex, int stationId) { if (factoryIndex < 0 || stationId < 0) { return; } if (!GameMain.isRunning || GameMain.instance.isMenuDemo) { return; } _lastFactoryIndex = factoryIndex; _lastStationFactoryIndex = stationId; if (_uiGame == null || (_uiStation) == null) { _uiGame = UIRoot.instance.uiGame; _uiStation = _uiGame.stationWindow; } if (!_uiStation.inited) { return; } if (_uiStation.active) { UIRealtimeTip.Popup("请先关闭目前物流站".Translate()); return; } if (GameMain.data.factories != null && GameMain.data.factories.Length > factoryIndex && GameMain.data.factories[factoryIndex] != null) { try { var factory = GameMain.data.factories[factoryIndex]; var transport = factory.transport; if (transport.stationPool != null && transport.stationPool.Length >= stationId && transport.stationPool[stationId] != null ) { _uiStation.stationId = stationId; _uiStation.active = true; if (!_uiStation.gameObject.activeSelf) { _uiStation.gameObject.SetActive(true); } _uiStation.factory = factory; _uiStation.transport = factory.transport; _uiStation.powerSystem = factory.powerSystem; _uiStation.player = GameMain.mainPlayer; _uiStation.OnStationIdChange(); _uiStation.nameInput.onValueChanged.AddListener(_uiStation.OnNameInputSubmit); _uiStation.nameInput.onEndEdit.AddListener(_uiStation.OnNameInputSubmit); _uiStation.player.onIntendToTransferItems += _uiStation.OnPlayerIntendToTransferItems; _uiStation.transform.SetAsLastSibling(); _uiGame.OpenPlayerInventory(); _inspectingStation = true; } else { UIRealtimeTip.Popup("物流站ID不存在".Translate()); } } catch (Exception message) { _inspectingStation = false; Debug.Log(message.StackTrace); } } else { UIRealtimeTip.Popup("工厂不存在".Translate()); } }
private void OpenStation(int factoryIndex, int stationId) { if (factoryIndex < 0 || stationId < 0) { return; } if (!GameMain.isRunning || GameMain.instance.isMenuDemo) { return; } _lastFactoryIndex = factoryIndex; _lastStationFactoryIndex = stationId; if (_uiGame == null || (_uiStation) == null) { _uiGame = UIRoot.instance.uiGame; _uiStation = _uiGame.stationWindow; } if (!_uiStation.inited) { return; } if (_uiStation.active) { UIRealtimeTip.Popup("请先关闭目前物流站".Translate()); return; } if (GameMain.data.factories != null && GameMain.data.factories.Length > factoryIndex && GameMain.data.factories[factoryIndex] != null) { try { var factory = GameMain.data.factories[factoryIndex]; var transport = factory.transport; if (transport.stationPool != null && transport.stationPool.Length >= stationId && transport.stationPool[stationId] != null ) { _uiStation.stationId = stationId; Traverse.Create(_uiStation).Property("active").SetValue(true); if (!_uiStation.gameObject.activeSelf) { _uiStation.gameObject.SetActive(true); } _uiStation.factory = factory; _uiStation.transport = factory.transport; _uiStation.powerSystem = factory.powerSystem; _uiStation.player = GameMain.mainPlayer; Traverse.Create(_uiStation).Method("OnStationIdChange").GetValue(); Traverse.Create(_uiStation).Field("eventLock").SetValue(true); var eventInfo = _uiStation.player.GetType().GetEvent("onIntendToTransferItems"); var methodInfo = _uiStation.GetType() .GetMethod("OnPlayerIntendToTransferItems", BindingFlags.NonPublic | BindingFlags.Instance); if (eventInfo != null && methodInfo != null) { eventInfo.AddEventHandler(_uiStation.player, Delegate.CreateDelegate(eventInfo.EventHandlerType, _uiStation, methodInfo)); } _uiStation.transform.SetAsLastSibling(); _uiGame.OpenPlayerInventory(); _inspectingStation = true; } else { UIRealtimeTip.Popup("物流站ID不存在".Translate()); } } catch (Exception message) { _inspectingStation = false; Debug.Log(message.StackTrace); } } else { UIRealtimeTip.Popup("工厂不存在".Translate()); } }
private void Awake () { if(Instance == null) Instance = this; }
private void InitializeMainPage() { var rootElement = page.RootElement; mainLayoutGrid = rootElement.FindVisualChildOfType <Grid>("mainLayout"); // counters bonusCounter = rootElement.FindVisualChildOfType <TextBlock>("bonusCounter"); lifeCounter = rootElement.FindVisualChildOfType <TextBlock>("lifeCounter"); moneyCounter = rootElement.FindVisualChildOfType <TextBlock>("moneyCounter"); Bonus = 30; LifeStatus = 3; Money = 30; // lifebar lifebarGaugeImage = MainSceneImages["life_bar"]; lifebarGrid = rootElement.FindVisualChildOfType <Grid>("lifebarGrid"); gaugeBarRegion = lifebarGaugeImage.Region; // character name nameTextBlock = rootElement.FindVisualChildOfType <TextBlock>("nameTextBlock"); // explanation // FIXME: UI asset should support multiline text var explanationText = rootElement.FindVisualChildOfType <TextBlock>("explanationText"); explanationText.Text = "Pictogram-based alphabets are easily supported.\n日本語も簡単に入れることが出来ます。"; // status stars var statusPanel = rootElement.FindVisualChildOfType <UniformGrid>("statusPanel"); powerStatusStar = statusPanel.FindVisualChildOfType <ImageElement>("powerStatusStar"); controlStatusStar = statusPanel.FindVisualChildOfType <ImageElement>("controlStatusStar"); speedStatusStar = statusPanel.FindVisualChildOfType <ImageElement>("speedStatusStar"); PowerStatus = shipList[activeShipIndex].Power; ControlStatus = shipList[activeShipIndex].Control; SpeedStatus = shipList[activeShipIndex].Speed; // ship selection var currentShipButton = rootElement.FindVisualChildOfType <Button>("currentShipButton"); currentShipButton.Click += delegate { // Once click, update the SpaceShip status pop-up and show it. UpdateShipStatus(); ShowShipSelectionPopup(); }; currentShipImage = currentShipButton.FindVisualChildOfType <ImageElement>("currentShipImage"); // upgrade buttons var statusUpgradePanel = rootElement.FindVisualChildOfType <UniformGrid>("statusUpgradePanel"); SetupStatusButton(statusUpgradePanel.FindVisualChildOfType <ButtonBase>("powerStatusButton"), 2, 0, () => PowerStatus, () => PowerStatus++); SetupStatusButton(statusUpgradePanel.FindVisualChildOfType <ButtonBase>("controlStatusButton"), 2, 0, () => ControlStatus, () => ControlStatus++); SetupStatusButton(statusUpgradePanel.FindVisualChildOfType <ButtonBase>("speedStatusButton"), 2, 0, () => SpeedStatus, () => SpeedStatus++); SetupStatusButton(statusUpgradePanel.FindVisualChildOfType <ButtonBase>("lifeStatusButton"), 1, 1, () => 0, () => LifeStatus++); // quit button var quitButton = rootElement.FindVisualChildOfType <Button>("quitButton"); quitButton.Click += delegate { UIGame.Exit(); }; }
private UIElement CreateMainScene() { // the top life bar var topBar = CreateMainScreneTopBar(); // Create Name label nameTextBlock = new TextBlock { Font = WesternFont, TextSize = 52, TextColor = Color.LightGreen, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(50, 0, 50, 0) }; var nameLabel = new ContentDecorator { BackgroundImage = SpriteFromSheet.Create(MainSceneImages, "tex_edit_inactivated_background"), Content = nameTextBlock, Padding = new Thickness(20, 15, 20, 20), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; nameLabel.SetGridRow(1); // Create Character image var characterImage = new ImageElement { Name = "HeroImage", Source = SpriteFromSheet.Create(MainSceneImages, "character"), HorizontalAlignment = HorizontalAlignment.Center, }; characterImage.SetGridRow(2); // Create Explanation TextBlock var explanationLabel = new ContentDecorator { BackgroundImage = SpriteFromSheet.Create(MainSceneImages, "description_frame"), HorizontalAlignment = HorizontalAlignment.Center, Content = new TextBlock { Font = JapaneseFont, TextSize = 28, TextColor = Color.White, Text = "Pictogram-based alphabets are easily supported.\n日本語も簡単に入れることが出来ます。", HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, WrapText = true }, Padding = new Thickness(50, 30, 50, 40), }; explanationLabel.SetGridRow(3); // The ship status panel var shipStatusPanel = CreateMainSceneShipStatusPanel(); shipStatusPanel.SetGridRow(4); // Create quit button (Last element) var quitButton = CreateTextButton("Quit Sample"); quitButton.HorizontalAlignment = HorizontalAlignment.Center; quitButton.VerticalAlignment = VerticalAlignment.Center; quitButton.Click += delegate { UIGame.Exit(); }; quitButton.SetGridRow(5); // Put region together in the main grid var mainLayout = new Grid(); mainLayout.ColumnDefinitions.Add(new StripDefinition()); mainLayout.RowDefinitions.Add(new StripDefinition(StripType.Star, 15)); mainLayout.RowDefinitions.Add(new StripDefinition(StripType.Star, 10)); mainLayout.RowDefinitions.Add(new StripDefinition(StripType.Star, 20)); mainLayout.RowDefinitions.Add(new StripDefinition(StripType.Star, 20)); mainLayout.RowDefinitions.Add(new StripDefinition(StripType.Star, 25)); mainLayout.RowDefinitions.Add(new StripDefinition(StripType.Star, 10)); mainLayout.LayerDefinitions.Add(new StripDefinition()); // set minimal and maximal size of rows mainLayout.RowDefinitions[0].MaximumSize = topBar.MaximumHeight; mainLayout.RowDefinitions[1].MinimumSize = 100; mainLayout.RowDefinitions[3].MinimumSize = 120; mainLayout.RowDefinitions[5].MinimumSize = 90; mainLayout.Children.Add(topBar); mainLayout.Children.Add(nameLabel); mainLayout.Children.Add(characterImage); mainLayout.Children.Add(explanationLabel); mainLayout.Children.Add(shipStatusPanel); mainLayout.Children.Add(quitButton); return(mainLayout); }
public virtual void Init(UIGame uiGame) { this.uiGame = uiGame; }
public void GameUIShow() { _GameUI = new UIGame(); _GameUI.Show(); }
private void Start() { uiGame = UIGame.Instance; ResetChest(); }