private void Screamer(PositionInfo positionInfo, Transform monsterTransform) { GameController.playerLose = true; MonsterTools.UsePositionInfo(positionInfo, monsterTransform, monsterAnim); meshObject.enabled = true; ScreamerEffect(); }
protected IEnumerator MonsterEmergence(PositionInfo[] positionInfo) { meshObject = monsterModel.GetComponent <SkinnedMeshRenderer>(); monsterTransform = gameObject.GetComponent <Transform>(); //Кешируем Transform monsterAnim = monsterAnimHandler.GetComponent <Animation>(); meshObject.enabled = !meshObject.enabled; //Выключаем модель монстра while (!monsterOver) { bool isForcedAppearNeeded = false; for (int i = 0; i < (generalTime * Tools.chekerIECoeficient); i++) //Ждем появления монстра { if (SafeTimeCondition(ref isForcedAppearNeeded)) //Запускаем отсчет появления заново, если игрок выполнил нужное условие { i = 0; } if (isForcedAppearNeeded) //Прерываем цикл, если выполнено условие внезапного появления { break; } timeToAppear = (generalTime - i / Tools.chekerIECoeficient); //Записываем время до появление монстра в публичную переменную yield return(new WaitForSeconds(1 / Tools.chekerIECoeficient)); } positionKey = (monsterStadia * 3) + Random.Range(0, Tools.GetMaxValue(2)); //Умножаем на 3, ибо всего 3 стадии. generalTime = Random.Range(minTimeToAppear, Tools.GetMaxValue(maxTimeToAppear)); BasicAppearEffect(positionInfo[positionKey].soundNum); //Монстр появляется yield return(new WaitForSeconds(EyeBlinkController.halfTimeBlink)); //время, специально подобранное под анимацию моргания. Когда игрок ничего не видит, монстр появляется. MonsterTools.UsePositionInfo(positionInfo[positionKey], monsterTransform, monsterAnim); meshObject.enabled = !meshObject.enabled; //Монстр появляется bool pauseCycleNeeded = false; //Нужна ли пауза bool isConditionPerformedFlag = false; //Выполнено ли условие безопасного выхода for (int i = 0; i < waitingTime * Tools.chekerIECoeficient; i++) //Время ожидания монстра { if (StopWaitingTimeCondition(ref isConditionPerformedFlag, ref pauseCycleNeeded)) { break; //Прерываем счетчик } if (pauseCycleNeeded) //Приостанавливаем цикл ожидания, если необходима пауза { i = 0; } yield return(new WaitForSeconds(1 / Tools.chekerIECoeficient)); } BasicDisappearEffect(); //Монстр исчезает yield return(new WaitForSeconds(EyeBlinkController.halfTimeBlink)); meshObject.enabled = !meshObject.enabled; if (!isConditionPerformedFlag) //Если условие безопасного выхода не выполнено { if (monsterStadia >= 2) //Если стадия монстра выше/равна 2, игра закончена { monsterOver = !monsterOver; } else { waitingTime -= debuffWaitingTime; //В следующий раз время ожидания монстра сократится monsterStadia++; heartBitting.Play(); //Проигрываем звук сердцебиения } } } yield return(new WaitForSeconds(EyeBlinkController.halfTimeBlink)); //чтобы игрок не "проморгал" скример Screamer(positionInfo[screamerArrayPosition], monsterTransform); }
void Start() { halfOfGameTime = GameController.gameTime / 2; undercoverSounds = stickmanUndercoverSoundsObj.GetComponent <StickmanUndercoverSounds>(); lampScript = lamphead.GetComponent <LampScript>(); pauseButton = pauseButtonObject.GetComponent <PauseButton>(); MonsterTools.PositionsInfoInitialization(positionsInfo); //Инициализируем массив positionsInfo[0].position = new Vector3(16.34f, 14.02f, 1.6f); //Координаты позиции монстра positionsInfo[0].rotation = new Vector3(0f, -19.999f, 0f); //Координаты поворота positionsInfo[0].animationName = animationHeadRotateLeft; //Номер анимации positionsInfo[0].soundNum = 1; //Номер звука positionsInfo[1].position = new Vector3(47.29f, 14.1f, 34.66f); positionsInfo[1].rotation = new Vector3(0f, -89.62901f, 0f); positionsInfo[1].animationName = animationHeadRotateRight; positionsInfo[1].soundNum = 2; //Номер звука positionsInfo[2].position = new Vector3(47.36f, 14.1f, -16.96f); positionsInfo[2].rotation = new Vector3(0f, -89.62901f, 0f); positionsInfo[2].animationName = animationHeadRotateLeft; positionsInfo[2].soundNum = 1; //Номер звука positionsInfo[3].position = new Vector3(30.83f, 14.1f, 3.59f); positionsInfo[3].rotation = new Vector3(0f, 86.275f, 0f); positionsInfo[3].animationName = animationHeadRotateLeft; positionsInfo[3].soundNum = 0; //Номер звука positionsInfo[4].position = new Vector3(48.85727f, 14.1f, 27.96603f); positionsInfo[4].rotation = new Vector3(0f, 146.743f, 0f); positionsInfo[4].animationName = animationHeadRotateLeft; positionsInfo[4].soundNum = 2; //Номер звука positionsInfo[5].position = new Vector3(52.76725f, 16.76f, -17.41399f); positionsInfo[5].rotation = new Vector3(0f, 12.455f, 0f); positionsInfo[5].animationName = animationHeadRotateLeft; positionsInfo[5].soundNum = 1; //Номер звука positionsInfo[6].position = new Vector3(55.83f, 14.26f, 14.97f); positionsInfo[6].rotation = new Vector3(0f, 448.482f, 0f); positionsInfo[6].animationName = animationHeadRotateRight; positionsInfo[6].soundNum = 0; //Номер звука positionsInfo[7].position = new Vector3(43.96393f, 14.26f, 9.109217f); positionsInfo[7].rotation = new Vector3(0f, 326.453f, 0f); positionsInfo[7].animationName = animationEphilepsy; positionsInfo[7].soundNum = 3; //Номер звука positionsInfo[8].position = new Vector3(46.54034f, 13.57f, -1.232216f); positionsInfo[8].rotation = new Vector3(0f, 241.038f, 0f); positionsInfo[8].animationName = animationHeadRotateRight; positionsInfo[8].soundNum = 0; //Номер звука positionsInfo[9].position = new Vector3(60.59021f, 14.26f, 6.704445f); positionsInfo[9].rotation = new Vector3(0f, 361.793f, 0f); positionsInfo[9].animationName = animationScreamer; positionsInfo[9].soundNum = 4; //Номер звука monsterEmergenceCourutine = StartCoroutine(routine: MonsterEmergence(positionsInfo)); }
private bool forcedAppearHappened = false; //Было ли внезапное появление void Start() { halfOfGameTime = GameController.gameTime / 2; lampScript = lampHead.GetComponent <LampScript>(); MonsterTools.PositionsInfoInitialization(positionsInfo); //Инициализируем массив positionsInfo[0].position = new Vector3(10.26559f, 4.32f, -2.823093f); //Координаты позиции монстра positionsInfo[0].rotation = new Vector3(0f, -111.491f, 0f); //Координаты поворота positionsInfo[0].animationName = animationIdle; //Номер анимации positionsInfo[0].soundNum = 0; //Номер звука positionsInfo[1].position = new Vector3(5.964944f, 4.32f, 2.508347f); positionsInfo[1].rotation = new Vector3(0f, -111.491f, 0f); positionsInfo[1].animationName = animationIdle; positionsInfo[1].soundNum = 1; //Номер звука positionsInfo[2].position = new Vector3(47.45f, 4.5f, 34.65f); positionsInfo[2].rotation = new Vector3(0f, 0f, 0f); positionsInfo[2].animationName = animationIdle; positionsInfo[2].soundNum = 0; //Номер звука positionsInfo[3].position = new Vector3(28.90191f, 4.32f, 3.15575f); positionsInfo[3].rotation = new Vector3(0f, -0.826f, 0f); positionsInfo[3].animationName = animationHeadRotateRight; positionsInfo[3].soundNum = 1; //Номер звука positionsInfo[4].position = new Vector3(29.64321f, 4.319671f, 7.093417f); positionsInfo[4].rotation = new Vector3(0f, -156.403f, 0f); positionsInfo[4].animationName = animationHeadRotateLeft; positionsInfo[4].soundNum = 2; //Номер звука positionsInfo[5].position = new Vector3(32.75f, 4.32f, 5.14f); positionsInfo[5].rotation = new Vector3(0f, -86.22501f, 0f); positionsInfo[5].animationName = animationIdle; positionsInfo[5].soundNum = 0; //Номер звука positionsInfo[6].position = new Vector3(41.78289f, 4.44f, 15.21876f); positionsInfo[6].rotation = new Vector3(0f, -128.735f, 0f); positionsInfo[6].animationName = animationRotateArms; positionsInfo[6].soundNum = 1; //Номер звука positionsInfo[7].position = new Vector3(43.86f, 4.5f, -1.186751f); positionsInfo[7].rotation = new Vector3(0f, -72.928f, 0f); positionsInfo[7].animationName = animationHeadRotateRight; positionsInfo[7].soundNum = 2; //Номер звука positionsInfo[8].position = new Vector3(57.77f, 4.5f, 17.9f); positionsInfo[8].rotation = new Vector3(0f, -72.928f, 0f); positionsInfo[8].animationName = animationHeadRotateLeft; positionsInfo[8].soundNum = 1; //Номер звука positionsInfo[9].position = new Vector3(60.324f, 2.825f, 6.41f); positionsInfo[9].rotation = new Vector3(1.44f, -272.361f, -0.059f); positionsInfo[9].animationName = animationScreamer; positionsInfo[9].soundNum = 3; //Номер звука monsterEmergenceCourutine = StartCoroutine(routine: MonsterEmergence(positionsInfo)); }