protected override void OnInitialize() { GameObjectUtilities.FindGameObject(_panelRoute + "/MenuPanel/SettingsButton").GetComponent <Button>().onClick.AddListener(() => SettingsClickedEvent?.Invoke()); GameObjectUtilities.FindGameObject(_panelRoute + "/MenuPanel/LeaderboardButton").GetComponent <Button>().onClick.AddListener(() => { SUGARManager.Leaderboard.Display("smi_stars", LeaderboardFilterType.Near); SendTrackerEvent("ViewLeaderboard"); }); GameObjectUtilities.FindGameObject(_panelRoute + "/MenuPanel/AchievementButton").GetComponent <Button>().onClick.AddListener(() => { SUGARManager.Evaluation.DisplayAchievementList(); SendTrackerEvent("ViewAchievements"); }); _panel = GameObjectUtilities.FindGameObject(_panelRoute); _background = GameObjectUtilities.FindGameObject("BackgroundContainer/MenuBackgroundImage"); _playButton = GameObjectUtilities.FindGameObject(_panelRoute + "/MenuPanel/PlayButton").GetComponent <Button>(); _menuPanel = GameObjectUtilities.FindGameObject(_panelRoute + "/MenuPanel"); _quitPanel = GameObjectUtilities.FindGameObject(_panelRoute + "/QuitPanel"); _messagePanel = GameObjectUtilities.FindGameObject(_panelRoute + "/MessagePanel"); _messagePanel.SetActive(false); _playButton.onClick.AddListener(() => PlayClickedEvent?.Invoke()); _quitPanel.transform.FindButton("YesButton").onClick.AddListener(Application.Quit); _quitPanel.transform.FindButton("NoButton").onClick.AddListener(() => OnQuitAttempt(true)); }
/// <summary> /// Set the title and buttons of the popup containier /// </summary> /// <param name="title">The title of the popup</param> /// <param name="outputs">The desired button Output from left to right</param> /// <param name="closePopupAction"></param> public void SetPopup(string title, Output[] outputs, Action closePopupAction) { // set the title SetTitle(title); if (outputs == null) { return; } _buttonContainer = GameObjectUtilities.Find("PopupContainer/PopupPanelContainer/ButtonContainer").gameObject; var buttonPrefab = Resources.Load("ButtonContainer"); foreach (var buttonOutput in outputs) { var buttonObject = Instantiate(buttonPrefab) as GameObject; if (buttonObject != null) { SetButton(buttonObject.GetComponent <Button>(), buttonOutput.Name, buttonOutput.Action, closePopupAction); //now set the parent of the object buttonObject.transform.SetParent(_buttonContainer.transform, false); _buttonsGameObjects.Add(buttonObject); } } }
public void OnPointerClick(PointerEventData eventData) { var description = !string.Equals(_containerImage.sprite.name, UIConstants.ItemContainerDefaultSpriteName, StringComparison.CurrentCultureIgnoreCase) ? _containerImage.sprite.name.ToUpperInvariant() + "_DESCRIPTION" : string.Empty; GameObjectUtilities.FindGameObject("Game/Canvas/ItemPanel/ItemContainer_Inventory").GetComponent <ItemContainerBehaviour>().TryGetItem(out var inventory); if (_moveItem) { if (inventory && inventory.Id == _moveItem.Id) { if (_moveItemContainer != null) { if (TryGetItem(out var containerItem) == false) { PlayerCommands.DropItem(_moveItem.Id, ContainerIndex); } else { PlayerCommands.SwapInventoryItem(containerItem.Id, ContainerIndex, _moveItem.Id); } } else { if (TryGetItem(out var containerItem) == false) { PlayerCommands.DropAndActivateItem(_moveItem.Id, ContainerIndex); } else { PlayerCommands.SwapAndActivateInventoryItem(containerItem.Id, ContainerIndex, _moveItem.Id); } }
protected override void OnInitialize() { GameObjectUtilities.FindGameObject(_panelRoute + "/AnswerButton").GetComponent <Button>().onClick.AddListener(() => AnswerClickedEvent?.Invoke()); _panel = GameObjectUtilities.FindGameObject(_panelRoute); _background = GameObjectUtilities.FindGameObject("BackgroundContainer/CallBackgroundImage"); _callAnim = GameObjectUtilities.FindGameObject(_panelRoute + "/SatelliteAnimContainer").GetComponent <CallAnimationBehaviour>(); }
protected GameObject[] GetTargets() { if (null == Origin || null == Vision) { return(null); } int mask = 0; if (TargetDetectionType.Enemy == TargetDetectionType || TargetDetectionType.Both == TargetDetectionType) { mask = LayerMaskValues.ENEMY; } if (TargetDetectionType.Player == TargetDetectionType || TargetDetectionType.Both == TargetDetectionType) { mask |= LayerMaskValues.PLAYER; } Collider[] targets = Environment.GetEntitiesInSight( mask, Origin, Vision.DetectionRadius, Vision.DetectionAngle, Vision.HeightOffset, Vision.MaxHeightDifference, true ); GameObject[] targetsGO = GameObjectUtilities.GetGameObjects(targets); if (IsAoE) { return(targetsGO); } GameObject[] nearest = { Environment.GetNearestObject(Origin.position, targetsGO) }; return(nearest); }
public override void Draw(SpriteBatch spriteBatch, Color color) { if (Enemies.Count > 0) { Enemies.Clear(); } base.Draw(spriteBatch, color); foreach (var item in StartPoints.Values) { GameObjectUtilities.Draw(spriteBatch, color, startPointTexture, item.Bounds); } foreach (var item in Goals.Values) { GameObjectUtilities.Draw(spriteBatch, color, goalPointTexture, item.Bounds); } foreach (var item in EnemyStartPoints.Values) { GameObjectUtilities.Draw(spriteBatch, color, enemyStartPointTexture, item.Bounds); var enemy = _gameEntry.AvailableEnemies[item.EnemyName]; GameObjectUtilities.Draw(spriteBatch, Color.LightGray, enemy.Texture, item.Bounds); } }
public WeenusUI(Component unityComponent) { var buttons = new List <WeenusFieldButton>(); var views = new List <WeenusFieldView>(); var inputs = new List <WeenusInputField>(); RectTransform rect = unityComponent.GetComponent <RectTransform>(); GameObjectUtilities.GetAllComponentsInChildTree <WeenusFieldButton>(rect, buttons); GameObjectUtilities.GetAllComponentsInChildTree <WeenusFieldView>(rect, views); GameObjectUtilities.GetAllComponentsInChildTree <WeenusInputField>(rect, inputs); foreach (var b in buttons) { Button.Add(b.gameObject.name, b); } foreach (var b in views) { FieldView.Add(b.gameObject.name, b); } foreach (var b in inputs) { FieldInput.Add(b.gameObject.name, b); } }
public static Collider[] GetEntitiesInSight(int mask, Transform transform, float radius, float degrees, float heightOffset, float maxHeightDifference, bool useHeightDifference = true) { Collider[] colliders = Environment.GetObjectsInRadius(transform.position, radius, mask); List <Collider> results = new List <Collider>(); float halfDegrees = degrees / 2.0f; for (int loop1 = 0; loop1 < colliders.Length; loop1++) { GameObject candidate = GameObjectUtilities.GetGameObject(colliders[loop1]); if (halfDegrees <= Direction.GetAngle(transform, candidate.transform)) { continue; } Vector3 eyePos = candidate.transform.position + Vector3.up * heightOffset; Vector3 toPlayer = transform.position - eyePos; // If the enemy is too high or too low ignore him. if (useHeightDifference && Mathf.Abs(toPlayer.y + heightOffset) > maxHeightDifference) { continue; } EntityController entity = candidate.GetComponent <EntityController>(); if (null == entity || entity.Dead) { continue; } results.Add(colliders[loop1]); } return(results.ToArray()); }
public ModulesController() { var aotFaqList = new List <FaqEntry>(); var aotModEntList = new List <ModuleEntry>(); Localization.Initialize(); _modulesPopup = GameObjectUtilities.FindGameObject("GameContainer/GamePanelContainer/ModulesContainer/ModulesPopup"); _modulesContent = GameObjectUtilities.FindGameObject("GameContainer/GamePanelContainer/ModulesContainer/ModulesPopup/Scroll View").GetComponent <ScrollRect>().content; _moduleItemPrefab = Resources.Load <GameObject>("Prefabs/ModuleItem"); _moduleIndexItemPrefab = Resources.Load <GameObject>("Prefabs/ModuleIndexItem"); _moduleDescriptionItemPrefab = Resources.Load <GameObject>("Prefabs/ModuleDescriptionItem"); _moduleIcons = Resources.LoadAll <Sprite>("Sprites/Modules/Icons"); _backButton = GameObjectUtilities.FindGameObject("GameContainer/GamePanelContainer/ModulesContainer/ModulesPopup/BackButton").GetComponent <Button>(); _nextArrow = GameObjectUtilities.FindGameObject("GameContainer/GamePanelContainer/ModulesContainer/ModulesPopup/NextArrow").GetComponent <Button>(); _backArrow = GameObjectUtilities.FindGameObject("GameContainer/GamePanelContainer/ModulesContainer/ModulesPopup/BackArrow").GetComponent <Button>(); GameObjectUtilities.FindGameObject("GameContainer/GamePanelContainer/ModulesContainer").GetComponent <Button>().onClick.AddListener(() => { TogglePopup(); SendTrackerEvents("ClosedModuleMenu", "ClosedModuleMenu"); }); foreach (var lang in Localization.Languages) { var www = new WWW((Application.platform != RuntimePlatform.Android ? "file:///" : string.Empty) + Path.Combine(Application.streamingAssetsPath, "modules-" + lang.Name + ".json")); while (!www.isDone) { } _modulesDatabase.Add(lang.Name, JsonConvert.DeserializeObject <ModuleEntry[]>(www.text)); } TrackerEventSender.SetModuleDatabase(_modulesDatabase[Localization.SelectedLanguage.Name]); }
protected EntityController GetTarget() { if (null == Vision) { return(null); } Collider[] targets = Environment.GetEntitiesInSight( LayerMaskValues.PLAYER, transform, GetMaxAttackRange(), Vision.DetectionAngle, Vision.HeightOffset, Vision.MaxHeightDifference, true ); GameObject[] targetsGO = GameObjectUtilities.GetGameObjects(targets); GameObject nearest = Environment.GetNearestObject(transform.position, targetsGO); if (null == nearest) { return(null); } EntityController target = nearest.GetComponent <EntityController>(); return(target); }
protected override void OnInitialize() { _panel = GameObjectUtilities.FindGameObject(_panelRoute); _background = GameObjectUtilities.FindGameObject("BackgroundContainer/CallBackgroundImage"); _scorePanel = GameObjectUtilities.FindGameObject(_panelRoute + "/ScorePanel").GetComponent <ScorePanelBehaviour>(); GameObjectUtilities.FindGameObject(_panelRoute + "/ScorePanel/NextButton").GetComponent <Button>().onClick.AddListener(OnNextButtonClicked); }
protected override void OnInitialize() { var chatPanel = GameObjectUtilities.FindGameObject("Voice/VoicePanelContainer").gameObject; _talkButton = GameObjectUtilities.FindGameObject("Voice/PressToTalkButtonContainer").GetComponent <PressedState>(); base.OnInitialize(); }
protected override void OnInitialize() { _panel = GameObjectUtilities.FindGameObject(_panelRoute); _background = GameObjectUtilities.FindGameObject("BackgroundContainer/MenuBackgroundImage"); _itemPrefab = Resources.Load <GameObject>("Prefabs/LevelItem"); _gridLayout = GameObjectUtilities.FindGameObject(_panelRoute + "/LevelPanel/Scroll View/Viewport/Content/GridLayout").GetComponent <GridLayoutGroup>(); GameObjectUtilities.FindGameObject(_panelRoute + "/BackButton").GetComponent <Button>().onClick.AddListener(OnBackClick); }
private void Intialise() { MenuScreen = GameObjectUtilities.GetChildComponent <UIMenuController> (this.transform); GameScreen = GameObjectUtilities.GetChildComponent <UIGameController> (this.transform); PauseScreen = GameObjectUtilities.GetChildComponent <UIPauseController> (this.transform); GameOverScreen = GameObjectUtilities.GetChildComponent <UIGameOverController> (this.transform); EventManager.OnStateChanged += OnStateSwitched; }
public void OnOutOfBounds() { offscreen = false; GameObjectUtilities.Destroy(gameObject); if (DestroyCallback != null) { DestroyCallback(); } }
public GameObject GetNearestEnemyInRange(bool useHeightDifference = true) { Collider[] enemies = GetEnemiesInRange(useHeightDifference); if (0 == enemies.Length) { return(null); } GameObject[] enemiesGO = GameObjectUtilities.GetGameObjects(enemies); return(Environment.GetNearestObject(transform.position, enemiesGO)); }
protected override void OnInitialize() { _panel = GameObjectUtilities.FindGameObject("Menu/SimulationSummaryContainer/SimulationSummaryPanelContainer"); _columnContainer = _panel.transform.Find("ColumnContainer"); _playerMetricsContainer = _panel.transform.Find("PlayerMetricsPanel"); _continueButton = _panel.transform.FindButton("ButtonPanel/ContinueButtonContainer"); _columnResource = Resources.Load <GameObject>("SimulationSummaryColumn"); _rowItemResource = Resources.Load <GameObject>("SimulationSummaryRowItem"); _playerMetricsResource = Resources.Load <GameObject>("PlayerMetricContainer"); }
// Update is called once per frame void Update() { Collider[] enemies = _playerControllerScript.GetEnemiesInSight(); if (0 == enemies.Length) { HideCombatUI(); } else { GameObject[] enemiesGO = GameObjectUtilities.GetGameObjects(enemies); ShowCombatUI(); Attack punch = _playerControllerScript.Attacks[(int)PlayerAttackIndex.Punch]; Attack kick = _playerControllerScript.Attacks[(int)PlayerAttackIndex.Kick]; Attack block = _playerControllerScript.Attacks[(int)PlayerAttackIndex.Block]; Attack jumpkick = _playerControllerScript.Attacks[(int)PlayerAttackIndex.Jumpkick]; Attack super = _playerControllerScript.Attacks[(int)PlayerAttackIndex.Super]; if (punch.IsUseable(enemiesGO)) { punchButton.SetButtonStateOn(); } else { punchButton.SetButtonState(ButtonState.Disabled); } if (kick.IsUseable(enemiesGO)) { kickButton.SetButtonStateOn(); } else { kickButton.SetButtonState(ButtonState.Disabled); } if (block.IsUseable(enemiesGO)) { blockButton.SetButtonStateOn(); } else { blockButton.SetButtonState(ButtonState.Disabled); } if (jumpkick.IsUseable(enemiesGO)) { jumpkickButton.SetButtonStateOn(); } else { jumpkickButton.SetButtonState(ButtonState.Disabled); } _superInRange = super.IsUseable(enemiesGO); } AttackType attack = GetAttack(); Attack(attack); CurrentAttack = attack; }
protected virtual void OnTriggerEnter(Collider other) { GameObject go = GameObjectUtilities.GetGameObject(other); PlayerController player = go.GetComponent <PlayerController>(); if (null == player) { return; } PlayerVisited = true; }
protected override void OnInitialize() { // Create Game Popup _createGamePanel = GameObjectUtilities.FindGameObject("CreateGameContainer/CreatePanelContainer"); _buttons = new ButtonList("CreateGameContainer/CreatePanelContainer/ButtonPanel"); _createGameCloseButton = _buttons.GetButton("BackButtonContainer"); _createGamePopupButton = _buttons.GetButton("CreateButtonContainer"); // Create Game Listener Goes Here }
protected override void OnInitialize() { _feedbackPanel = GameObjectUtilities.FindGameObject("FeedbackContainer/FeedbackPanelContainer/FeedbackPanel"); _columnPrefab = Resources.Load("FeedbackColumn") as GameObject; _entryPrefab = Resources.Load("FeedbackEntry") as GameObject; _slotPrefab = Resources.Load("FeedbackSlot") as GameObject; _buttons = new ButtonList("FeedbackContainer/FeedbackPanelContainer/FeedbackButtons"); _error = GameObjectUtilities.FindGameObject("FeedbackContainer/FeedbackPanelContainer/Error"); _sendButton = _buttons.GetButton("SendButtonContainer"); }
void ResetGame() { spawner.active = true; player = GameObjectUtilities.Instantiate(playerPrefab, new Vector3(0, (Screen.height / CameraFocus.pixelsToUnits) / 2 + 100, 0)); var playerDestroyScript = player.GetComponent <GarbageCollection> (); playerDestroyScript.DestroyCallback += OnPlayerKilled; gameStarted = true; continueText.canvasRenderer.SetAlpha(0); timeElapsed = 0; beatBestTime = false; }
IEnumerator EnemyGenerator() { yield return(new WaitForSeconds(delay)); if (active) { var newTransform = transform; GameObjectUtilities.Instantiate(prefabs[Random.Range(0, prefabs.Length)], newTransform.position); ResetDelay(); } StartCoroutine(EnemyGenerator()); }
protected override void OnInitialize() { _settingsPanel = GameObjectUtilities.FindGameObject("SettingsContainer/SettingsPanelContainer"); _creator = _settingsPanel.GetComponentInChildren <SettingCreation>(); _creator.Wipe(); _creator.SetLabelAlignment(TextAnchor.MiddleLeft); _creator.TryLanguageForPlatform(out _language, false, true, "SETTINGS_LABEL_LANGUAGE"); _creator.TryResolutionForPlatform(out _resolution, 960, 540, null, false, true, "SETTINGS_LABEL_RESOLUTION"); _creator.TryFullScreenForPlatform(out _fullScreen, true, "SETTINGS_LABEL_FULLSCREEN"); _cancel = GameObjectUtilities.FindGameObject("SettingsContainer/SettingsPanelContainer/ButtonPanel/CancelButtonContainer").GetComponent <Button>(); _apply = GameObjectUtilities.FindGameObject("SettingsContainer/SettingsPanelContainer/ButtonPanel/ApplyButtonContainer").GetComponent <Button>(); }
protected override void OnInitialize() { // Join Game Popup _joinGamePanel = GameObjectUtilities.FindGameObject("JoinGameContainer/JoinPanelContainer"); _buttons = new ButtonList("JoinGameContainer/JoinPanelContainer/ButtonPanel"); _backButton = _buttons.GetButton("BackButtonContainer"); _refreshButton = _buttons.GetButton("RefreshButtonContainer"); _gameListObject = GameObjectUtilities.FindGameObject("JoinGameContainer/JoinPanelContainer/GameListContainer/Viewport/Content"); _gameItemPrefab = Resources.Load("GameItem") as GameObject; }
public void Initialize() { // get player entity item storage component if (_director.Player.Entity.TryGetComponent(out ItemStorage itemStorage) == false) { throw new SimulationIntegrationException("No item storage found on player"); } var inventoryGameObject = GameObjectUtilities.FindGameObject("Game/Canvas/ItemPanel/ItemContainer_Inventory"); var inventoryItemContainer = itemStorage.Items[0] as InventoryItemContainer; _inventoryItem = new ItemPanelContainer(_director, inventoryGameObject, -1, inventoryItemContainer, false); }
protected override void OnInitialize() { _panel = GameObjectUtilities.FindGameObject(_panelRoute); _background = GameObjectUtilities.FindGameObject("BackgroundContainer/CallBackgroundImage"); _characterMood = GameObjectUtilities.FindGameObject(_panelRoute + "/ReviewPanel/StatusBar/MoodPanel/FillBar").GetComponent <Image>(); _reviewContent = GameObjectUtilities.FindGameObject(_panelRoute + "/ReviewPanel/Scroll View").GetComponent <ScrollRect>(); _clientChatPrefab = Resources.Load <GameObject>("Prefabs/ClientChatFeedbackItem"); _playerChatPrefab = Resources.Load <GameObject>("Prefabs/PlayerChatFeedbackItem"); _feedbackPrefab = Resources.Load <GameObject>("Prefabs/FeedbackElement"); GameObjectUtilities.FindGameObject(_panelRoute + "/ReviewPanel/NextButton").GetComponent <Button>().onClick.AddListener(() => NextClickedEvent?.Invoke()); }
public override void OnAwake() { base.OnAwake(); if (isSearchWhenRuntime) { var source = GetSource(); var t = source.Value; var n = GameObjectUtilities.GetRelativePath(source.Owner.gameObject, Value); XLogger.Log(n); Value = Owner.transform.Find(n).gameObject; } }
MeshFilter CreateMesh(string name, string materialName) { GameObject g = new GameObject(name); g.transform.SetParent(transform); GameObjectUtilities.AlignTransform(g.transform, transform); var renderer = g.AddComponent <MeshRenderer> (); var mat = Resources.Load <Material>(materialName); renderer.material = mat; return(g.AddComponent <MeshFilter> ()); }
public override void OnEnter() { base.OnEnter(); if (Fsm.isPrefab) { gameObject.SetActive(active); } else { var targetTransform = GameObjectUtilities.FindByName(Fsm.transform, gameObject.name); targetTransform.gameObject.SetActive(active); } }