Example #1
0
    void CheckAndSwitchState()
    {
        float distToTravel  = GetFlatDistance(SpawnerTransform.position, PlayerTransform.position);
        float distTravelled = GetFlatDistance(SpawnerTransform.position, transform.position);

        if (State == ChaserState.Boost)
        {
            if (distTravelled >= distToTravel * 0.33f)
            {
                State = ChaserState.Glide;
                //Debug.Log("Entering glide phase");
            }
        }
        else if (State == ChaserState.Glide)
        {
            if (distTravelled >= distToTravel * 0.66f)
            {
                State = ChaserState.Terminal;
                //Debug.Log("Entering terminal phase");
            }
        }

        //Debug.Log(distToTravel);

        //this doesn't work, distToTravel is something absurd
        if (distToTravel <= DestroyThreshold)
        {
            Destroy(this.gameObject);
            //TODO destroy effects?
        }
    }
Example #2
0
 public ChaserController()
 {
     _targettingModule = new TargettingModule();
     _wanderingModule  = new WanderingModule();
     ConfigureDefault();
     _state = SelfTypeCreatorFactory <State> .Create <ChasingState>();
 }
Example #3
0
 private void StartChasing()
 {
     if (this.behavior != null)
     {
         this.Agent.MaxSpeed = this.speed;
         this.behavior.SetWeight(0f, this.wanderGoal);
         this.behavior.SetWeight(1f, this.chaseGoal);
         this.behavior.SetWeight(0.1f, this.centerGoal);
         this.state = ChaserState.Chase;
     }
 }
Example #4
0
    private void Awake()
    {
        m_runnerInput    = GetComponent <RunnerInput>();
        m_ChaserMove     = GetComponent <ChaserMove>();
        m_runnerStatus   = GetComponent <RunnerStatus>();
        m_rigidBody      = GetComponent <Rigidbody>();
        m_chaserColor    = GetComponentInChildren <SkinnedMeshRenderer>().material.color;
        m_playerAnimator = GetComponent <PlayerAnimator>();
        m_uIController   = GameObject.Find("UIController").GetComponent <UIController>();
        //m_uIController = GetComponent<UIController>();

        StatusInit();
        m_chaserState = ChaserState.normal;
    }
Example #5
0
    void DebugSkil()
    {
        // Rキー押してcoolTimeが0ならスタン開始
        if (Input.GetKeyDown(KeyCode.R))
        {
            ChaserSkill.Instance.StanSkilStart(gameObject);
            RunnerController.Instance.stanTime = m_stanTime;
        }

        // Tキー押してcoolTimeが0なら透明化開始
        if (Input.GetKeyDown(KeyCode.T))
        {
            m_chaserState   = ChaserState.invisible;
            m_invisibleTime = m_maxInvisibleTime;
        }
    }
Example #6
0
    public void ChaserInvisible(GameObject chaserObject, ChaserState state, float coolTime)
    {
        Color chaserColor = ChaserController.Instance.m_chaserColor;

        ChaserController.Instance.m_chaserState = state;
        Debug.Log("とぅっとぅるー");
        if (ChaserController.Instance.m_chaserState == ChaserState.invisible)
        {
            //Debug.Log("透明");
            if (coolTime == 0)
            {
                Debug.Log("透明");
                chaserObject.GetComponentInChildren <SkinnedMeshRenderer>().material.color = new Color(chaserColor.r, chaserColor.g, chaserColor.b, 0f);
                ChaserController.Instance.m_isInvisible = true;
            }
        }
    }
Example #7
0
    public void ChaserButton()
    {
        if (m_runnerInput.button_A)
        {
            Debug.Log("スキル_1");
            ChaserSkill.Instance.StanSkilStart(gameObject);
            RunnerController.Instance.stanTime = m_stanTime;
            m_uIController.GetStanImage().fillAmount = 0f;
        }

        if (m_runnerInput.button_B)
        {
            if (m_isTakePlayer)
            {
                Debug.Log("タッチ");
            }
            m_playerAnimator.KillAnimation();
            //m_timer = 0;
        }
        //else
        //{
        //    if (m_timer <= 0.5)
        //    {
        //        m_timer += Time.deltaTime;
        //    }
        //}

        if (m_runnerInput.button_X)
        {
            if (m_invisibleCoolTime == 0f)
            {
                Debug.Log("スキル_2");
                m_chaserState   = ChaserState.invisible;
                m_invisibleTime = m_maxInvisibleTime;
                m_isInvisible   = true;
                m_uIController.GetInvisibleImage().fillAmount = 0f;
            }
        }

        if (m_runnerInput.button_Y)
        {
            Debug.Log("Y");
        }
    }
Example #8
0
        private void HandleEnemyResponse(Character character, SCNNode enemy)
        {
            var direction = enemy.WorldPosition - character.Node.WorldPosition;

            if (direction.Length < this.hitDistance)
            {
                if (character.IsAttacking)
                {
                    this.state = ChaserState.Dead;

                    character.DidHitEnemy();

                    this.PerformEnemyDieWithExplosion(enemy, direction);
                }
                else
                {
                    character.WasTouchedByEnemy();
                }
            }
        }
Example #9
0
    void Start()
    {
        PlayerTransform = GameObject.FindGameObjectWithTag("Player").transform;

        SpawnerTransform = transform.parent;
        //Debug.Log(SpawnerTransform.gameObject.name);

        //initial velocity and state
        float iVelocity = Mathf.Clamp(MaxVelocity, 0, MaxAccel);
        //Debug.Log(iVelocity);
        Vector3 vecToTarget  = PlayerTransform.position - transform.position;
        Vector3 raisedVector = Quaternion.AngleAxis(BoostAngle, Vector3.left) * vecToTarget;

        //Vector3 raisedVector = vecToTarget;
        Velocity = raisedVector.normalized * iVelocity;
        //Debug.Log(Velocity.ToString());

        State = ChaserState.Boost;

        transform.forward = Velocity.normalized;
    }
Example #10
0
 void ChaserInvisibleTime()
 {
     Debug.Log(m_invisibleTime);
     // m_isInvisibleがtrueになったら透明化開始
     if (m_isInvisible)
     {
         --m_invisibleTime;
         if (m_invisibleTime < 0f)
         {
             m_invisibleTime = 0f;
         }
         if (m_invisibleTime == 0f)
         {
             // 透明化の時間が終わったら、m_isInvisibleとchaserStateをノーマルに戻す
             m_isInvisible = false;
             m_chaserState = ChaserState.normal;
             if (!m_isInvisible)
             {
                 GetComponentInChildren <SkinnedMeshRenderer>().material.color = new Color(m_chaserColor.r, m_chaserColor.g, m_chaserColor.b, 1f);
             }
         }
     }
 }
Example #11
0
    void Update()
    {
        if (far.target)
        {
            target = far.target;
        }

        if (cooldown > 0)
        {
            cooldown -= Time.deltaTime;
            return;
        }

        animator.SetFloat("speed", agent.velocity.magnitude);

        if ((target && !close.target) && _chase == null && _attack == null)
        {
            if (_attack != null)
            {
                StopCoroutine(_attack);
                _attack = null;
            }
            _chase = StartCoroutine(_Chase());
            state  = ChaserState.Chasing;
        }
        else if (close.target && _attack == null)
        {
            if (_chase != null)
            {
                StopCoroutine(_chase);
                _chase = null;
            }
            _attack = StartCoroutine(_Attack());
            state   = ChaserState.Attacking;
        }
    }
Example #12
0
 public void retrieveChaser()
 {
     _chaser = GameObject.Find("chaser").GetComponent <ChaserState> ();
 }
Example #13
0
 public void SetState(ChaserState newState) { _currentState = newState; }
Example #14
0
  // TIPS: プレイヤー追跡モード
  IEnumerator Chase() {
    var player = PlayerState.instance.transform;
    var currentCount = 0;

    while (currentCount < _loopCount) {
      if (!manager.isActive) { break; }
      _agent.SetDestination(player.position);
      if (isAlert) { yield return new WaitForSeconds(_interval); }
      yield return null;
      ++currentCount;
    }

    var result = (isAlert ? IsAlertRange() : IsChaseRange());
    if (!result) { _currentState = ChaserState.Move; }
  }
Example #15
0
 public void SetNextState(ChaserState state)
 {
     _nextState = state ?? _nextState;
 }
Example #16
0
 protected override void ExecuteCommands(Entity entity)
 {
     _state     = _nextState ?? _state;
     _nextState = null;
     ExecuteSingleCommand(ref _command, entity);
 }