private GameObject PlayRandomSound()
 {
     if (GameData.GetCurrentGameData().IsJesusActive)
     {
         return(PlaySound(RandomAttackSoundCollection, transform.position, 4));
     }
     return(PlaySound(RandomIdleSoundCollection, transform.position, 4));
 }
Beispiel #2
0
        public void FuckShitUp()
        {
            GetComponent <AudioSource>().Play();
            GameData.GetCurrentGameData().IsJesusActive = true;
            _nextSpawnTime  = Mathf.Infinity;
            _isAnnihilating = true;
            GameData.GetCurrentGameData().IsJesusActive = _isAnnihilating;

            _jesusParts.gameObject.SetActive(true);
            MoveToNewPoint();
        }
Beispiel #3
0
        public override void OnLookStart()
        {
            if (GameData.GetCurrentGameData().IsJesusActive)
            {
                SoundManager.GetSharedManager().PlayScratchSound(transform.position);
                _audioSource.mute = true;
                Invoke("ResumeMusic", 3);
            }

            _jesus.CalmDown();
        }
Beispiel #4
0
        void Update()
        {
            if (!GameData.GetCurrentGameData().IsGameStarted)
            {
                return;
            }

            RaycastHit hit;
            Vector3    fwd = transform.TransformDirection(Vector3.forward);

            if (Physics.Raycast(transform.position, fwd, out hit, 60))
            {
                GameObject hitObject       = hit.transform.gameObject;
                Target     hitObjectTarget = hitObject.GetComponent <Target>();
                if (hitObjectTarget != null)
                {
                    if (_lastTarget == null)
                    {
                        _lastTarget = hitObject;
                        hitObjectTarget.OnLookStart();
                    }
                    else
                    {
                        if (_lastTarget != hitObject)
                        {
                            Target lastTarget = _lastTarget.GetComponent <Target>();
                            lastTarget.OnLookEnd();
                            _lastTarget = hitObject;
                            hitObjectTarget.OnLookStart();
                        }
                    }
                }
                else
                {
                    if (_lastTarget != null)
                    {
                        Target t = _lastTarget.GetComponent <Target>();
                        t.OnLookEnd();
                        _lastTarget = null;
                    }
                }
            }
            else
            {
                if (_lastTarget != null)
                {
                    Target t = _lastTarget.GetComponent <Target>();
                    t.OnLookEnd();
                    _lastTarget = null;
                }
            }
        }
 void Update()
 {
     if (GameData.GetCurrentGameData().IsGameStarted)
     {
         _lastTimeStep += Time.deltaTime;
         if (_lastTimeStep > 1f)
         {
             _lastTimeStep = _lastTimeStep % 1f;
             if (Random.value < RandomSoundsPerMinute / 60f)
             {
                 PlayRandomSound();
             }
         }
     }
 }
Beispiel #6
0
        public void CalmDown()
        {
            if (_isAnnihilating)
            {
                _isAnnihilating = false;
                GameData.GetCurrentGameData().IsJesusActive = _isAnnihilating;
                _timeSinceLastMovement = 0;
                _jesusParts.gameObject.SetActive(false);
                DetermineNextSpawnTime();
                _laserBeamsComponent.SetSpeedBackToMin();

                foreach (Transform t in _targets)
                {
                    Elf elf = t.GetComponent <Elf>();
                    elf.StopWorking();
                }
                GameData.GetCurrentGameData().IsJesusActive = false;
                GetComponent <AudioSource>().Stop();
            }
        }
Beispiel #7
0
        public void BurnToBlack()
        {
            // object not found... can't worry about this right now
            torsoRenderer.material.color     = Color.Lerp(Color.green, Color.black, Time.time * 0.1f);
            legLeftRenderer.material.color   = Color.Lerp(Color.green, Color.black, Time.time * 0.1f);
            legRightRenderer.material.color  = Color.Lerp(Color.green, Color.black, Time.time * 0.1f);
            armLeftRenderer.material.color   = Color.Lerp(Color.green, Color.black, Time.time * 0.1f);
            armRightRenderer.material.color  = Color.Lerp(Color.green, Color.black, Time.time * 0.1f);
            handLeftRenderer.material.color  = Color.Lerp(elfSkinColor, Color.black, Time.time * 0.1f);
            handRightRenderer.material.color = Color.Lerp(elfSkinColor, Color.black, Time.time * 0.1f);
            headRenderer.material.color      = Color.Lerp(elfSkinColor, Color.black, Time.time * 0.1f);
            hatRenderer.material.color       = Color.Lerp(Color.green, Color.black, Time.time * 0.1f);
            noseRenderer.material.color      = Color.Lerp(elfSkinColor, Color.black, Time.time * 0.1f);
            hatBrimRenderer.material.color   = Color.Lerp(Color.white, Color.black, Time.time * 0.1f);
            hatBallRenderer.material.color   = Color.Lerp(Color.white, Color.black, Time.time * 0.1f);

            _isTurnedToBlack       = true;
            _rigidbody.isKinematic = true;

            _jesusDelegate.OnElfDestroyed(transform);
            GameData.GetCurrentGameData().DecrementRemainingElfCount();

            SoundManager.GetSharedManager().PlayJesusAttackSound(transform.position);
        }
 private void StartGame()
 {
     GoObject.SetActive(false);
     GameData.GetCurrentGameData().StartGame();
 }
Beispiel #9
0
        void Update()
        {
            // We don't want OnLookUpdate to be called on each frame. This is to prevent the gazing from acting faster on faster CPU's.
            // Rather, OnLookUpdate is called every _threshold seconds while the elf is under gaze by santa.
            _lastTimeStep += Time.deltaTime;
            if (_lastTimeStep + Time.deltaTime > _threshold)
            {
                _lastTimeStep = _lastTimeStep % _threshold;
                if (_isUnderGaze)
                {
                    OnLookUpdate();
                }
                else
                {
                    if (!_isTurnedToBlack)
                    {
                        _armAnimation.speed = Mathf.Max(_armAnimation.speed * 0.95f, MinWorkingSpeed);
                    }
                    else
                    {
                        _armAnimation.speed = _armAnimation.speed * 0.95f;
                    }
                }
            }
            if (Time.time - _underGazeTime > _acknowledgeSoundThreshold && s_canAcknowledge)
            {
                s_canAcknowledge = false;
                SoundManager.GetSharedManager().PlayAcknowledgeSound(transform.position);
            }
            if (Time.time - _underGazeTime > _pushedSoundTreshold && s_canBePushed)
            {
                s_canBePushed       = false;
                s_pushedAudioSource = SoundManager.GetSharedManager().PlayPushedSound(transform.position);
            }

            _focusMarker.transform.Rotate(Vector3.up * Time.deltaTime * _armAnimation.speed * 150);

            if (numHammerHits >= 10)
            {
                SpawnGift();
            }
            _shouldBurnToBlack = _isUnderJesusGaze && (Time.time - _jesusGazeStartTime > _jesusTolerance);
            if (_shouldBurnToBlack && !_isTurnedToBlack)
            {
                BurnToBlack();
            }

            if (!_isTurnedToBlack)
            {
                // Elves will look at Jesus if the head rotation is within normal "human" limits.
                Quaternion angleToTarget = Quaternion.LookRotation(JesusLookTarget.transform.position);
                float      angleDiff     = Quaternion.Angle(angleToTarget, originalDirection);
                if (!lookAtSanta)
                {
                    if (angleDiff < 90)
                    {
                        HeadJoint.transform.LookAt(JesusLookTarget.transform);
                    }
                    else
                    {
                        HeadJoint.transform.rotation = originalDirection;
                    }
                }
            }

            if (_pointOfNoReturn)
            {
                _jesusDelegate.OnElfDestroyed(transform);
                _bloodAndGoreFactory.CreateBloodAndGore(transform.position);
                GameData.GetCurrentGameData().DecrementRemainingElfCount();
                Destroy(s_pushedAudioSource);
                Destroy(gameObject);
            }
        }
Beispiel #10
0
 public override void OnLookStart()
 {
     GiftFactory.CreateSmallGift(transform.position);
     GameData.GetCurrentGameData().IncrementPresentCount();
     Destroy(gameObject);
 }