Exemple #1
0
 // Start is called before the first frame update
 void Start()
 {
     Plane01 = GameObject.Find("Plane (2)").GetComponent <RayScript>();
     Plane02 = GameObject.Find("Plane (3)").GetComponent <RayScript>();
     Plane03 = GameObject.Find("Plane (4)").GetComponent <RayScript>();
     Plane04 = GameObject.Find("Plane (5)").GetComponent <RayScript>();
     Plane05 = GameObject.Find("Plane (6)").GetComponent <RayScript>();
 }
Exemple #2
0
    IEnumerator StartBlank(SpriteRenderer srComponets, Collider2D col, float detectRange)
    {
        yield return(new WaitForSeconds(delayTime)); //일정시간동안 시작을 딜레이 합니다.

        int   randomTime;
        int   layerMask       = 1 << 9;
        float detectDelayTime = blankTime;

        while ((CollisionTargetTransform == null) && useTrigger)
        {
            yield return(new WaitForFixedUpdate());                                                     //트리거가 타겟을 발생하기 전까지 반복
        }
        while (startStatus)
        {
            while (RayScript.DetectedOverlapCircle2D(transform.position, detectRange, layerMask) != null)
            {
                if (!detectState)
                {
                    detectState = true;
                    offComponentState(srComponets, col);
                }
                print("실행");
                yield return(new WaitForSeconds(detectDelayTime));
            }
            if (detectState)
            {
                detectState = false;
            }
            switch (selectType)
            {
            case 0:
                ReverseComponentState(srComponets, col);
                break;

            case 1:
                //while 이 스위치 밖에 있을 경우 코드 실행 시간이 증가하므로 원하던 효과가 발생하지 않는다.
                yield return(new WaitForSeconds(blankTime));

                /* bool 값을 처음 true로 저장 후 역전시켜가면서 깜빡이는 효과를 줍니다. */
                ReverseComponentState(srComponets, col);
                break;

            case 2:
                randomTime = Random.Range(minTime, maxTime + 1);     // 랜덤한 시간마다 깜빡입니다.
                yield return(new WaitForSeconds(randomTime));

                ReverseComponentState(srComponets, col);
                break;
            }
        }
    }
Exemple #3
0
    void MirrorRay()
    {
        Range            = hit.distance;
        collision_object = hit.collider.gameObject;
        RayScript ray_script = collision_object.GetComponent <RayScript>();

        if (reflect_count < 1)
        {
            ray_script.startPosition = hit.point;
            ray_script.rayDirection  = Vector3.Reflect(rayDirection, hit.normal);
            ray_script.rayDirection  = new Vector3(ray_script.rayDirection.x, 0, ray_script.rayDirection.z).normalized;
            ray_script.reflect       = true;
            ray_script.reflect_count++;
        }
    }
Exemple #4
0
 void RestartValues()
 {
     if (collider != null)
     {
         collider.enabled = true;
     }
     line.enabled  = false;
     reflect_count = 0;
     Range         = 10000;
     if (collision_object != null)
     {
         RayScript ray_script = collision_object.GetComponent <RayScript>();
         ray_script.reflect = false;
         collision_object   = null;
     }
 }
    /// <summary>
    /// selectedKey를 통해 탐지방법을 전달받고 탐지 결과에 따라 protected 속성인 detectState 변수를 트리거.
    /// </summary>
    protected IEnumerator DetectObject(Rigidbody2D self, Vector2 direction, int selectedKey, float rayScale = 0.5f, int layerMask = 0, float detectTime = 0.01f, string targetTag = null)
    {
        int        xxx = 0;
        GameObject ret = null;

        detectState = true;
        while (detectState)
        {
            switch (selectedKey)
            {
            case 0:
                // print("ObjectInteraction - 0 번시작 " + layerMask);
                ret = RayScript.DetectedOverlapCircle2D(self.position, rayScale, layerMask);
                break;

            case 1:
                //print("ObjectInteraction - 1 번시작 " + layerMask);
                ret = RayScript.DetectedRayCast2D(self.position, direction, rayScale, layerMask);
                break;
            }
            if (ret != null)
            {
                Debug.Log("ObjectInteraction - " + ret.name + "와 충돌했습니다.");
                if (targetTag == null)
                {
                    detectState = false;
                }
                else
                {
                    if (ret.tag == targetTag)
                    {
                        detectState = false;
                    }
                    else
                    {
                        detectState = true;
                    }
                }
            }
            yield return(new WaitForSeconds(detectTime));
        }
    }
Exemple #6
0
    IEnumerator CheckWater()
    {
        int layer = 1 << 10;

        while (state)
        {
            yield return(new WaitForSeconds(checkWaterTime));

            if (!RayScript.DetectedOverlapCircle2D(transform.position, 0.2f, layer))
            {
                Debug.Log("FishAI.cs - not water platform");
                inWater       = false;
                rb2d.velocity = Vector2.zero;
                MovePos(rb2d, Vector2.down, force * 2, true);
            }
            else
            {
                inWater = true;
            }
        }
    }