private Vector2 fireballsAndTrail(Vector2 change) { if (redwing_hooks.blackmothSymbolsExist) { // Why does this work but not just checking it directly? if (redwing_hooks.blackmothGrubberCheck()) { return(change); } } HeroActions direction = GameManager.instance.inputHandler.inputActions; if (direction.up.IsPressed && !direction.down.IsPressed && change.y > 0.00001f) { if (flamePower > 1.0f && canFireballs) { flamePower -= 1.0f; StartCoroutine(noMoreFireballs()); redwingSpawner.addFireballs(); } } // ReSharper disable once InvertIf This looks really dumb if (canFireTrail) { currentTrailSprite = redwing_flame_gen.rng.Next(0, redwing_hooks.fireTrailTextures.Length); StartCoroutine(noMoreTrails()); } return(change); }
public void CheckForDash() { dashCooldownStart = dashCooldownStart == HeroController.instance.DASH_COOLDOWN_CH * 0.4f ? dashCooldownStart : HeroController.instance.DASH_COOLDOWN_CH * 0.4f; dashCooldownHasDash = dashCooldownHasDash == HeroController.instance.DASH_COOLDOWN_CH * 0.1f ? dashCooldownHasDash : HeroController.instance.DASH_COOLDOWN_CH * 0.1f; GetPrivateField("dashQueueSteps").SetValue(HeroController.instance, 0); GetPrivateField("dashQueuing").SetValue(HeroController.instance, false); HeroActions direction = GameManager.instance.inputHandler.inputActions; if (PlayerData.instance.equippedCharm_35) { GetPrivateField("dashCooldownTimer").SetValue(HeroController.instance, 0f); GetPrivateField("shadowDashTimer").SetValue(HeroController.instance, 0); } if (direction.up.IsPressed) { DashDirection.y = 1; } else if (direction.down.IsPressed && !HeroController.instance.cState.onGround) { DashDirection.y = -1; } else { DashDirection.y = 0; } if (direction.right.IsPressed) { DashDirection.x = 1; } else if (direction.left.IsPressed) { DashDirection.x = -1; } else if (DashDirection.y == 0) { DashDirection.x = HeroController.instance.cState.facingRight ? 1 : -1; } else { DashDirection.x = 0; } LogDebug($@"Dash direction: {DashDirection}"); if (!PlayerData.instance.hasDash) { DashDirection.y = 0; DashDirection.x = HeroController.instance.cState.facingRight ? 1 : -1; } if (!PlayerData.instance.equippedCharm_35) { DoDash(); } // Fixes TC bug where after tink sharp shadow is broken sharpShadowFSM.SetState("Idle"); }
//Initalizes the sprite game objects IEnumerator SpriteRoutine() { do { yield return(null); }while (HeroController.instance == null || GameManager.instance == null); instance = this; ha = InputHandler.Instance.inputActions; try { prevFaceRightVal = HeroController.instance.cState.facingRight; gunSpriteGO = new GameObject("HollowPointGunSprite", typeof(SpriteRenderer), typeof(GunSpriteRenderer), typeof(AudioSource)); gunSpriteGO.transform.position = HeroController.instance.transform.position; gunSpriteGO.transform.localPosition = new Vector3(0, 0, 0); gunSpriteGO.SetActive(true); transformSlave = new GameObject("slaveTransform", typeof(Transform)); ts = transformSlave.GetComponent <Transform>(); //ts.transform.SetParent(HeroController.instance.transform); gunSpriteGO.transform.SetParent(ts); defaultWeaponPos = new Vector3(-0.2f, -0.84f, -0.0001f); rand = new System.Random(); whiteFlashGO = CreateGameObjectSprite("lightflash.png", "lightFlashGO", 65); muzzleFlashGO = CreateGameObjectSprite("muzzleflash.png", "bulletFadePrefabObject", 150); muzzleFlashGOAlt = CreateGameObjectSprite("muzzleflashAlt.png", "bulletFadePrefabObjectAlt", 150); } catch (Exception e) { Log(e); } whiteFlashGO.SetActive(false); DontDestroyOnLoad(whiteFlashGO); DontDestroyOnLoad(transformSlave); DontDestroyOnLoad(gunSpriteGO); DontDestroyOnLoad(muzzleFlashGO); DontDestroyOnLoad(muzzleFlashGOAlt); try { tk2d = HeroController.instance.GetComponent <tk2dSpriteAnimator>(); } catch (Exception e) { Log(e); } }
private IEnumerator LookForShowInstantly() { while (true) { HeroActions actions = Ref.Input.inputActions; if (actions.jump.WasPressed || actions.attack.WasPressed || actions.menuCancel.WasPressed) { _showInstantly = true; break; } yield return(new WaitForEndOfFrame()); } }
private IEnumerator ListenForInput() { HeroActions buttons = Ref.Input.inputActions; while (true) { if (selected > 0 && buttons.up.WasPressed) { selected--; UpdatePositions(); } else if (selected < validItems.Length - 1 && buttons.down.WasPressed) { selected++; UpdatePositions(); } yield return(new WaitForEndOfFrame()); } }
private Vector2 fireballsAndTrail(Vector2 change) { if (blackmothSymbolsExist) { // Why does this work but not just checking it directly? if (blackmothGrubberCheck()) { return(change); } } HeroActions direction = GameManager.instance.inputHandler.inputActions; if (direction.up.IsPressed && !direction.down.IsPressed && change.y > 0.00001f) { if (fbTime <= 0.0) { spawnFireballs(); // Stop fireballs from spawning mid dash. } else if (fbTime <= 0.2) { fbTime = 0.2; } } // ReSharper disable once InvertIf This looks really dumb if (useFT) { currentTrailSprite = redwing_flame_gen.rng.Next(0, fireTrailTextures.Length); spawnFireTrail(change); useFT = false; } return(change); }
private bool CheckForDash() { if (_antiTurboDashFrames > 0) { return(true); } _dashCooldownStart = HeroController.instance.DASH_COOLDOWN_CH * 0.4f; _dashCooldownHasDash = HeroController.instance.DASH_COOLDOWN_CH * 0.1f; GetPrivateField("dashQueueSteps").SetValue(HeroController.instance, 0); GetPrivateField("dashQueuing").SetValue(HeroController.instance, false); HeroActions direction = GameManager.instance.inputHandler.inputActions; if (PlayerData.instance.GetBool("equippedCharm_35")) { Log("Got to grubber"); GetPrivateField("dashCooldownTimer").SetValue(HeroController.instance, 0f); GetPrivateField("shadowDashTimer").SetValue(HeroController.instance, 0f); } if (direction.up.IsPressed) { _dashDirection.y = 1; } else if (direction.down.IsPressed && !HeroController.instance.cState.onGround) { _dashDirection.y = -1; } else { _dashDirection.y = 0; } if (direction.right.IsPressed) { _dashDirection.x = 1; } else if (direction.left.IsPressed) { _dashDirection.x = -1; } else if (_dashDirection.y == 0) { _dashDirection.x = HeroController.instance.cState.facingRight ? 1 : -1; } else { _dashDirection.x = 0; } LogDebug($@"Dash direction: {_dashDirection}"); if (!PlayerData.instance.GetBool("hasDash")) { _dashDirection.y = 0; _dashDirection.x = HeroController.instance.cState.facingRight ? 1 : -1; } DoDash(); // Fixes TC problem where after tink sharp shadow is broken _sharpShadowFsm.SetState("Idle"); return(true); }
private IEnumerator ShowPopup() { // Check for skipping popup Coroutine skipCoroutine = StartCoroutine(LookForShowInstantly()); // Begin dimming the scene GameObject dimmer = CanvasUtil.CreateImagePanel(gameObject, BlackPixel, new CanvasUtil.RectData(Vector2.zero, Vector2.zero, Vector2.zero, Vector2.one)); dimmer.GetComponent <Image>().preserveAspect = false; CanvasGroup dimmerCG = dimmer.AddComponent <CanvasGroup>(); dimmerCG.blocksRaycasts = false; dimmerCG.interactable = false; dimmerCG.alpha = 0; StartCoroutine(FadeInCanvasGroup(dimmerCG)); yield return(WaitForSeconds(0.1f)); // Aim for 400 high prompt image float scaler = _imagePrompt.texture.height / 400f; Vector2 size = new Vector2(_imagePrompt.texture.width / scaler, _imagePrompt.texture.height / scaler); // Begin fading in the top bits of the popup GameObject topImage = CanvasUtil.CreateImagePanel(gameObject, _imagePrompt, new CanvasUtil.RectData(size, Vector2.zero, new Vector2(0.5f, 0.75f), new Vector2(0.5f, 0.8f))); GameObject topTextOne = CanvasUtil.CreateTextPanel(gameObject, _takeText, 34, TextAnchor.MiddleCenter, new CanvasUtil.RectData(new Vector2(1920, 100), Vector2.zero, new Vector2(0.5f, 0.55f), new Vector2(0.5f, 0.55f)), Fonts.Get("Perpetua")); GameObject topTextTwo = CanvasUtil.CreateTextPanel(gameObject, _nameText, 76, TextAnchor.MiddleCenter, new CanvasUtil.RectData(new Vector2(1920, 300), Vector2.zero, new Vector2(0.5f, 0.49f), new Vector2(0.5f, 0.49f))); CanvasGroup topImageCG = topImage.AddComponent <CanvasGroup>(); CanvasGroup topTextOneCG = topTextOne.AddComponent <CanvasGroup>(); CanvasGroup topTextTwoCG = topTextTwo.AddComponent <CanvasGroup>(); topImageCG.blocksRaycasts = false; topImageCG.interactable = false; topImageCG.alpha = 0; topTextOneCG.blocksRaycasts = false; topTextOneCG.interactable = false; topTextOneCG.alpha = 0; topTextTwoCG.blocksRaycasts = false; topTextTwoCG.interactable = false; topTextTwoCG.alpha = 0; StartCoroutine(FadeInCanvasGroup(topImageCG)); StartCoroutine(FadeInCanvasGroup(topTextOneCG)); yield return(StartCoroutine(FadeInCanvasGroup(topTextTwoCG))); // Animate the middle fleur GameObject fleur = CanvasUtil.CreateImagePanel(gameObject, Frames[0], new CanvasUtil.RectData(new Vector2(Frames[0].texture.width / 1.6f, Frames[0].texture.height / 1.6f), Vector2.zero, new Vector2(0.5f, 0.4125f), new Vector2(0.5f, 0.4125f))); yield return(StartCoroutine(AnimateFleur(fleur, 12))); yield return(WaitForSeconds(0.25f)); // Fade in the remaining text GameObject botTextOne = CanvasUtil.CreateTextPanel(gameObject, _buttonText, 34, TextAnchor.MiddleCenter, new CanvasUtil.RectData(new Vector2(1920, 100), Vector2.zero, new Vector2(0.5f, 0.335f), new Vector2(0.5f, 0.335f)), Fonts.Get("Perpetua")); GameObject botTextTwo = CanvasUtil.CreateTextPanel(gameObject, _descOneText, 34, TextAnchor.MiddleCenter, new CanvasUtil.RectData(new Vector2(1920, 100), Vector2.zero, new Vector2(0.5f, 0.26f), new Vector2(0.5f, 0.26f)), Fonts.Get("Perpetua")); GameObject botTextThree = CanvasUtil.CreateTextPanel(gameObject, _descTwoText, 34, TextAnchor.MiddleCenter, new CanvasUtil.RectData(new Vector2(1920, 100), Vector2.zero, new Vector2(0.5f, 0.205f), new Vector2(0.5f, 0.205f)), Fonts.Get("Perpetua")); CanvasGroup botTextOneCG = botTextOne.AddComponent <CanvasGroup>(); CanvasGroup botTextTwoCG = botTextTwo.AddComponent <CanvasGroup>(); CanvasGroup botTextThreeCG = botTextThree.AddComponent <CanvasGroup>(); botTextOneCG.blocksRaycasts = false; botTextOneCG.interactable = false; botTextOneCG.alpha = 0; botTextTwoCG.blocksRaycasts = false; botTextTwoCG.interactable = false; botTextTwoCG.alpha = 0; botTextThreeCG.blocksRaycasts = false; botTextThreeCG.interactable = false; botTextThreeCG.alpha = 0; yield return(StartCoroutine(FadeInCanvasGroup(botTextOneCG))); StartCoroutine(FadeInCanvasGroup(botTextTwoCG)); yield return(StartCoroutine(FadeInCanvasGroup(botTextThreeCG))); yield return(WaitForSeconds(1.5f)); // Can I offer you an egg in this trying time? GameObject egg = CanvasUtil.CreateImagePanel(gameObject, AreaRando.GetSprite("UI.egg"), new CanvasUtil.RectData( new Vector2(AreaRando.GetSprite("UI.egg").texture.width / 1.65f, AreaRando.GetSprite("UI.egg").texture.height / 1.65f), Vector2.zero, new Vector2(0.5f, 0.1075f), new Vector2(0.5f, 0.1075f))); CanvasGroup eggCG = egg.AddComponent <CanvasGroup>(); eggCG.blocksRaycasts = false; eggCG.interactable = false; eggCG.alpha = 0; // Should wait for one fade in, don't want to poll input immediately yield return(FadeInCanvasGroup(eggCG)); // Stop doing things instantly before polling input if (!_showInstantly) { StopCoroutine(skipCoroutine); } _showInstantly = false; // Save the coroutine to stop it later Coroutine coroutine = StartCoroutine(BlinkCanvasGroup(eggCG)); // Wait for the user to cancel the menu while (true) { HeroActions actions = Ref.Input.inputActions; if (actions.jump.WasPressed || actions.attack.WasPressed || actions.menuCancel.WasPressed) { break; } yield return(new WaitForEndOfFrame()); } // Fade out the full popup yield return(FadeOutCanvasGroup(gameObject.GetComponent <CanvasGroup>())); // Small delay before hero control yield return(WaitForSeconds(0.75f)); // Optionally send FSM event after finishing if (_fsmObj != null && _fsmEvent != null) { FSMUtility.SendEventToGameObject(_fsmObj, _fsmEvent); } // Stop the egg routine and destroy everything StopCoroutine(coroutine); Destroy(gameObject); }
public void Update() { if (scene != Constants.MENU_SCENE) { return; } float t = Time.realtimeSinceStartup; if (_uim.menuState != MainMenuState.SAVE_PROFILES) { MoreSaves.PageLabel.CrossFadeAlpha(0, 0.25f, false); return; } _ih = _ih ? _ih : _uim.GetAttr <UIManager, InputHandler>("ih"); HeroActions heroActions = _ih.inputActions; bool updateSaves = false; bool holdingLeft = heroActions.paneLeft.IsPressed; bool holdingRight = heroActions.paneRight.IsPressed; bool pressedDN = heroActions.dreamNail.WasPressed; if (pressedDN) { if (_selectedSaveSlot != null) { string filepath = Application.persistentDataPath + GetLockFilename((int)_selectedSaveSlot.saveSlot); if (File.Exists(filepath)) { _selectedSaveSlot.StartCoroutine(_uim.FadeInCanvasGroup(_selectedSaveSlot.clearSaveButton)); File.Delete(filepath); } else { _selectedSaveSlot.StartCoroutine(_uim.FadeOutCanvasGroup(_selectedSaveSlot.clearSaveButton)); FileStream fs = File.Create(filepath); fs.Close(); } } } if (heroActions.paneRight.WasPressed && t - _lastInput > 0.05f) { _firstInput = t; _queueRight++; } if (heroActions.paneLeft.WasPressed && t - _lastInput > 0.05f) { _firstInput = t; _queueLeft++; } if (_queueRight == 0 && holdingRight && t - _firstInput > INPUT_WINDOW) { _queueRight = 1; } if (_queueLeft == 0 && holdingLeft && t - _firstInput > INPUT_WINDOW) { _queueLeft = 1; } if (_pagesHidden || !_pagesHidden && t - _lastPageTransition > TRANSISTION_TIME) { if (_queueRight > 0 && t - _lastInput > INPUT_WINDOW / 2) { _lastInput = t; _currentPage += _queueRight; _queueRight = 0; updateSaves = true; } if (_queueLeft > 0 && t - _lastInput > INPUT_WINDOW / 2) { _lastInput = t; _currentPage -= _queueLeft; _queueLeft = 0; updateSaves = true; } _currentPage %= _maxPages; if (_currentPage < 0) { _currentPage = _maxPages - 1; } MoreSaves.PageLabel.text = $"Page {_currentPage + 1}/{_maxPages}"; } if (!_pagesHidden && updateSaves && t - _lastPageTransition > TRANSISTION_TIME) { _lastPageTransition = t; _pagesHidden = true; HideAllSaves(); } if (_pagesHidden && t - _lastInput > INPUT_WINDOW && t - _lastPageTransition > TRANSISTION_TIME) { _lastPageTransition = t; _pagesHidden = false; ShowAllSaves(); } if (t - _lastPageTransition < TRANSISTION_TIME * 2) { return; } if (_pagesHidden || Slots.All(x => x.state != HIDDEN)) { MoreSaves.PageLabel.CrossFadeAlpha(1, 0.25f, false); } else { MoreSaves.PageLabel.CrossFadeAlpha(0, 0.25f, false); } }
private bool dashTapped() { if (antiTurboLeft != 0) { return(true); } if (gng_bindings.hasCharmBinding() && redwing_hooks.ftTime > 0.0) { return(false); } hasSharpShadowCached = PlayerData.instance.GetBool("equippedCharm_16"); getPrivateField("dashQueueSteps").SetValue(HeroController.instance, 0); getPrivateField("dashQueuing").SetValue(HeroController.instance, false); HeroActions direction = GameManager.instance.inputHandler.inputActions; if (direction.up.IsPressed) { DashDirection.y = 1f; } else if (direction.down.IsPressed && !HeroController.instance.cState.onGround) { DashDirection.y = -1f; } else { DashDirection.y = 0; } if (direction.right.IsPressed) { DashDirection.x = 1f; } else if (direction.left.IsPressed) { DashDirection.x = -1f; } // ReSharper disable once CompareOfFloatsByEqualityOperator else if (DashDirection.y == 0) { DashDirection.x = HeroController.instance.cState.facingRight ? 1 : -1; } else { DashDirection.x = 0; } //log($@"Dash direction: {DashDirection}"); if (!PlayerData.instance.GetBool("hasDash")) { DashDirection.y = 0; DashDirection.x = HeroController.instance.cState.facingRight ? 1 : -1; } if (!PlayerData.instance.GetBool("hasShadowDash")) { if (Math.Abs(DashDirection.y) > 0.001f && Math.Abs(DashDirection.x) > 0.001f) { DashDirection.x = 0f; } } doDash(); // Fixes TC problem where after tink sharp shadow is broken if (sharpShadowFSM != null) { sharpShadowFSM.SetState("Idle"); } return(true); }
static void Main(string[] args) { // TODO: Создать Repository Pattern // TODO: Добавить базу данных // TODO: Подумать о паттернах // TODO: Добавить сервисы чатов // Для Кексика // TODO: Логика выбора героя, чтобы пользователь сам выбрать героя + // Продумать что можеть делать герой // Продумай в начала, два режима, первый можно самому выбрать героя, второй рандомно назначается + //Герои #region HeroModels Creature hero1 = new Creature( "Азраэль", "Рыцарь смерти", 1000, 700); hero1.Description = "Восставший воин"; Creature hero2 = new Creature( "Хок", "Головорез", 1000, 500); hero2.Description = "Ловкач"; Creature hero3 = new Creature( "Зик", "Паладин", 1000, 800); hero3.Description = "Воин света"; #endregion //выбор героя первого игрока #region CreateHero Console.WriteLine($"Приветствую, незнакомец. Кто ты?\n(выберите героя по номеру, либо любую другую цифру для рандомного выбора)\n"); Creature[] heroes = new Creature[] { hero1, hero2, hero3 }; for (int i = 0; i < heroes.Length; i++) { Console.WriteLine($"Герой{i + 1}: {heroes[i].HeroClass}. {heroes[i].Description}"); } ; Creature player1 = new Creature("", "", 0, 0); //создание игрока на которого навешиваются доп функции int chan = Int32.Parse(Console.ReadLine()); // упрощенный вариант для ввода чисел if (chan == 1) { player1 = hero1; } else if (chan == 2) { player1 = hero2; } else if (chan == 3) { player1 = hero3; } else { Console.WriteLine($"Рандомный выбор"); Random rnd = new Random(); chan = rnd.Next(1, 3); if (chan == 1) { player1 = hero1; } else if (chan == 2) { player1 = hero2; } else if (chan == 3) { player1 = hero3; } } Console.WriteLine($"Ваш выбор:{player1.Name}. {player1.HeroClass}\nЗдоровье:{player1.HP}поинтов"); Console.WriteLine($"Кошелек:{player1.Gold} золото"); #endregion //модели оружия #region WeaponModels Weapon sword1 = new Weapon( "Большой меч", 200, "Двуручное", 120); Weapon daggers1 = new Weapon( "Кинжалы", 150, "Двуручное", 70); Weapon maul1 = new Weapon( "Гигантский Молот", 250, "Двуручное", 140); #endregion // Выбор оружия для первого игрока #region ChangeWepon ItemProduct[] weapons = new ItemProduct[] { sword1, daggers1, maul1, }; Console.WriteLine($"\nПеред выходом на арену необходимо выбрать оружие:\n"); for (int i = 0; i < weapons.Length; i++) { Console.WriteLine($"Item {i + 1}:{weapons[i].Name}" + $"\n Price:{weapons[i].Price}\n"); } Console.WriteLine($"\nВыберите экипировку\"\n"); int chan2 = Int32.Parse(Console.ReadLine()); if (chan2 == 1) { Console.WriteLine($"\nВыбран:{sword1.Name}\nУрон:{sword1.Damage}\n"); player1.WeaponHero = (sword1.Name, sword1.Damage); player1.BuyItem(sword1); Console.WriteLine($"Золото 1-го игрока:{player1.Gold}\n"); } if (chan2 == 2) { Console.WriteLine($"\nВыбран:{daggers1.Name}\nУрон:{daggers1.Damage}\n"); player1.WeaponHero = (daggers1.Name, daggers1.Damage); player1.BuyItem(daggers1); Console.WriteLine($"Золото 1-го игрока:{player1.Gold}\n"); } if (chan2 == 3) { Console.WriteLine($"\nВыбран:{maul1.Name}\nУрон:{maul1.Damage}\n"); player1.WeaponHero = (maul1.Name, maul1.Damage); player1.BuyItem(maul1); Console.WriteLine($"Золото 1-го игрока:{player1.Gold}\n"); } #endregion Console.WriteLine($"{player1.HeroClass} бьет {player1.WeaponHero.name} на {player1.WeaponHero.damage} урона"); IHeroActions heroActions = new HeroActions(); //игрок атакует другого персонажа player1.Atack(hero3); Console.WriteLine($"{hero3.HP}"); #region Пригодится позже Elixir health_elixir = new Elixir( "Эликсир здоровья", 50); Elixir poison_elixir = new Elixir( "Эликсир яда", 50); Armor plate = new Armor( "Полный доспех", 500, 50); #endregion }