コード例 #1
0
 IEnumerator FindNode()
 {
     while (true)
     {
         foreach (Spider _monster in monstersClass)
         {
             if (_monster.inGameObject)
             {
                 if (_monster.m_Script.findPlayer && !_monster.m_Script.isCornering && !_monster.m_Script.isShooting)
                 {
                     if (_monster.prePosition != _monster.GetPosition())
                     {
                         _monster.prePosition = _monster.GetPosition();
                     }
                     DirandRot _nextDR = GetNextNode(_monster);
                     if (_nextDR.Equals(null))
                     {
                         _nextDR = new DirandRot(new Vector2(), Quaternion.Euler(0, 0, 0));
                     }
                     _monster.inGameObject.GetComponent <Monster_Spider_AI>().PassNextNode(_nextDR);
                 }
             }
         }
         yield return(new WaitForSeconds(0.1f));
     }
 }
コード例 #2
0
ファイル: Monster_Spider_AI.cs プロジェクト: hand32/Mechanity
        void Move()
        {
            if (isCornering)
            {
                return;
            }


            if (!findPlayer || isHooking || isShooting)
            {
                return;
            }


            //is this have to Cornering?
            if (currentDR.Equals(null))
            {
                currentDR = new DirandRot(new Vector2(), Quaternion.Euler(0, 0, 0));
            }

            if (currentDR.dir != null && (Mathf.Round(transform.right.x) != currentDR.dir.x && Mathf.Round(transform.right.y) != currentDR.dir.y))
            {
                if (!isCornering)
                {
                    Cornering(currentDR);
                }
            }
            else
            {
                if (currentDR.dir != Vector2.zero && currentDR.dir != null)
                {
                    m_Animator.SetBool("Walk", true);
                }
                else
                {
                    m_Animator.SetBool("Walk", false);
                    return;
                }
                transform.position += (Vector3)currentDR.dir * spiderInfo.moveSpeed * Time.deltaTime;
                transform.rotation  = currentDR.rot;
            }
        }