Exemplo n.º 1
0
 public void ConfirmItem(ItemForSale item, Item.TYPE itemType, string iTemName, int iTemPrice)
 {
     itemTypeToConfirm = itemType;
     itemNameToConfirm = iTemName;
     price             = iTemPrice;
     selectedItem      = item;
 }
Exemplo n.º 2
0
    // 들고 있는 아이템에 따른 ‘수리 진척 상태’를 반환
    public float getGainRepairment(GameObject item_go)
    {
        float gain = 0.0f;

        if (item_go == null)
        {
            gain = 0.0f;
        }
        else
        {
            Item.TYPE type = this.getItemType(item_go);
            switch (type)
            { // 들고 있는 아이템의 종류로 갈라진다.
            case Item.TYPE.IRON:
                gain = GameStatus.GAIN_REPAIRMENT_IRON;
                GameObject.Find("GameRoot").GetComponent <GameStatus>().repairCount += 3;
                break;

            case Item.TYPE.PLANT:
                gain = GameStatus.GAIN_REPAIRMENT_PLANT;
                GameObject.Find("GameRoot").GetComponent <GameStatus>().repairCount += 1;
                break;
            }
        }
        return(gain);
    }
Exemplo n.º 3
0
    public float getConsumeSatiety(GameObject item_go)
    {
        float consume = 0.0f;

        if (item_go == null)
        {
            consume = 0.0f;
        }
        else
        {
            Item.TYPE type = this.getItemType(item_go);
            switch (type)
            { // 들고 있는 아이템의 종류로 갈라진다.
            case Item.TYPE.IRON:
                consume = GameStatus.CONSUME_SATIETY_IRON; break;

            case Item.TYPE.APPLE:
                consume = GameStatus.CONSUME_SATIETY_APPLE; break;

            case Item.TYPE.PLANT:
                consume = GameStatus.CONSUME_SATIETY_PLANT; break;
            }
        }
        return(consume);
    }
Exemplo n.º 4
0
    // 아이템의 종류를 Item.TYPE형으로 반환하는 메소드.
    public Item.TYPE getItemType(GameObject item_go)
    {
        Item.TYPE type = Item.TYPE.NONE;
        if (item_go != null)
        {     // 인수로 받은 GameObject가 비어있지 않으면.
            switch (item_go.tag)
            { // 태그로 분기.
            case "Iron": type   = Item.TYPE.IRON;
                itemInfo.sprite = ironSprite;
                break;

            case "Apple": type  = Item.TYPE.APPLE;
                itemInfo.sprite = appleSprite;
                break;

            case "Plant": type  = Item.TYPE.PLANT;
                itemInfo.sprite = plantSprite;
                break;

            case "Chestnut": type = Item.TYPE.CHESTNUT;
                itemInfo.sprite   = chestnutSprite;
                break;
            }
        }
        return(type);
    }
Exemplo n.º 5
0
    // 철광석이나 식물을 든 상태에서 우주선에 접촉했는지 확인
    public bool isEventIgnitable(Item.TYPE carried_item, GameObject event_go)
    {
        bool ret = false;

        Event.TYPE type = Event.TYPE.NONE;
        if (event_go != null)
        {
            type = this.getEventType(event_go); // 이벤트 타입을 구한다.
        }
        switch (type)
        {
        case Event.TYPE.ROCKET:
            if (carried_item == Item.TYPE.IRON)
            {               // 가지고 있는 것이 철광석이라면.
                ret = true; // '이벤트할 수 있어요!'라고 응답한다.
            }
            if (carried_item == Item.TYPE.PLANT)
            {               // 가지고 있는 것이 식물이라면.
                ret = true; // '이벤트할 수 있어요!'라고 응답한다.
            }
            break;

        case Event.TYPE.MAKEFIRE:
            if (carried_item == Item.TYPE.PLANT)
            {               // 가지고 있는 것이 식물이라면.
                ret = true; // '이벤트할 수 있어요!'라고 응답한다.
            }
            break;

        case Event.TYPE.GETFIRE:
            ret = true;
            break;
        }
        return(ret);
    }
    public bool isEventIgnitable(Item.TYPE carried_item, GameObject event_go)
    {
        bool ret = false;

        Event.TYPE type = Event.TYPE.NONE;

        if (event_go != null)
        {
            type = this.getEventType(event_go); // イベントタイプを取得
        }

        switch (type)
        {
        case Event.TYPE.ROCKET:
            if (carried_item == Item.TYPE.IRON)  // 持っているのが鉄鉱石なら
            {
                ret = true;                      // 「イベントできるよ!」と返す
            }
            if (carried_item == Item.TYPE.PLANT) // 持っているのが植物なら
            {
                ret = true;                      // 「イベントできるよ!」と返す
            }
            break;
        }
        return(ret);
    }
Exemplo n.º 7
0
    public bool     isEventIgnitable(Item.TYPE carried_item, GameObject event_go)
    {
        bool ret = false;

        Event.TYPE type = Event.TYPE.NONE;
        if (event_go != null)
        {
            type = this.getEventType(event_go);
        }
        switch (type)
        {
        case Event.TYPE.ROCKET:
            if (carried_item == Item.TYPE.IRON)
            {
                ret = true;
            }
            if (carried_item == Item.TYPE.PLANT)
            {
                ret = true;
            }
            break;

        case Event.TYPE.FIRE:
            if (carried_item == Item.TYPE.APPLE)
            {
                ret = true;
            }
            if (carried_item == Item.TYPE.PLANT)
            {
                ret = true;
            }
            break;
        }
        return(ret);
    }
    private bool is_event_ignitable()
    {
        bool ret = false;

        do
        {
            if (this.closest_event == null) // 注目イベントがなければ
            {
                break;                      // falseを返す
            }

            // 持ち上げているアイテムの種類を取得
            Item.TYPE carried_item_type = this.item_root.getItemType(this.carried_item);

            // 持ち上げているアイテムの種類と、注目しているイベントの種類から
            // イベント可能化どうかを判定し、イベント不可ならfalseを返す
            if (!this.event_root.isEventIgnitable(carried_item_type, this.closest_event))
            {
                break;
            }

            ret = true; // ここまで来たらイベントを開始できると判定!
        } while (false);
        return(ret);
    }
Exemplo n.º 9
0
    // 아이템을 버리거나 줍는다.
    private void    pick_or_drop_control()
    {
        do
        {
            if (!this.key.pick)
            {
                break;
            }
            if (this.carried_item == null)
            {
                // 아이템을 가지고 있지 않을 때.
                // 가까이에 아이템이 없으면 아무것도 하지 않는다.
                if (this.closest_item == null)
                {
                    break;
                }
                this.carried_item = this.closest_item;
                this.carried_item.transform.parent        = this.transform;
                this.carried_item.transform.localPosition = Vector3.up * 2.0f;
                this.closest_item = null;
                this.sound_control.SoundPlay(Sound.SOUND.GET);                                  // sound.
                this.next_step = STEP.PICKUP;
            }
            else
            {
                // 아이템을 가지고 있을 때.
                Item.TYPE carried_item_type = this.item_root.getItemType(this.carried_item);
                switch (carried_item_type)
                {
                case Item.TYPE.APPLE:
                    GameObject.Destroy(this.carried_item);
                    this.item_root.plantTree(this.gameObject.transform.position);                               // 나무를 심는다---.
                    this.sound_control.SoundPlay(Sound.SOUND.PLANT);
                    this.next_step = STEP.PLANT;
                    break;

                case Item.TYPE.IRON:
                case Item.TYPE.PLANT:
                    this.carried_item.transform.localPosition = Vector3.forward * 1.0f;
                    this.carried_item.transform.parent        = null;

                    // 곧 바로 다시 주울 수 있도록 closest_item에 설정해 둔다.
                    // (버리고 나서 한 발도 움직이지 않고도 다시 주울 수 있도록).
                    this.closest_item = this.carried_item;
                    this.carried_item = null;
                    this.sound_control.SoundPlay(Sound.SOUND.THROW);                                            // sound.
                    this.next_step = STEP.THROW;
                    break;
                }
            }
        } while(false);
    }
Exemplo n.º 10
0
    private bool Is_Carried_Food()                       // 들고 있는 물건이 먹을것인지 판별하는 method입니다.
    {
        if (this.carried_item != null)
        {
            Item.TYPE carried_item_type = this.item_root.GetItemType(this.carried_item);

            switch (carried_item_type)              // 가지고 있는 아이템을 판별합니다.
            {
            case Item.TYPE.APPLE:                   // 사과라면
            case Item.TYPE.PLANT:                   // 혹은 식물이라면
                return(true);
            }
        }
        return(false);
    }
Exemplo n.º 11
0
    private float respawn_timer_plant      = 0.0f;  // 식물의 출현 시간.


    // 아이템의 종류를 Item.TYPE형으로 반환하는 메소드.
    public Item.TYPE getItemType(GameObject item_go)
    {
        Item.TYPE type = Item.TYPE.NONE;
        if (item_go != null)          // 인수로 받은 GameObject가 비어있지 않으면.
        {
            switch (item_go.tag)      // 태그로 분기.
            {
            case "Iron": type = Item.TYPE.IRON; break;

            case "Apple": type = Item.TYPE.APPLE; break;

            case "Plant": type = Item.TYPE.PLANT; break;
            }
        }
        return(type);
    }
    private float respawn_timer_plant       = 0.0f;  // 植物の出現時間

    // アイテムの種類を、Item.TYPE型で返すメソッド
    public Item.TYPE getItemType(GameObject item_go)
    {
        Item.TYPE type = Item.TYPE.NONE;
        if (item_go != null)     // 引数で受け取ったGameObjectが空っぽでないなら
        {
            switch (item_go.tag) // タグで分岐
            {
            case "Iron": type = Item.TYPE.IRON; break;

            case "Apple": type = Item.TYPE.APPLE; break;

            case "Plant": type = Item.TYPE.PLANT; break;
            }
        }
        return(type);
    }
Exemplo n.º 13
0
    // event---------------------------
    private bool    is_event_ignitable()
    {
        bool ret = false;

        do
        {
            if (this.closest_event == null)
            {
                break;
            }
            Item.TYPE carried_item_type = this.item_root.getItemType(this.carried_item);
            if (!this.event_root.isEventIgnitable(carried_item_type, this.closest_event))
            {
                break;
            }
            ret = true;
        } while(false);
        return(ret);
    }
Exemplo n.º 14
0
    // ㅁ닥불로 태울 때 올라가는 수리도.
    public float    getRegainFire(GameObject item_go)
    {
        float regain = 0.0f;

        if (item_go == null)
        {
            regain = 0.0f;
        }
        else
        {
            Item.TYPE type = this.getItemType(item_go);
            switch (type)
            {
            case Item.TYPE.APPLE:   regain = GameStatus.REGAIN_FIRE_APPLE;  break;

            case Item.TYPE.PLANT:   regain = GameStatus.REGAIN_FIRE_PLANT;  break;
            }
        }
        return(regain);
    }
Exemplo n.º 15
0
    // 먹었을 때 회복하는 체력.
    public float    getRegainSatiety(GameObject item_go)
    {
        float regain = 0.0f;

        if (item_go == null)
        {
            // 아무것도 들고 있지 않다.
            regain = 0.0f;
        }
        else
        {
            Item.TYPE type = this.getItemType(item_go);
            switch (type)
            {
            case Item.TYPE.APPLE:   regain = GameStatus.REGAIN_SATIETY_APPLE;       break;

            case Item.TYPE.PLANT:   regain = GameStatus.REGAIN_SATIETY_PLANT;       break;
            }
        }
        return(regain);
    }
Exemplo n.º 16
0
    public float getGainRepairment(GameObject item_go)
    {
        float gain = 0.0f;

        if (item_go == null)
        {
            gain = 0.0f;
        }
        else
        {
            Item.TYPE type = this.getItemType(item_go);
            switch (type)
            { // 들고 있는 아이템의 종류로 갈라진다.
            case Item.TYPE.IRON:
                gain          = GameStatus.GAIN_REPAIRMENT_IRON;
                toilet.value += 0.15f;
                break;
            }
        }
        return(gain);
    }
Exemplo n.º 17
0
    // 수리했을 때 상승하는 수리도.
    public float    getGainRepairment(GameObject item_go)
    {
        float gain = 0.0f;

        if (item_go == null)
        {
            // 아무것도 가지고 있지 않다.
            gain = 0.0f;
        }
        else
        {
            Item.TYPE type = this.getItemType(item_go);
            switch (type)
            {
            case Item.TYPE.IRON:    gain = GameStatus.GAIN_REPARIMENT_IRON; break;

            case Item.TYPE.PLANT:   gain = GameStatus.GAIN_REPARIMENT_PLANT;        break;
            }
        }
        return(gain);
    }
    public float getGainRepairment(GameObject item_go)
    {
        float gain = 0.0f;

        if (item_go == null)
        {
            gain = 0.0f;
        }
        else
        {
            Item.TYPE type = this.getItemType(item_go);
            switch (type) // 持っているアイテムの種類で分岐
            {
            case Item.TYPE.IRON:
                gain = GameStatus.GAIN_REPAIRMENT_IRON; break;

            case Item.TYPE.PLANT:
                gain = GameStatus.GAIN_REPAIRMENT_PLANT; break;
            }
        }
        return(gain);
    }
Exemplo n.º 19
0
    // 아이템의 종류를 Item.TYPE으로 반환하는 method 입니다.
    public Item.TYPE GetItemType(GameObject item_go)
    {
        Item.TYPE type = Item.TYPE.NONE;

        if (item_go != null)
        {
            switch (item_go.tag)                        // tag가 비어있지 않으면 tag에 따라 나뉩니다.
            {
            case "Iron":
                type = Item.TYPE.IRON;
                break;

            case "Apple":
                type = Item.TYPE.APPLE;
                break;

            case "Plant":
                type = Item.TYPE.PLANT;
                break;
            }
        }
        return(type);
    }
Exemplo n.º 20
0
    public bool isEventIgnitable(Item.TYPE carried_item, GameObject event_go)
    {
        bool ret = false;

        Event.TYPE type = Event.TYPE.NONE;
        if (event_go != null)
        {
            type = this.getEventType(event_go);             // 이벤트 타입을 취득.
        }
        switch (type)
        {
        case Event.TYPE.ROCKET:
            if (carried_item == Item.TYPE.IRON)  // 가지고 있는 것이 철광석이면.
            {
                ret = true;                      // '이벤트할 수 있어요!'라고 반환한다.
            }
            if (carried_item == Item.TYPE.PLANT) // 가지고 있는 것이 식물이면.
            {
                ret = true;                      // '이벤트할 수 있어요!'라고 반환한다.
            }
            break;
        }
        return(ret);
    }
Exemplo n.º 21
0
    public float getRegainSatiety(GameObject item_go)
    {
        float regain = 0.0f;

        if (item_go == null)
        {
            regain = 0.0f;
        }
        else
        {
            Item.TYPE type = this.getItemType(item_go);
            switch (type)
            { // 들고 있는 아이템의 종류로 갈라진다.
            case Item.TYPE.APPLE:
                regain      = GameStatus.REGAIN_SATIETY_APPLE;
                gage.value += 0.22f;
                break;

            case Item.TYPE.PLANT:
                regain = GameStatus.REGAIN_SATIETY_PLANT; break;
            }
        }
        return(regain);
    }
Exemplo n.º 22
0
    // 들고 있는 아이템의 종류와 주목하는 이벤트의 종류를 보고 이벤트 시작
    private bool is_event_ignitable()
    {
        bool ret = false;

        do
        {
            if (this.closest_event == null)
            {          // 주목 이벤트가 없으면.
                break; // false를 반환한다.
            }
            // 들고 있는 아이템 종류를 가져온다.
            Item.TYPE carried_item_type =
                this.item_root.getItemType(this.carried_item);
            // 들고 있는 아이템 종류와 주목하는 이벤트의 종류에서.
            // 이벤트가 가능한지 판정하고, 이벤트 불가라면 false를 반환한다.
            if (!this.event_root.isEventIgnitable(
                    carried_item_type, this.closest_event))
            {
                break;
            }
            ret = true; // 여기까지 오면 이벤트를 시작할 수 있다고 판정!.
        } while (false);
        return(ret);
    }
Exemplo n.º 23
0
    void Update()
    {
        this.get_input();
        this.step_timer += Time.deltaTime;

        float eat_time    = 1.0f;
        float repair_time = 1.0f;
        float fire_time   = 1.0f;
        float action_time = 0.3f;

        // 변화대기.
        if (this.next_step == STEP.NONE)
        {
            switch (this.step)
            {
            case STEP.MOVE:
                do
                {
                    if (!this.key.action)
                    {
                        break;
                    }

                    if (this.closest_event != null)
                    {
                        if (!this.is_event_ignitable())
                        {
                            break;
                        }
                        Event.TYPE ignitable_event = this.event_root.getEventType(this.closest_event);
                        switch (ignitable_event)
                        {
                        case Event.TYPE.ROCKET:
                            this.next_step = STEP.REPAIRING;
                            break;

                        // fire.
                        case Event.TYPE.FIRE:
                            this.next_step = STEP.FIRE;
                            break;
                        }
                        break;
                    }
                    if (this.carried_item != null)
                    {
                        Item.TYPE carried_item_type = this.item_root.getItemType(this.carried_item);
                        switch (carried_item_type)
                        {
                        case Item.TYPE.APPLE:
                        case Item.TYPE.PLANT:
                            this.next_step = STEP.EATING;
                            break;
                        }
                    }
                } while(false);
                break;

            case STEP.EATING:
                if (this.step_timer > eat_time)
                {
                    this.next_step = STEP.MOVE;
                }
                break;

            case STEP.REPAIRING:
                if (this.step_timer > repair_time)
                {
                    this.next_step = STEP.MOVE;
                }
                break;

            case STEP.FIRE:
                if (this.step_timer > fire_time)
                {
                    this.next_step = STEP.MOVE;
                }
                break;

            case STEP.PICKUP:
                if (this.step_timer > action_time)
                {
                    this.next_step = STEP.MOVE;
                }
                break;

            case STEP.THROW:
                if (this.step_timer > action_time)
                {
                    this.next_step = STEP.MOVE;
                }
                break;

            case STEP.PLANT:
                if (this.step_timer > action_time)
                {
                    this.next_step = STEP.MOVE;
                }
                break;
            }
        }


        // ---------------------------------------------------------------- //
        // 상태가 전환됐을 때의 초기화.
        while (this.next_step != STEP.NONE)
        {
            Debug.Log(next_step);

            this.step      = this.next_step;
            this.next_step = STEP.NONE;
            switch (this.step)
            {
            case STEP.MOVE:

                break;

            case STEP.EATING:
                if (this.carried_item != null)
                {
                    this.game_status.addSatiety(this.item_root.getRegainSatiety(this.carried_item));                            // status

                    GameObject.Destroy(this.carried_item);
                    this.carried_item = null;
                    this.animation.CrossFade("08_eat", 0.1f);                                   //motion
                    this.sound_control.SoundPlay(Sound.SOUND.EAT);                              // sound.
                }
                break;


            case STEP.REPAIRING:
                if (this.carried_item != null)
                {
                    this.game_status.addRepairment(this.item_root.getGainRepairment(this.carried_item));                        // status

                    GameObject.Destroy(this.carried_item);
                    this.carried_item  = null;
                    this.closest_event = null;
                    this.animation.CrossFade("07_repair", 0.1f);                                //motion.
                    //this.sound_control.SoundPlay(Sound.SOUND.RESTORE);			// sound.
                }
                break;

            case STEP.FIRE:
                if (this.carried_item != null)
                {
                    this.game_status.addFire(this.item_root.getRegainFire(this.carried_item));                          // status

                    GameObject.Destroy(this.carried_item);
                    this.carried_item  = null;
                    this.closest_event = null;
                    this.animation.CrossFade("07_repair", 0.1f);                                //motion.
                    this.sound_control.SoundPlay(Sound.SOUND.BURN);                             // sound.
                }
                break;


            case STEP.PICKUP:
                this.animation.CrossFade("09_pickup", 0.1f);                            //motion.
                break;

            case STEP.THROW:
                this.animation.CrossFade("10_put", 0.1f);                               //motion.
                break;

            case STEP.PLANT:
                this.animation.CrossFade("10_put", 0.1f);                               //motion.
                break;

            case STEP.DEAD:
                this.animation.CrossFade("05_died", 0.1f);                              //motion.
                this.sound_control.SoundPlay(Sound.SOUND.VO_MISS);
                break;

            case STEP.CLEAR:
                this.animation.CrossFade("09_pickup", 0.1f);                            //motion.
                break;
            }
            this.step_timer = 0.0f;
        }


        // ---------------------------------------------------------------- //
        // 각 상태에서의 실행 처리.
        switch (this.step)
        {
        case STEP.MOVE:
            this.move_control();
            this.pick_or_drop_control();
            this.game_status.alwaysSatiety();                           // 아무것도 하지 않아도 배가 고프다.

            break;

        case STEP.REPAIRING:
            // this.rocket_model.transform.localRotation *= Quaternion.AngleAxis(360.0f/10.0f*Time.deltaTime, Vector3.up);

            // se-.
            this.se_repair_count += Time.deltaTime;
            if (this.se_repair_count > SE_REPAIR_TIMING)
            {
                this.se_repair_count = 0.0f;
                this.sound_control.SoundPlay(Sound.SOUND.RESTORE);
            }

            // effect--.
            this.count_repair_eff += Time.deltaTime;
            if (this.count_repair_eff > REPAIR_EFF_TIMING)
            {
                this.count_repair_eff = 0.0f;
                this.effect_control.repairEffect(GameObject.Find("tonkachi").transform.position);
            }

            break;

        case STEP.DEAD:
            if (this.vo_miss_flag)
            {
                if (this.step_timer >= 1.0f)
                {
                    this.sound_control.SoundPlay(Sound.SOUND.MISS_JINGLE);
                    this.vo_miss_flag = false;
                    Debug.Log("miss");
                }
            }
            break;
        }

        // 멋대로 빙글빙들 돌지 않도록 회전 속도를 강제로 0으로 한다.
        this.rigidbody.angularVelocity = Vector3.zero;
    }
Exemplo n.º 24
0
    void Update()
    {
        this.Get_Input();                           // 키 입력정보 취득
        this.step_timer += Time.deltaTime;
        float eat_time = 2.0f;

        // 상태를 변화시키는 처리
        if (this.next_step == STEP.NONE)            // 다음 예정이 없다면?
        {
            switch (this.step)                      // 현재 상태가...
            {
            case STEP.MOVE:                         // 이동중일 때
                do
                {
                    if (!this.key.action)           // 액션(X)키가 눌려 있지 않다 -> 루프 탈출
                    {
                        break;
                    }

                    if (this.carried_item != null)                  // 액션(X)키가 눌려 있다면?
                    {
                        Item.TYPE carried_item_type = this.item_root.getItemType(this.carried_item);

                        switch (carried_item_type)                  // 가지고 있는 아이템을 판별합니다.
                        {
                        case Item.TYPE.APPLE:                       // 사과라면
                        case Item.TYPE.PLANT:                       // 혹은 식물이라면
                            this.next_step = STEP.EATING;           // 상태를 '식사'로 바꿉니다.
                            break;
                        }
                    }
                } while (false);
                break;

            case STEP.EATING:
                if (this.step_timer > eat_time)
                {
                    this.next_step = STEP.MOVE;
                }
                break;
            }
        }

        // 상태가 변화할 때의 처리
        while (this.next_step != STEP.NONE)
        {
            this.step      = this.next_step;
            this.next_step = STEP.NONE;
            switch (this.step)
            {
            case STEP.MOVE:                         // '이동' 상태 처리
                break;

            case STEP.EATING:                       // '식사' 상태 처리
                if (this.carried_item != null)
                {
                    GameObject.Destroy(this.carried_item);      // 먹은 아이템을 없앱니다.
                }
                break;
            }
            this.step_timer = 0.0f;
        }

        // 각 상황(MOVE, REPAIRING, EATING)에서 반복행동
        switch (this.step)
        {
        case STEP.MOVE:
            this.Move_Control();                    // 이동 조작
            this.pick_or_drop_control();            // 수집 조작
            break;
        }
    }
Exemplo n.º 25
0
    void Update()
    {
        this.Get_input();      // 입력정보 취득
        this.step_timer += Time.deltaTime;
        float eat_time = 2.0f; // 사과는 2초에 걸쳐 먹는다.

        //상태를 변화시킨다----------------------
        if (this.next_step == STEP.NONE) // 다음 예정이 없으면
        {
            switch (this.step)
            {
            case STEP.MOVE:
                do
                {
                    if (!this.key.action)     // 액션키가 눌려있지 않다
                    {
                        break;                // 탈출
                    }

                    if (this.carried_item != null)
                    {
                        //가지고 있는 아이템 판별
                        Item.TYPE carried_item_type =
                            this.item_root.getItemType(this.carried_item);

                        switch (carried_item_type)
                        {
                        case Item.TYPE.APPLE:         // 사과라면
                        case Item.TYPE.PLANT:         // 식물이라면
                            //'식사중'상태로 이행.
                            this.next_step = STEP.EATING;
                            break;
                        }
                    }
                } while (false);
                break;

            case STEP.EATING:                       //식사중 상태의 처리
                if (this.step_timer > eat_time)     // 2초 대기
                {
                    this.next_step = STEP.MOVE;     // 이동상태로 이행
                }
                break;
            }
        }



        //상태가 변했을때------------------------
        while (this.next_step != STEP.NONE) // 상태가 NONE이외 = 상태가 변했다.
        {
            this.step      = this.next_step;
            this.next_step = STEP.NONE;
            switch (this.step)
            {
            case STEP.MOVE:
                break;

            case STEP.EATING:     // 식사중 상태의처리
                if (this.carried_item != null)
                {
                    //가지고 있던 아이템을 폐기
                    GameObject.Destroy(this.carried_item);
                    this.carried_item = null;
                }
                break;
            }
            this.step_timer = 0.0f;
        }

        //각 상황에서 반복할것---------------------

        switch (this.step)
        {
        case STEP.MOVE:
            this.Move_control();
            this.pick_or_drop_control();
            break;
        }
    }
Exemplo n.º 26
0
    // Update is called once per frame
    // 상태를 변화시키는 부분, 상태가 변화했을 때의 처리 부분, 각 상태에서의 동작 부분에 추가
    void Update()
    {
        this.get_input(); // 입력 정보 취득.
        this.step_timer += Time.deltaTime;
        float eat_time    = 0.01f;
        float repair_time = 0.5f;

        // 상태를 변화시킨다---------------------.
        if (this.next_step == STEP.NONE)
        { // 다음 예정이 없으면.
            switch (this.step)
            {
            case STEP.MOVE:     // '이동 중' 상태의 처리.
                do
                {
                    if (!this.key.action)
                    {          // 액션 키가 눌려있지 않다.
                        break; // 루프 탈출.
                    }

                    // 주목하는 이벤트가 있을 때.
                    if (this.closest_event != null)
                    {
                        if (!this.is_event_ignitable())
                        {          // 이벤트를 시작할 수 없으면.
                            break; // 아무 것도 하지 않는다.
                        }
                        // 이벤트 종류를 가져온다.
                        Event.TYPE ignitable_event =
                            this.event_root.getEventType(this.closest_event);
                        switch (ignitable_event)
                        {
                        case Event.TYPE.ROCKET:         // 이벤트의 종류가 ROCKET이면.
                                                        // REPAIRING(수리) 상태로 이행.
                            this.next_step = STEP.REPAIRING;
                            break;
                        }
                        break;
                    }



                    if (this.carried_item != null)
                    {
                        // 가지고 있는 아이템 판별.
                        Item.TYPE carried_item_type =
                            this.item_root.getItemType(this.carried_item);
                        switch (carried_item_type)
                        {
                        case Item.TYPE.APPLE:         // 사과라면.
                            // case Item.TYPE.PLANT: // 식물이라면.
                            // '식사 중' 상태로 이행.
                            this.next_step = STEP.EATING;
                            break;
                        }
                    }
                } while (false);
                break;

            case STEP.EATING:                   // '식사 중' 상태의 처리.
                if (this.step_timer > eat_time)
                {                               // 2초 대기.
                    this.next_step = STEP.MOVE; // '이동' 상태로 이행.
                }
                break;

            case STEP.REPAIRING:                // '수리 중' 상태의 처리.
                if (this.step_timer > repair_time)
                {                               // 2초 대기.
                    this.next_step = STEP.MOVE; // '이동' 상태로 이행.
                }
                break;
            }
        }

        // 상태가 변화했을 때------------.
        while (this.next_step != STEP.NONE)
        { // 상태가 NONE이외 = 상태가 변화했다.
            this.step      = this.next_step;
            this.next_step = STEP.NONE;
            switch (this.step)
            {
            case STEP.MOVE:
                break;

            case STEP.EATING:     // '식사 중' 상태의 처리.
                if (this.carried_item != null)
                {
                    // 들고 있는 아이템의 '체력 회복 정도'를 가져와서 설정.
                    this.game_status.addSatiety(
                        this.item_root.getRegainSatiety(this.carried_item));
                    // 가지고 있던 아이템을 폐기.
                    GameObject.Destroy(this.carried_item);
                    this.carried_item = null;
                }
                break;

            case STEP.REPAIRING:     // '수리 중'이 되면.
                if (this.carried_item != null)
                {
                    // 들고 있는 아이템의 '수리 진척 상태'를 가져와서 설정.
                    this.game_status.addRepairment(
                        this.item_root.getGainRepairment(this.carried_item));
                    // 가지고 있는 아이템 삭제.
                    GameObject.Destroy(this.carried_item);
                    this.carried_item = null;
                    this.closest_item = null;
                }
                break;
            }
            this.step_timer = 0.0f;
        }
        // 각 상황에서 반복할 것----------.
        switch (this.step)
        {
        case STEP.MOVE:
            this.move_control();
            this.pick_or_drop_control();
            // 이동 가능한 경우는 항상 배가 고파진다.
            this.game_status.alwaysSatiety();
            break;

        case STEP.REPAIRING:
            // 우주선을 회전시킨다.
            //this.rocket_model.transform.localRotation *=
            //Quaternion.AngleAxis(360.0f / 10.0f * Time.deltaTime,
            //Vector3.up);
            break;
        }
    }
Exemplo n.º 27
0
    // Update is called once per frame
    void Update()
    {
        if (Vector3.Distance(willson.transform.position, transform.position) > 3)
        {
            game_status.addLonely(GameStatus.CONSUME_LONELY_FAR_FROM_WILLSON);
        }
        else
        {
            game_status.addLonely(-GameStatus.CONSUME_LONELY_FAR_FROM_WILLSON);
        }

        if (game_status.getFire)
        {
            _Torch.SetActive(true);
        }
        else
        {
            _Torch.SetActive(false);
        }

        if (carried_item == null)
        {
            animator.SetBool("isCarried", false);
            item_root.itemInfo.sprite = item_root.emptySprite;
        }
        else if (carried_item != null)
        {
            animator.SetBool("isCarried", true);
        }

        this.get_input(); // 입력 정보 취득.
                          // 상태가 변화했을 때------------.

        this.step_timer += Time.deltaTime;
        float eat_time    = 0.5f; // 사과는 2초에 걸쳐 먹는다.
        float repair_time = 2.0f; // 수리에 걸리는 시간도 2초.

        // 상태를 변화시킨다---------------------.
        if (this.next_step == STEP.NONE)
        { // 다음 예정이 없으면.
            switch (this.step)
            {
            case STEP.MOVE:     // '이동 중' 상태의 처리.
                do
                {
                    if (!this.key.action)
                    {          // 액션 키가 눌려있지 않다.
                        break; // 루프 탈출.
                    }
                    // 주목하는 이벤트가 있을 때.
                    if (this.closest_event != null)
                    {
                        if (!this.is_event_ignitable())
                        {          // 이벤트를 시작할 수 없으면.
                            break; // 아무 것도 하지 않는다.
                        }
                        // 이벤트 종류를 가져온다.
                        Event.TYPE ignitable_event =
                            this.event_root.getEventType(this.closest_event);
                        switch (ignitable_event)
                        {
                        case Event.TYPE.ROCKET:         // 이벤트의 종류가 ROCKET이면.
                                                        // REPAIRING(수리) 상태로 이행.
                            this.next_step = STEP.REPAIRING;
                            break;

                        case Event.TYPE.MAKEFIRE:
                            this.next_step = STEP.MAKINGCAMP;
                            break;

                        case Event.TYPE.GETFIRE:
                            this.next_step = STEP.GETTINGFIRE;
                            break;
                        }
                        break;
                    }
                    if (this.carried_item != null)
                    {
                        // 가지고 있는 아이템 판별.
                        Item.TYPE carried_item_type = this.item_root.getItemType(this.carried_item);
                        switch (carried_item_type)
                        {
                        case Item.TYPE.APPLE:         // 사과라면.
                            this.next_step = STEP.EATING;
                            break;

                        case Item.TYPE.PLANT:             // 식물이라면.
                            this.next_step = STEP.EATING; // '식사 중' 상태로 이행.
                            break;
                        }
                    }
                } while (false);
                break;

            case STEP.EATING: // '식사 중' 상태의 처리.
                if (this.step_timer > eat_time)
                {             // 2초 대기.
                    if (SoundManager.instance.myAudio.isPlaying)
                    {
                        SoundManager.instance.myAudio.Stop();
                    }
                    else
                    {
                        SoundManager.instance.eatEFS();
                    }
                    this.next_step = STEP.MOVE;     // '이동' 상태로 이행.
                }
                break;

            case STEP.REPAIRING:                // '수리 중' 상태의 처리.
                if (this.step_timer > repair_time)
                {                               // 2초 대기.
                    this.next_step = STEP.MOVE; // '이동' 상태로 이행.
                }
                break;

            case STEP.MAKINGCAMP:
                this.next_step = STEP.MOVE;
                break;

            case STEP.GETTINGFIRE:
                this.next_step = STEP.MOVE;
                break;

            default:
                break;
            }
        }
        while (this.next_step != STEP.NONE)
        { // 상태가 NONE이외 = 상태가 변화했다.
            this.step      = this.next_step;
            this.next_step = STEP.NONE;
            switch (this.step)
            {
            case STEP.MOVE:
                break;

            case STEP.EATING:     // '식사 중' 상태의 처리.
                if (this.carried_item != null)
                {
                    // 가지고 있던 아이템을 폐기.
                    GameObject.Destroy(this.carried_item);
                    this.game_status.addSatiety(this.item_root.getRegainSatiety(this.carried_item));
                    this.carried_item = null;
                }
                break;

            case STEP.REPAIRING:     // '수리 중'이 되면.
                if (this.carried_item != null)
                {
                    // 들고 있는 아이템의 '수리 진척 상태'를 가져와서 설정.
                    this.game_status.addRepairment(this.item_root.getGainRepairment(this.carried_item));

                    // 가지고 있는 아이템 삭제.
                    GameObject.Destroy(this.carried_item);
                    this.carried_item = null;
                    this.closest_item = null;
                }
                break;

            case STEP.MAKINGCAMP:
                if (this.carried_item != null)
                {
                    GameObject.Destroy(this.carried_item);
                    game_status.fireCount = 3;
                    this.carried_item     = null;
                    this.closest_item     = null;
                }
                break;

            case STEP.GETTINGFIRE:
                if (this.carried_item == null)
                {
                    game_status.fireCount -= 1;
                    game_status.getFire    = true;
                }
                break;
            }
            this.step_timer = 0.0f;
        }
        // 각 상황에서 반복할 것----------.
        switch (this.step)
        {
        case STEP.MOVE:
            this.move_control();
            this.pick_or_drop_control();
            // 이동 가능한 경우는 항상 배가 고파진다.
            this.game_status.alwaysSatiety();
            break;

        case STEP.REPAIRING:
            // 우주선을 회전시킨다.
            animator.SetBool("fix", true);
            if (SoundManager.instance.myAudio.isPlaying)
            {
                SoundManager.instance.myAudio.Stop();
            }
            else
            {
                SoundManager.instance.fixEFS();
            }
            //this.rocket_model.transform.localRotation *=
            //Quaternion.AngleAxis(360.0f / 10.0f * Time.deltaTime,
            //Vector3.up);
            break;
        }
    }
    void Update()
    {
        this.get_input();         // 入力情報を取得
        this.step_timer += Time.deltaTime;
        float eat_time    = 0.5f; // リンゴは、2秒かけて食べる
        float repair_time = 0.5f; // 修理にかかる時間も2秒

        // 状態を変化させる---------------------
        if (this.next_step == STEP.NONE) // 次の予定がないなら
        {
            switch (this.step)
            {
            case STEP.MOVE:     // 「移動中」状態の処理
                do
                {
                    if (!this.key.action) // アクションキーが押されていない
                    {
                        break;            // ループを脱出
                    }
                    // 注目中のイベントがある場合
                    if (this.closest_event != null)
                    {
                        if (!this.is_event_ignitable()) // イベントが開始不可なら
                        {
                            break;                      // 何もしない
                        }
                        // イベントの種類を取得
                        Event.TYPE ignitable_event = this.event_root.getEventType(this.closest_event);

                        switch (ignitable_event)
                        {
                        case Event.TYPE.ROCKET:
                            // イベントの種類がROCKETなら
                            // REPAIRING(種類)状態に移行
                            this.next_step = STEP.REPAIRING;
                            break;
                        }
                        break;
                    }
                    if (this.carried_item != null)
                    {
                        // 持っているアイテムを判別
                        Item.TYPE carried_item_type = this.item_root.getItemType(this.carried_item);

                        switch (carried_item_type)
                        {
                        case Item.TYPE.APPLE:         // リンゴなら
                        case Item.TYPE.PLANT:         // 植物なら
                            // 「食事中」状態に移行
                            this.next_step = STEP.EATING;
                            break;
                        }
                    }
                } while (false);
                break;

            case STEP.EATING:                   // 「食事中」状態の処理
                if (this.step_timer > eat_time) // 2秒待つ
                {
                    this.next_step = STEP.MOVE; // 「移動」状態に移行
                }
                break;

            case STEP.REPAIRING:                   // 「修理中」状態の処理
                if (this.step_timer > repair_time) // 2秒待つ
                {
                    this.next_step = STEP.MOVE;    // 「移動」状態に移行
                }
                break;
            }
        }

        // 状態が変化した場合------------
        while (this.next_step != STEP.NONE) // 状態がNONE以外=状態が変化した
        {
            this.step      = this.next_step;
            this.next_step = STEP.NONE;
            switch (this.step)
            {
            case STEP.MOVE:
                break;

            case STEP.EATING:     // 「食事中」状態の処理
                if (this.carried_item != null)
                {
                    // 持っているアイテムの「お腹の回復具合」を取得し、設定
                    this.game_status.addSatiety(this.item_root.getRegainSatiety(this.carried_item));
                    // 持っていたアイテムを破棄
                    GameObject.Destroy(this.carried_item);
                    this.carried_item = null;
                }
                break;

            case STEP.REPAIRING:     // 「修理中」になったら
                if (this.carried_item != null)
                {
                    // 持っているアイテムの「お腹の回復具合」を取得し、設定
                    this.game_status.addRepairment(this.item_root.getGainRepairment(this.carried_item));
                    // 持っているアイテムを削除
                    GameObject.Destroy(this.carried_item);
                    this.carried_item = null;
                    this.closest_item = null;
                }
                break;
            }
            this.step_timer = 0.0f;
        }

        // 各状態で繰り返しすること------------
        switch (this.step)
        {
        case STEP.MOVE:
            this.move_control();
            this.pick_or_drop_control();
            // 移動可能な場合は常にお腹が減る
            this.game_status.alwaysSatiety();
            break;

        case STEP.REPAIRING:
            // 宇宙船を回転させる
            this.rocket_model.transform.localRotation *= Quaternion.AngleAxis(360.0f / 10.0f * Time.deltaTime, Vector3.up);
            break;
        }
    }
Exemplo n.º 29
0
    void    OnGUI()
    {
        float x = 20.0f;
        float y = Screen.height - 40.0f;

        Rect rect_info_x = new Rect(220.0f, Screen.height - 40.0f, info_x_eat.width, info_x_eat.height);
        Rect rect_info_z = new Rect(20.0f, Screen.height - 40.0f, info_z_get.width, info_z_get.height);


        if (this.carried_item != null)
        {
            Item.TYPE carried_item_type = this.item_root.getItemType(this.carried_item);
            switch (carried_item_type)
            {
            case Item.TYPE.APPLE:
                // GUI.Label(new Rect(x, y, 200.0f, 20.0f), "Z:심는다");
                GUI.DrawTexture(rect_info_z, info_z_plant);
                GUI.DrawTexture(rect_info_x, info_x_eat);
                break;

            case Item.TYPE.IRON:
                GUI.DrawTexture(rect_info_z, info_z_put);
                break;

            case Item.TYPE.PLANT:
                // GUI.Label(new Rect(x, y, 200.0f, 20.0f), "Z:버린다");
                GUI.DrawTexture(rect_info_x, info_x_eat);
                GUI.DrawTexture(rect_info_z, info_z_put);
                break;
            }
        }
        else
        {
            if (this.closest_item != null)
            {
                // GUI.Label(new Rect(x, y, 200.0f, 20.0f), "Z:주으면 피로하다");
                GUI.DrawTexture(rect_info_z, info_z_get);
            }
        }


        if (this.closest_item_prev != this.closest_item)
        {
            this.sound_control.SoundPlay(Sound.SOUND.INFO);
        }
        if (this.carried_item_prev != this.carried_item)
        {
            this.sound_control.SoundPlay(Sound.SOUND.INFO);
        }

        this.closest_item_prev = this.closest_item;
        this.carried_item_prev = this.carried_item;



        switch (this.step)
        {
        case STEP.EATING:
            // GUI.Label(new Rect(x+200.0f, y, 200.0f, 20.0f), "우걱우걱우물우물……");
            GUI.DrawTexture(rect_info_x, info_musha);
            break;

        case STEP.REPAIRING:
            // GUI.Label(new Rect(x+200.0f, y, 200.0f, 20.0f), "수리중");
            GUI.DrawTexture(rect_info_x, info_repair);
            break;

        case STEP.FIRE:
            GUI.DrawTexture(rect_info_x, info_fire);
            break;
        }


        if (this.is_event_ignitable())
        {
            string message = this.event_root.getIgnitableMessage(this.closest_event);
            GUI.Label(new Rect(x + 200.0f, y, 200.0f, 20.0f), "X:" + message);

            switch (this.event_root.getEventType(this.closest_event))
            {
            case Event.TYPE.ROCKET:
                GUI.DrawTexture(rect_info_x, info_x_repair);
                break;

            case Event.TYPE.FIRE:
                GUI.DrawTexture(rect_info_x, info_x_fire);
                break;
            }
        }
    }