public override void Enter()
        {
            base.Enter();
            _crow.lr.enabled = true;
            _caught          = false;
            _crow.lr.SetPosition(0, _crow.getThrowChainPosition().position); //TODO chainPosition
            _crow.lr.startWidth = 0.3f;
            _crow.lr.endWidth   = 0.3f;

            Collider[] playerHit = Physics.OverlapSphere(_crow.transform.position, 14f, LayerMask.GetMask("Player"));
            if (playerHit.Length > 0)
            {
                _grabPosition   = playerHit[0].GetComponent <PlayerStatus>().getGrabZone().position;
                _playerPosition = playerHit[0].transform.position;
                _player         = playerHit[0].gameObject;
                _projectile     = _crow.instantiateProjectileChain();
                _projectile.GetComponent <ChainProjectile>().setTarget(_grabPosition, _crow.transform.position);
            }
            else
            {
                _stateMachine.ChangeState(_crow._playerDetect);
            }
        }
예제 #2
0
        public override void Enter()
        {
            base.Enter();
            _begin        = Time.time;
            _spitPosition = _iceCrow.getThrowChainPosition().position;

            /*WaterCrow w = _waterCrow;
             * Transform _waterSpit = _waterCrow.getThrowChainPosition();*/

            _counter = 0f;
            _lineRenderer.enabled = true;
            _lineRenderer.SetPosition(0, _spitPosition);
            _lineRenderer.startWidth = 0.3f;
            _lineRenderer.endWidth   = 0.3f;
            try{
                _waterCrow = _iceCrow.GetWaterCrow();
                if (_waterCrow == null)
                {
                    _stateMachine.ChangeState(_iceCrow._MoveState);
                }

                _dist        = Vector3.Distance(_spitPosition, _waterCrow.getThrowChainPosition().position);
                _distToHalja = Vector3.Distance(_spitPosition, _iceCrow.GetHalja().getThrowChainPosition().position);
                if (!_iceCrow.IsIneluttable())
                {
                    _secondLr         = _iceCrow.getThrowChainPosition().GetComponent <LineRenderer>();
                    _secondLr.enabled = true;
                    _secondLr.SetPosition(0, _spitPosition);
                    _secondLr.startWidth = 0.3f;
                    _secondLr.endWidth   = 0.3f;
                }
            }catch (NullReferenceException e) {
                _stateMachine.ChangeState(_iceCrow._MoveState);
            }catch (MissingReferenceException m) {
                _stateMachine.ChangeState(_iceCrow._MoveState);
            }
        }
예제 #3
0
        public override void Update()
        {
            base.Update();
            try{
                _iceCrow.setPlayerPosition(_iceCrow.isPlayerInAggroRange());

                if (!_iceCrow.IsIneluttable())
                {
                    if (_secondCounter <= _distToHalja) //just a simple animation
                    {
                        _secondCounter += .1f / _lineDrawSpeed;
                        float   x              = Mathf.Lerp(0, _distToHalja, _secondCounter);
                        Vector3 pointA         = _spitPosition;
                        Vector3 pointB         = _iceCrow.GetHalja().getThrowChainPosition().position;
                        Vector3 pointAngleLine = x * Vector3.Normalize(pointB - pointA) + pointA;
                        _secondLr.SetPosition(1, pointAngleLine);
                    }
                }

                if (_counter <= _dist) //just a simple animation
                {
                    _counter += .1f / _lineDrawSpeed;
                    float   x              = Mathf.Lerp(0, _dist, _counter);
                    Vector3 pointA         = _spitPosition;
                    Vector3 pointB         = _waterCrow.getThrowChainPosition().position;
                    Vector3 pointAngleLine = x * Vector3.Normalize(pointB - pointA) + pointA;
                    _lineRenderer.SetPosition(1, pointAngleLine);
                }
                _lineRenderer.SetPosition(0, _spitPosition);
                _lineRenderer.SetPosition(1, _waterCrow.getThrowChainPosition().position);
                if (!_iceCrow.IsIneluttable())
                {
                    _secondLr.SetPosition(0, _spitPosition);
                    _secondLr.SetPosition(1, _iceCrow.GetHalja().getThrowChainPosition().position);
                }

                RaycastHit Hit;

                if (Physics.Raycast(_spitPosition, (_waterCrow.getThrowChainPosition().position - _spitPosition).normalized, out Hit,
                                    Vector3.Distance(_spitPosition, _waterCrow.getThrowChainPosition().position), LayerMask.GetMask("Player")))
                {
                    StunData st = new StunData();
                    st.isEmpty = false;
                    st.time    = 3f;
                    Hit.collider.gameObject.GetComponent <PlayerStatus>().AddStatus(new Effects(new SlowData(), st, new DamageOverTimeData(),
                                                                                                new DamageData(), new FearData(), false, new SlowOverAreaData(), new DamageOverAreaData(), new EnhanceData()));
                }

                if (!_iceCrow.IsIneluttable())
                {
                    if (Physics.Raycast(_spitPosition, (_iceCrow.GetHalja().getThrowChainPosition().position - _spitPosition).normalized, out Hit,
                                        Vector3.Distance(_spitPosition, _iceCrow.GetHalja().getThrowChainPosition().position), LayerMask.GetMask("Player")))
                    {
                        StunData st = new StunData();
                        st.isEmpty = false;
                        st.time    = 3f;
                        Hit.collider.gameObject.GetComponent <PlayerStatus>().AddStatus(new Effects(new SlowData(), st, new DamageOverTimeData(),
                                                                                                    new DamageData(), new FearData(), false, new SlowOverAreaData(), new DamageOverAreaData(), new EnhanceData()));
                    }
                }

                if (Time.time >= _begin + _iceCrow.getUnbreakableBondDuration())
                {
                    _stateMachine.ChangeState(_iceCrow._MoveState);
                }
            }catch (NullReferenceException e) {
                _stateMachine.ChangeState(_iceCrow._MoveState);
            }catch (MissingReferenceException m) {
                _stateMachine.ChangeState(_iceCrow._MoveState);
            }
        }