コード例 #1
0
 private void OnTriggerEntered(TargetTrigger trigger)
 {
     if (IsParentOfTrigger(trigger))
     {
         FinishBoard(trigger == _correctTrigger || _correctTrigger == null, trigger);
     }
 }
コード例 #2
0
 // Use this for initialization
 void Start()
 {
     m_trigger = GetComponentInParent <TargetTrigger>();
     if (m_trigger)
     {
         m_trigger.ActiveChanged += OnActiveChanged;
         m_indicator              = GetComponent <Renderer>();
     }
 }
コード例 #3
0
        public void Reset()
        {
            IsFinished = false;

            if (TargetTrigger != null)
            {
                TargetTrigger.Reset();
            }
        }
コード例 #4
0
 private bool IsParentOfTrigger(TargetTrigger trigger)
 {
     foreach (TargetTrigger trig in _triggers)
     {
         if (trigger == trig)
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #5
0
ファイル: AudioManager.cs プロジェクト: turbolek/Polyjam20
 private void OnGameplayBoardFinished(GameplayBoard board, TargetTrigger trigger, bool success)
 {
     if (success)
     {
         SFXAudioSource.PlayOneShot(CorrectAnswer);
     }
     else
     {
         SFXAudioSource.PlayOneShot(WrongAnswer);
     }
 }
コード例 #6
0
 private void SwitchBoards(GameplayBoard finishedBoard, TargetTrigger trigger)
 {
     if (finishedBoard == StartingBoard)
     {
         StartingBoard.Deactivate();
         OtherBoard.Activate(trigger, true);
     }
     else
     {
         OtherBoard.Deactivate();
         StartingBoard.Activate(trigger, true);
     }
 }
コード例 #7
0
    private void OnBoardFinished(GameplayBoard board, TargetTrigger trigger, bool success)
    {
        SwitchBoards(board, trigger);

        if (success)
        {
            _currentScore++;
            _scoreDisplayer.DisplayScore(_currentScore);

            CheckWin();
        }
        else
        {
            Finish(false);
        }
    }
コード例 #8
0
ファイル: ExplosionBehaviour.cs プロジェクト: jwinder86/LD27
    public void OnTriggerEnter(Collider other)
    {
        PigBehaviour  pig    = other.GetComponent <PigBehaviour>();
        TargetTrigger target = other.GetComponent <TargetTrigger>();

        if (pig != null)
        {
            pig.Stun();
        }

        if (target != null)
        {
            target.Explode();
        }

        if (other.rigidbody != null)
        {
            Vector3 direction = (other.transform.position - transform.position);
            direction.z = 0f;
            direction   = direction.normalized;

            other.rigidbody.AddForce(direction * explosionForce, ForceMode.VelocityChange);
        }
    }
コード例 #9
0
 internal void OnTargetTrigger(IEntity sender)
 {
     TargetTrigger?.Invoke(sender);
 }
コード例 #10
0
    private IEnumerator RestartCoroutine(TargetTrigger previousTrigger, bool instant)
    {
        List <TargetTrigger> triggersToSet    = new List <TargetTrigger>(_triggers).Shuffle();
        List <Sprite>        availableSprites = new List <Sprite>(_targetSprites).Shuffle();
        List <Color>         availableColors  = new List <Color>(_targetColors).Shuffle();


        if (previousTrigger == null)
        {
            previousTrigger = _triggers[0];
            previousTrigger.SetSprite(availableSprites[0]);
            previousTrigger.SetColor(availableColors[0]);
        }

        _player.SetSprite(previousTrigger.Sprite, previousTrigger.Color);

        _correctTrigger = triggersToSet[0];
        _correctTrigger.CorrectAnswerMarker.SetActive(true);
        triggersToSet.RemoveAt(0);

        if (UnityEngine.Random.Range(0f, 1f) < 0.5f)
        {
            Sprite previousSprite = GetSameSpriteFromPool(availableSprites, previousTrigger.Sprite);
            availableSprites.Remove(previousSprite);

            Color correctColor = GetSameColorFromPool(availableColors, previousTrigger.Color);
            _correctTrigger.SetColor(correctColor);
            availableColors.Remove(correctColor);

            _correctTrigger.SetSprite(availableSprites[0]);
            availableSprites.RemoveAt(0);
        }
        else
        {
            Color previousColor = GetSameColorFromPool(availableColors, previousTrigger.Color);
            availableColors.Remove(previousColor);

            Sprite correctSprite = GetSameSpriteFromPool(availableSprites, previousTrigger.Sprite);
            _correctTrigger.SetSprite(correctSprite);
            availableSprites.Remove(correctSprite);

            _correctTrigger.SetColor(availableColors[0]);
            availableColors.RemoveAt(0);
        }


        for (int i = triggersToSet.Count - 1; i >= 0; i--)
        {
            triggersToSet[i].SetColor(availableColors[i]);
            triggersToSet[i].SetSprite(availableSprites[i]);
            triggersToSet[i].CorrectAnswerMarker.SetActive(false);
            availableColors.RemoveAt(i);
            availableSprites.RemoveAt(i);
        }

        ShowGameplayParent(true);

        if (!instant)
        {
            _animator.SetTrigger("show");
            yield return(new WaitForSeconds(1f));
        }

        _player.ResetSpeed();
        _player.transform.position = _playerSpawnPoint.position;
        _player.Release();
        DisplayText("", true);
    }
コード例 #11
0
 public void Restart(TargetTrigger previousTrigger, bool instant)
 {
     StartCoroutine(RestartCoroutine(previousTrigger, instant));
 }
コード例 #12
0
 private void FinishBoard(bool success, TargetTrigger trigger)
 {
     BoardFinished?.Invoke(this, trigger, success);
 }
コード例 #13
0
 public void Activate(TargetTrigger previousTrigger, bool instant)
 {
     Restart(previousTrigger, instant);
     gameObject.SetActive(true);
 }
コード例 #14
0
    private void Start()
    {
        // Getting cache variables
        _navMeshAgent     = GetComponent <NavMeshAgent>();
        _animator         = GetComponent <Animator>();
        _mouthAudioSource = GetComponent <AudioSource>();
        _targetTrigger    = GetComponentInChildren <TargetTrigger>();
        AIDecapitation[] parts = GetComponentsInChildren <AIDecapitation>();
        foreach (AIDecapitation part in parts)
        {
            _parts.Add(part);
        }

        HandleAnimatorController();

        // Getting the skinned mesh renderers for the metamorphosis
        if (_metamorphosisMaterial != null)
        {
            SkinnedMeshRenderer[] skinnedMeshRenderers = GetComponentsInChildren <SkinnedMeshRenderer>();
            foreach (SkinnedMeshRenderer meshRenderer in skinnedMeshRenderers)
            {
                _skinnedMeshRenderers.Add(meshRenderer);
            }
        }

        // We always have the rotation of the navmesh deactivated!
        // In fact, we either rotate with the root motion rotation of the turn around animation
        // Or we rotate it manually through code.
        // In sum, the navmesh is only useful for calculating the path: steertingTarget :)
        if (_navMeshAgent != null)
        {
            _navMeshAgent.updateRotation = false;
        }

        if (_targetTrigger != null)
        {
            _targetTrigger.RegisterTargetTrigger(this);
        }

        // Storing states
        AIStateIdle stateIdle = GetComponent <AIStateIdle>();

        if (stateIdle != null)
        {
            _statesDictionary.Add(AIStateType.Idle, stateIdle);
            _statesDictionary[AIStateType.Idle].RegisterState(this);
        }

        AIStatePatrol statePatrol = GetComponent <AIStatePatrol>();

        if (statePatrol != null)
        {
            _statesDictionary.Add(AIStateType.Patrol, statePatrol);
            _statesDictionary[AIStateType.Patrol].RegisterState(this);
        }

        AIStatePursuit statePursuit = GetComponent <AIStatePursuit>();

        if (statePursuit != null)
        {
            _statesDictionary.Add(AIStateType.Pursuit, statePursuit);
            _statesDictionary[AIStateType.Pursuit].RegisterState(this);
        }

        AIStateAttack stateAttack = GetComponent <AIStateAttack>();

        if (stateAttack != null)
        {
            _statesDictionary.Add(AIStateType.Attacking, stateAttack);
            _statesDictionary[AIStateType.Attacking].RegisterState(this);
        }

        AIStateAlert stateAlert = GetComponent <AIStateAlert>();

        if (stateAlert != null)
        {
            _statesDictionary.Add(AIStateType.Alert, stateAlert);
            _statesDictionary[AIStateType.Alert].RegisterState(this);
        }

        if (_statesDictionary.ContainsKey(AIStateType.Idle) && _statesDictionary[AIStateType.Idle] != null)
        {
            ChangeState(AIStateType.Idle);
        }

        // Get all body parts snapshot
        Transform[] bodyParts = transform.GetComponentsInChildren <Transform>();
        foreach (Transform bodyPart in bodyParts)
        {
            BodyPartSnapShot bodyPartSnapshot = new BodyPartSnapShot();
            bodyPartSnapshot.transform = bodyPart;
            _bodyPartsSnapshots.Add(bodyPartSnapshot);
        }

        // At the beginning, we should always be able to scream
        _screamTimer = _screamDelay;

        // Getting the navmesh agent initial speed for damageBehavior (in case we aren't using root rotation)
        if (_navMeshAgent != null)
        {
            _initialSpeed = _navMeshAgent.speed;
        }

        _initialVehicleStoppingDistance = _vehicleStoppingDistance;
    }
コード例 #15
0
 public bool TryToStartup()
 {
     return(TargetTrigger.TryToStartUp());
 }