예제 #1
0
    // +Y 이동
    public void moveUp()
    {
        CD = P_UpCollis.GetComponent <CharatorDetector>();

        //좌표값 오류로 초기화 시켜줘야함
        moving = player.transform.position;

        // 이동 조건 : 계단에서만 이동 가능하고, 불이 있다면 이동하지 않음
        // AP(행동력)이 있을 때만 행동(불끄기, 이동)이 가능함

        // AP 체크
        if (GM.playAP == 0)
        {
            print("AP없음");
        }
        else
        {
            //CharaterDetecter에 불이 닿았는지 판별
            //닿아 있다면 이동하지 않고 불을 끄는 행동을 한다. AP -1
            //계단에서만 상-하 불을 끌 수 있다
            if (CD.hitFire == true && (moving.x >= -0.1 && moving.x <= 0.1))
            {
                player.transform.position = moving; //이동하지 않음
                if (SUI.player1_Range == 2)
                {
                    //캐릭터와 부딪힌 불 왼쪽에 불이 있는지 FireDetecter에서 참조한다
                    if (CD.cdr.UpCollis.GetComponent <FireDetector>().fr != null)
                    {
                        //불 왼쪽에 불이 닿아 있다면 삭제
                        moving = CD.cdr.UpCollis.GetComponent <FireDetector>().fr.gameObject.transform.position;
                        WC.waterAction(moving);
                        Destroy(CD.cdr.UpCollis.GetComponent <FireDetector>().fr.gameObject);
                    }
                }
                moving = new Vector3(CD.cdr.gameObject.transform.position.x, CD.cdr.gameObject.transform.position.y, CD.cdr.gameObject.transform.position.z);
                WC.waterAction(moving);
                Destroy(CD.cdr.gameObject); // 닿아 있는 불 제거
                GM.playAP--;
                SoundEffect.clip = se[1];
                SoundEffect.Play();
            }
            //닿아 있지 않다면 이동. AP -1
            else if (moving.y <= 3.4f && (moving.x >= -0.1 && moving.x <= 0.1))
            {
                player.transform.Translate(0, 0.7f, 0);
                GM.playAP--;
                SoundEffect.clip = se[0];
                SoundEffect.Play();
            }
        }
    }
예제 #2
0
    //AP회복, 타이머
    void Update()
    {
        timer -= Time.deltaTime;
        if (timer < 0.0f)
        {
            timer = 15.0f;
        }
        AP_Checker();
        touchRay();

        if (touchFire && (touchFire.transform.position == coll.transform.position))
        {
            if (coll.gameObject.transform.position.y < 0 && GM.playAP >= 3)
            {
                WC.waterAction(coll.gameObject.transform.position);
                Destroy(coll.gameObject);
                GM.playAP -= 3;
            }
            else if (coll.gameObject.transform.position.y < 2.1 && GM.playAP >= 4)
            {
                WC.waterAction(coll.gameObject.transform.position);
                Destroy(coll.gameObject);
                GM.playAP -= 4;
            }
            else if (coll.gameObject.transform.position.y < 4.2 && GM.playAP >= 5)
            {
                WC.waterAction(coll.gameObject.transform.position);
                Destroy(coll.gameObject);
                GM.playAP -= 5;
            }
            else
            {
                print("AP가 부족하여 끌 수 없음");
            }
            gameObject.transform.position = new Vector3(0, -2.2f, 0);
        }
    }