Esempio n. 1
0
    // ---------------------------------------------------------------- //
    // 콜리전의 의미 부여.
    private void    resolve_collision()
    {
        foreach (var result in this.control.collision_results)
        {
            if (result.object1 == null)
            {
                continue;
            }

            //GameObject		self  = result.object0;
            GameObject other = result.object1;

            switch (other.tag)
            {
            case "Item":
            {
                do
                {
                    // 케이크 무한제공 이외(평소 게임 중)에는 리모트는.
                    //  아이템은 주울 수 없다.
                    if (!GameRoot.get().isNowCakeBiking())
                    {
                        break;
                    }

                    ItemController item = other.GetComponent <ItemController>();

                    QueryItemPick query = this.control.cmdItemQueryPick(item.name, true, true);
                } while(false);
            }
            break;
            }
        }
    }
Esempio n. 2
0
    // 떨어져 있는 아이템 줍기.
    public ItemController   pickItem(QueryItemPick query, string owner_id, string item_id)
    {
        // 프로그램의 버그를 막고자 쿼리가 없으면.
        // 줍지 못하게 했다.

        ItemController item = null;

        do
        {
            // 일단 쿼리의 결과도 체크.
            if (!query.isSuccess())
            {
                break;
            }

            item = this.find_item(item_id);

            if (item == null)
            {
                break;
            }

            item.picker = owner_id;
            item.startPicked();

            if (item_id.StartsWith("key"))
            {
                PartyControl.get().pickKey(item_id, owner_id);
            }
        } while(false);

        return(item);
    }
Esempio n. 3
0
    // 아이템를 픽업한다.
    public bool             cmdItemPick(QueryItemPick query, string owner_id, string item_id)
    {
        bool ret = false;

        do
        {
            if (this.item_carrier.isCarrying())
            {
                break;
            }

            ItemController item = this.item_man.pickItem(query, owner_id, item_id);

            if (item == null)
            {
                break;
            }

            if (query.is_anon)
            {
                this.item_carrier.beginCarryAnon(item);
            }
            else
            {
                this.item_carrier.beginCarry(item);
            }

            ret = true;
        } while(false);

        return(ret);
    }
Esempio n. 4
0
    // ---------------------------------------------------------------- //
    // 肄쒕━?꾩쓽 ?섎? 遺€??
    private void    resolve_collision()
    {
        foreach (var result in this.control.collision_results)
        {
            if (result.object1 == null)
            {
                continue;
            }

            //GameObject		self  = result.object0;
            GameObject other = result.object1;

            switch (other.tag)
            {
            case "Item":
            {
                do
                {
                    // 耳€?댄겕 臾댄븳?쒓났 ?댁쇅(?됱냼 寃뚯엫 以??먮뒗 由щえ?몃뒗.
                    //  ?꾩씠?쒖? 二쇱슱 ???녿떎.
                    if (!GameRoot.get().isNowCakeBiking())
                    {
                        break;
                    }

                    ItemController item = other.GetComponent <ItemController>();

                    QueryItemPick query = this.control.cmdItemQueryPick(item.name, true, true);
                } while(false);
            }
            break;
            }
        }
    }
Esempio n. 5
0
    // ?⑥뼱???덈뒗 ?꾩씠??以띻린.
    public ItemController   pickItem(QueryItemPick query, string owner_id, string item_id)
    {
        // ?꾨줈洹몃옩??踰꾧렇瑜?留됯퀬??荑쇰━媛€ ?놁쑝硫?
        // 以띿? 紐삵븯寃??덈떎.

        ItemController item = null;

        do
        {
            // ?쇰떒 荑쇰━??寃곌낵??泥댄겕.
            if (!query.isSuccess())
            {
                break;
            }

            item = this.find_item(item_id);

            if (item == null)
            {
                break;
            }

            item.picker = owner_id;
            item.startPicked();

            if (item_id.StartsWith("key"))
            {
                PartyControl.get().pickKey(item_id, owner_id);
            }
        } while(false);

        return(item);
    }
Esempio n. 6
0
    // 떨어져 있는 아이템을 줍습니다.
    public ItemController   pickItem(QueryItemPick query, string owner_id, string item_id)
    {
        // 프로그램의 버그를 막고자 쿼리가 없으면
        // 주울 수 없게 했습니다.

        ItemController item = null;

        do
        {
            // 일단 쿼리 결과도 체크합니다.
            if (!query.isSuccess())
            {
                break;
            }

            item = this.find_item(item_id);

            if (item == null)
            {
                break;
            }

            item.picker = owner_id;
            item.startPicked();
        } while(false);

        return(item);
    }
Esempio n. 7
0
    // ================================================================ //
    // 비헤이비어용 커맨드.
    // 쿼리 계.

    // 떨어져 있는 아이템을 주워도 되는가?.
    public QueryItemPick    queryPickItem(string owner_id, string item_id, bool is_local, bool forece_pickup)
    {
        ItemController item          = null;
        QueryItemPick  query         = null;
        bool           needMediation = is_local;

        do
        {
            item = this.find_item(item_id);

            if (item == null)
            {
                needMediation = false;
                break;
            }

            // 성장 중인 것은 주울 수 없다.
            if (!item.isPickable() && !forece_pickup)
            {
                needMediation = false;
                break;
            }

            // 이미 누군가 가지고 있는 것은 주울 수 없다.
            if (item.picker != "")
            {
                needMediation = false;
                break;
            }

            query = new QueryItemPick(owner_id, item_id);

            QueryManager.get().registerQuery(query);

            // 획득 중 상태로 변경한다.
            this.setItemState(item_id, ItemController.State.PickingUp, owner_id);
        } while(false);

        if (GameRoot.get().isNowCakeBiking() == false)
        {
            if (needMediation)
            {
                // 아이템 획득 문의를 한다.
                SendItemStateChanged(item_id, ItemController.State.PickingUp, owner_id);
            }
        }

        return(query);
    }
Esempio n. 8
0
    // ================================================================ //
    // 鍮꾪뿤?대퉬?댁슜 而ㅻ㎤??
    // 荑쇰━ 怨?

    // ?⑥뼱???덈뒗 ?꾩씠?쒖쓣 二쇱썙???섎뒗媛€?.
    public QueryItemPick    queryPickItem(string owner_id, string item_id, bool is_local, bool forece_pickup)
    {
        ItemController item          = null;
        QueryItemPick  query         = null;
        bool           needMediation = is_local;

        do
        {
            item = this.find_item(item_id);

            if (item == null)
            {
                needMediation = false;
                break;
            }

            // ?깆옣 以묒씤 寃껋? 二쇱슱 ???녿떎.
            if (!item.isPickable() && !forece_pickup)
            {
                needMediation = false;
                break;
            }

            // ?대? ?꾧뎔媛€ 媛€吏€怨??덈뒗 寃껋? 二쇱슱 ???녿떎.
            if (item.picker != "")
            {
                needMediation = false;
                break;
            }

            query = new QueryItemPick(owner_id, item_id);

            QueryManager.get().registerQuery(query);

            // ?띾뱷 以??곹깭濡?蹂€寃쏀븳??
            this.setItemState(item_id, ItemController.State.PickingUp, owner_id);
        } while(false);

        if (GameRoot.get().isNowCakeBiking() == false)
        {
            if (needMediation)
            {
                // ?꾩씠???띾뱷 臾몄쓽瑜??쒕떎.
                SendItemStateChanged(item_id, ItemController.State.PickingUp, owner_id);
            }
        }

        return(query);
    }
Esempio n. 9
0
    // 쿼리  아이템을 줍는가?.
    public QueryItemPick    cmdItemQueryPick(string item_id, bool is_local, bool force_pickup)
    {
        QueryItemPick query = null;

        do
        {
            query = ItemManager.get().queryPickItem(this.getAccountID(), item_id, is_local, force_pickup);

            if (query == null)
            {
                break;
            }
        } while(false);

        return(query);
    }
Esempio n. 10
0
    // 쿼리 아이템을 픽업한다?.
    public QueryItemPick    cmdItemQueryPick(string item_id, bool local = true, bool force = false)
    {
        QueryItemPick query = null;

        do
        {
            query = this.item_man.queryPickItem(this.account_name, item_id, local, force);

            if (query == null)
            {
                break;
            }

            this.queries.Add(query);
        } while(false);

        return(query);
    }
Esempio n. 11
0
    // ================================================================ //
    // 비헤이비어용 커맨드.
    // 쿼리.

    // 떨어져 있는 아이템을 주워도 되는가?.
    public QueryItemPick    queryPickItem(string owner_id, string item_id, bool local, bool force)
    {
        ItemController item   = null;
        QueryItemPick  query  = null;
        bool           notify = false;

        do
        {
            item = this.find_item(item_id);

            if (item == null)
            {
                break;
            }

            // 성장 중인 것은 주울 수 없습니다.
            if (!item.isPickable() && !force)
            {
                break;
            }

            // 이미 누군가가 소지 중인 것은 주울 수 없습니다.
            if (item.picker != "")
            {
                break;
            }

            query = new QueryItemPick(item_id);

            this.queries.Add(query);
            notify = true;
        } while(false);

        // 로컬 캐릭터가 아이템의 쿼리를 발행했을 때만 서버에 송신합니다.]
        if (notify && local)
        {
            // 아이템의 스테이트를 네트워크로 보냅니다.
            SendItemStateChanged(item_id, ItemController.State.PickingUp, owner_id);
        }

        return(query);
    }
Esempio n. 12
0
    // 아이템 줍는다.
    public ItemController           cmdItemPick(QueryItemPick query, string item_id)
    {
        ItemController item = null;

        do
        {
            string account_id = PartyControl.get().getLocalPlayer().getAcountID();
            item = ItemManager.getInstance().pickItem(query, account_id, item_id);

            if (item == null)
            {
                break;
            }

            item.gameObject.transform.parent        = this.gameObject.transform;
            item.gameObject.transform.localPosition = Vector3.up * 300.0f;
            item.gameObject.GetComponent <Rigidbody>().isKinematic = true;

            Debug.Log("cmdItemPick:" + item_id);
            dbwin.console().print("cmdItemPick:" + item_id);
        } while(false);

        return(item);
    }
Esempio n. 13
0
    private void    resolve_pick_item_query(QueryItemPick query)
    {
        do
        {
            if (!query.isSuccess())
            {
                break;
            }

            // ?꾩씠???⑤뒫留?蹂듭궗?섍퀬 ??젣?쒕떎.

            ItemController item = this.control.cmdItemPick(query, query.target);

            if (item == null)
            {
                break;
            }

            // ?④낵.
            EffectRoot.get().createItemGetEffect(this.control.getPosition());

            SoundManager.get().playSE(Sound.ID.DDG_SE_SYS02);

            switch (item.behavior.item_favor.category)
            {
            case Item.CATEGORY.CANDY:
            {
                // ?꾩씠??李쎌뿉 ?꾩씠肄??쒖떆.
                this.item_slot.candy.favor = item.behavior.item_favor.clone();

                ItemWindow.get().setItem(Item.SLOT_TYPE.CANDY, 0, this.item_slot.candy.favor);

                // ?룹쓽 ?쇱젙?쒓컙 ?뚯썙??					this.startShotBoost();
            }
            break;

            case Item.CATEGORY.SODA_ICE:
            case Item.CATEGORY.ETC:
            {
                // 鍮??щ’???꾩씠???ㅼ젙.
                int slot_index = this.item_slot.getEmptyMiscSlot();

                if (slot_index >= 0)
                {
                    this.item_slot.miscs[slot_index].item_id = query.target;
                    this.item_slot.miscs[slot_index].favor   = item.behavior.item_favor.clone();

                    // ?꾩씠??李쎌뿉 ?꾩씠肄??쒖떆.
                    ItemWindow.get().setItem(Item.SLOT_TYPE.MISC, slot_index, this.item_slot.miscs[slot_index].favor);
                }
            }
            break;

            case Item.CATEGORY.FOOD:
            {
                // 泥대젰 ?뚮났.
                if (GameRoot.get().isNowCakeBiking())
                {
                    this.control.vital.healFullInternal();
                }
                else
                {
                    this.control.vital.healFull();

                    // ?덉씤蹂댁슦 移쇰윭 ?④낵.
                    this.skin_color_control.startHealing();
                }

                // 泥대젰 ?뚮났???뚮┝.
                CharacterRoot.get().NotifyHitPoint(this.getAcountID(), this.control.vital.getHitPoint());

                // ?꾩씠???먭린瑜??뚮┝.
                this.control.cmdItemDrop(query.target);

                // 耳€?댄겕瑜?癒뱀? ??耳€?댄겕 臾댄븳?쒓났??.
                this.cake_count++;
            }
            break;

            // 諛??댁뇿.
            case Item.CATEGORY.KEY:
            {
                PartyControl.get().getLocalPlayer().control.consumeKey(item);

                Item.KEY_COLOR key_color = Item.Key.getColorFromInstanceName(item.name);

                // ?꾩씠??李쎌뿉 ?꾩씠肄??쒖떆.
                if (key_color != Item.KEY_COLOR.NONE)
                {
                    ItemWindow.get().setItem(Item.SLOT_TYPE.KEY, (int)key_color, item.behavior.item_favor);
                }
            }
            break;

            // ?뚮줈???대룞 臾??댁뇿.
            case Item.CATEGORY.FLOOR_KEY:
            {
                MapCreator.getInstance().UnlockBossDoor();

                // ?꾩씠??李쎌뿉 ?꾩씠肄??쒖떆.
                ItemWindow.get().setItem(Item.SLOT_TYPE.FLOOR_KEY, 0, item.behavior.item_favor);
            }
            break;

            case Item.CATEGORY.WEAPON:
            {
                // ??蹂€寃??€??諛쒖뭏 / ?좎옄 ??깂).
                SHOT_TYPE shot_type = Item.Weapon.getShotType(item.name);

                if (shot_type != SHOT_TYPE.NONE)
                {
                    this.changeBulletShooter(shot_type);
                }
            }
            break;
            }

            item.vanish();
        } while(false);

        query.set_expired(true);
    }
Esempio n. 14
0
    // ================================================================ //

    // 조정을 마친 쿼리 실행.
    protected void          execute_queries()
    {
        foreach (QueryBase query in this.controll.queries)
        {
            if (!query.isDone())
            {
                continue;
            }

            switch (query.getType())
            {
            case "item.pick":
            {
                QueryItemPick query_pick = query as QueryItemPick;

                if (query.isSuccess())
                {
                    // 아이템을 가지고 있으면 버린다.
                    if (this.controll.item_carrier.isCarrying())
                    {
                        Debug.Log("Pick:" + query_pick.target + " Carry:" + this.controll.item_carrier.item.id);
                        if (query_pick.target != this.controll.item_carrier.item.id)
                        {
                            // 상대방 플레이어에게 드롭한 사실을 알려줘야만 하므로 쿼리를 만든다.
                            // 동기화할 필요는 없으므로 드롭은 바로 실행한다.
                            Debug.Log("behavior:cmdItemQueryDrop");

                            QueryItemDrop query_drop = this.controll.cmdItemQueryDrop();

                            query_drop.is_drop_done = true;

                            this.controll.cmdItemDrop(this.controll.account_name);
                        }
                    }

                    this.controll.cmdItemPick(query_pick,this.controll.account_name,query_pick.target);

                    if (!query_pick.is_anon)
                    {
                        SoundManager.get().playSE(Sound.ID.TFT_SE01);
                    }
                }

                query.set_expired(true);
            }
            break;

            case "item.drop":
            {
                if (query.isSuccess())
                {
                    if ((query as QueryItemDrop).is_drop_done)
                    {
                        // 이미 드롭 완료.
                        Debug.Log("[CLIENT CHAR] Item already dropped.");
                    }
                    else
                    {
                        Debug.Log("[CLIENT CHAR] Item dropped.");

                        this.controll.cmdItemDrop(this.controll.account_name);
                    }
                }

                query.set_expired(true);
            }
            break;

            case "house-move.start":
            {
                do
                {
                    if (!query.isSuccess())
                    {
                        break;
                    }

                    QueryHouseMoveStart query_start = query as QueryHouseMoveStart;

                    chrBehaviorNPC_House house = CharacterRoot.get().findCharacter <chrBehaviorNPC_House>(query_start.target);

                    if (house == null)
                    {
                        break;
                    }

                    var start_event = EventRoot.get().startEvent <HouseMoveStartEvent>();

                    start_event.setPrincipal(this);
                    start_event.setHouse(house);
                } while(false);

                query.set_expired(true);
            }
            break;

            case "house-move.end":
            {
                do
                {
                    if (!query.isSuccess())
                    {
                        break;
                    }

                    chrBehaviorNPC_House house = this.step_house_move.house;

                    var end_event = EventRoot.get().startEvent <HouseMoveEndEvent>();

                    end_event.setPrincipal(this);
                    end_event.setHouse(house);
                } while(false);

                query.set_expired(true);
            }
            break;

            case "talk":
            {
                if (query.isSuccess())
                {
                    QueryTalk query_talk = query as QueryTalk;

                    this.controll.cmdDispBalloon(query_talk.words);
                }
                query.set_expired(true);
            }
            break;
            }

            break;
        }
    }
Esempio n. 15
0
	// 아이템 줍는다.
	public ItemController		cmdItemPick(QueryItemPick query, string item_id)
	{
		ItemController	item = null;

		do {

			string account_id = PartyControl.get().getLocalPlayer().getAcountID();
			item = ItemManager.getInstance().pickItem(query, account_id, item_id);

			if(item == null) {

				break;
			}

			item.gameObject.transform.parent        = this.gameObject.transform;
			item.gameObject.transform.localPosition = Vector3.up*300.0f;
			item.gameObject.GetComponent<Rigidbody>().isKinematic   = true;

			Debug.Log("cmdItemPick:" + item_id);
			dbwin.console().print("cmdItemPick:" + item_id);

		} while(false);

		return(item);
	}
Esempio n. 16
0
    // ================================================================ //

    // ?꾩씠???뺣낫 ?⑦궥 痍⑤뱷 ?⑥닔.
    public void OnReceiveItemPacket(int node, PacketId id, byte[] data)
    {
        ItemPacket packet = new ItemPacket(data);
        ItemData   item   = packet.GetPacket();

        // ?쒕쾭 ?곹깭?€ ?숆린??
        ItemState istate = new ItemState();

        istate.item_id = item.itemId;
        ItemController.State state = (ItemController.State)item.state;
        istate.state = (state == ItemController.State.Dropped)? ItemController.State.None : state;
        istate.owner = item.ownerId;
        if (GlobalParam.getInstance().item_table.ContainsKey(istate.item_id))
        {
            GlobalParam.getInstance().item_table.Remove(istate.item_id);
        }
        GlobalParam.getInstance().item_table.Add(istate.item_id, istate);

        string log = "[CLIENT] Receive itempacket [" +
                     "itemId:" + item.itemId +
                     " state:" + state.ToString() +
                     " ownerId:" + item.ownerId + "]";

        Debug.Log(log);
        dbwin.console().print(log);

        if (state == ItemController.State.Picked)
        {
            Debug.Log("Receive item pick.");
            dbwin.console().print("Receive item pick.");

            // ?묐떟???덈뒗  荑쇰━瑜??먯깋.
            QueryItemPick query_pick = QueryManager.get().findQuery <QueryItemPick>(x => x.target == item.itemId);

            bool remote_pick = true;

            if (query_pick != null)
            {
                string account_name = PartyControl.get().getLocalPlayer().getAcountID();
                if (item.ownerId == account_name)
                {
                    Debug.Log("Receive item pick local:" + item.ownerId);
                    dbwin.console().print("Receive item pick local:" + item.ownerId);

                    item_query_done(query_pick, true);
                    remote_pick = false;
                }
                else
                {
                    Debug.Log("Receive item pick remote:" + item.ownerId);
                    dbwin.console().print("Receive item pick remote:" + item.ownerId);

                    item_query_done(query_pick, false);
                }
            }

            if (remote_pick == true)
            {
                Debug.Log("Remote pick item:" + item.ownerId);
                dbwin.console().print("Remote pick item:" + item.ownerId);

                // 由щえ??罹먮┃?곌? 媛€吏€寃??쒕떎.
                chrController remote = CharacterRoot.getInstance().findPlayer(item.ownerId);
                if (remote)
                {
                    // ?꾩씠???띾뱷 荑쇰━ 諛쒗뻾.
                    QueryItemPick query = remote.cmdItemQueryPick(item.itemId, false, true);
                    if (query != null)
                    {
                        item_query_done(query, true);
                    }
                }
            }

            // ?꾩씠???띾뱷 ?곹깭 蹂€寃?
            this.setItemState(item.itemId, ItemController.State.Picked, item.ownerId);
        }
        else if (state == ItemController.State.Dropped)
        {
            Debug.Log("Receive item drop.");

            // ?묐떟???덈뒗 荑쇰━瑜?寃€??
            QueryItemDrop query_drop = QueryManager.get().findQuery <QueryItemDrop>(x => x.target == item.itemId);


            bool remote_drop = true;

            if (query_drop != null)
            {
                // ?붿껌???€???묐떟???덈떎.
                string account_name = AccountManager.get().getAccountData(GlobalParam.get().global_account_id).avator_id;
                if (item.ownerId == account_name)
                {
                    // ?먯떊???띾뱷.
                    Debug.Log("Receive item drop local:" + item.ownerId);
                    item_query_done(query_drop, true);
                    remote_drop = false;
                }
                else
                {
                    // ?곷?媛€ ?띾뱷.
                    Debug.Log("Receive item pick remote:" + item.ownerId);
                    item_query_done(query_drop, false);
                }
            }

            if (remote_drop == true)
            {
                // 由щえ??罹먮┃?곌? ?띾뱷.
                chrController remote = CharacterRoot.getInstance().findPlayer(item.ownerId);
                if (remote)
                {
                    // ?꾩씠?쒗쉷??荑쇰━ 諛쒗뻾.
                    Debug.Log("QuetyitemDrop:cmdItemQueryDrop");
                    remote.cmdItemDrop(item.itemId, false);
                }
            }
        }
        else
        {
            Debug.Log("Receive item error.");
        }
    }
Esempio n. 17
0
	// 떨어져 있는 아이템 줍기.
	public ItemController	pickItem(QueryItemPick query, string owner_id, string item_id)
	{
		// 프로그램의 버그를 막고자 쿼리가 없으면.
		// 줍지 못하게 했다.

		ItemController	item = null;
		
		do {
			
			// 일단 쿼리의 결과도 체크.
			if(!query.isSuccess()) {

				break;
			}
	
			item = this.find_item(item_id);
			
			if(item == null) {
				
				break;
			}

			item.picker = owner_id;
			item.startPicked();

			if (item_id.StartsWith("key")) {
				PartyControl.get().pickKey(item_id, owner_id);
			}

		} while(false);

		return(item);
	}
Esempio n. 18
0
    void    Update()
    {
        this.scene_timer += Time.deltaTime;
        this.disp_timer  -= Time.deltaTime;

        // ---------------------------------------------------------------- //
        // 다음 상태로 이동할지 체크합니다.

        switch (this.step.do_transition())
        {
        case STEP.GAME:
        {
        }
        break;
        }

        // ---------------------------------------------------------------- //
        // 상태가 전환될 때 초기화.

        while (this.step.get_next() != STEP.NONE)
        {
            switch (this.step.do_initialize())
            {
            case STEP.CHARACTER_CHANGE:
            {
                GlobalParam.get().account_name     = this.account_name_net;
                GlobalParam.get().skip_enter_event = true;

                Application.LoadLevel("GameScene 1");
            }
            break;

            case STEP.GAME:
            {
                this.account_name_local = GlobalParam.get().account_name;
                this.account_name_net   = GameRoot.getPartnerAcountName(this.account_name_local);

                if (this.owner == this.account_name_local)
                {
                    this.is_host = true;
                }
                else
                {
                    // 다른 플레이어의 마을에 갔을 때.
                    this.is_host = false;
                }

                // 플레이어를 만듭니다.
                this.local_player = CharacterRoot.get().createPlayerAsLocal(this.account_name_local);

                this.local_player.cmdSetPosition(Vector3.zero);

                if (GlobalParam.get().is_in_my_home == GlobalParam.get().is_remote_in_my_home)
                {
                    this.net_player = CharacterRoot.get().createPlayerAsNet(this.account_name_net);

                    this.net_player.cmdSetPosition(Vector3.left * 1.0f);
                }

                // 레벨 데이터(level_data.txt)를 읽고 NPC/아이템을 배치합니다.
                MapCreator.get().loadLevel(this.account_name_local, this.account_name_net, !this.is_host);

                SoundManager.get().playBGM(Sound.ID.TFT_BGM01);

                //

                if (!GlobalParam.get().skip_enter_event)
                {
                    EnterEvent enter_event = EventRoot.get().startEvent <EnterEvent>();

                    if (enter_event != null)
                    {
                        enter_event.setPrincipal(this.local_player.behavior as chrBehaviorPlayer);
                        enter_event.setIsLocalPlayer(true);
                    }
                }

                foreach (ItemManager.ItemState istate in GlobalParam.get().item_table.Values)
                {
                    if (istate.state == ItemController.State.Picked)
                    {
                        // 이미 아이템을 획득했다면 가져갈 수 있게 합니다.
                        ItemManager.get().finishGrowingItem(istate.item_id);
                        chrController controll = CharacterRoot.getInstance().findPlayer(istate.owner);
                        if (controll != null)
                        {
                            QueryItemPick query = controll.cmdItemQueryPick(istate.item_id, false, true);
                            if (query != null)
                            {
                                query.is_anon = true;
                                query.set_done(true);
                                query.set_success(true);
                            }
                        }
                    }
                }
            }
            break;

            // 다른 플레이어가 찾아왔습니다.
            case STEP.WELCOME:
            {
                if (this.net_player == null)
                {
                    EnterEvent enter_event = EventRoot.get().startEvent <EnterEvent>();

                    if (enter_event != null)
                    {
                        this.net_player = CharacterRoot.getInstance().createPlayerAsNet(this.account_name_net);

                        this.net_player.cmdSetPosition(Vector3.left);

                        enter_event.setPrincipal(this.net_player.behavior as chrBehaviorPlayer);
                        enter_event.setIsLocalPlayer(false);
                    }
                }
            }
            break;

            // 다른 플레이어가 돌아갑니다.
            case STEP.BYEBYE:
            {
                if (this.net_player != null)
                {
                    LeaveEvent leave_event = EventRoot.get().startEvent <LeaveEvent>();

                    if (leave_event != null)
                    {
                        leave_event.setPrincipal(this.net_player.behavior as chrBehaviorPlayer);
                        leave_event.setIsLocalPlayer(false);
                    }
                }
            }
            break;

            case STEP.VISIT:
            {
                GlobalParam.get().is_in_my_home = false;
                Application.LoadLevel("GameScene 1");
            }
            break;

            case STEP.GO_HOME:
            {
                // 자기 마을로 돌아옵니다.
                GlobalParam.get().is_in_my_home = true;
                Application.LoadLevel("GameScene 1");
            }
            break;

            case STEP.TO_TITLE:
            {
                Application.LoadLevel("TitleScene");
            }
            break;
            }
        }

        // ---------------------------------------------------------------- //
        // 각 상태에서의 실행 처리.

        switch (this.step.do_execution(Time.deltaTime))
        {
        case STEP.GAME:
        {
        }
        break;
        }

        // ---------------------------------------------------------------- //
        // 통신에 의한 이벤트 처리.

        // Network 클래스의 컴포넌트 획득.
        GameObject go      = GameObject.Find("Network");
        Network    network = go.GetComponent <Network>();

        if (network != null)
        {
            if (network.IsCommunicating() == true)
            {
                if (request_connet_event)
                {
                    // 접속 이벤트를 발동합니다.
                    GlobalParam.get().is_connected = true;
                    request_connet_event = false;
                }
                else if (GlobalParam.get().is_connected == false)
                {
                    // 접속했습니다.
                    Debug.Log("Guest connected.");
                    request_connet_event = true;
                    disp_timer           = 5.0f;
                }
            }
        }

        // 접속 종료 이벤트를 발동합니다.
        if (request_disconnet_event)
        {
            GlobalParam.get().is_disconnected = true;
            request_disconnet_event = false;
            // 접속 종료 시 이벤트.
            disconnect_event();
        }

        // ---------------------------------------------------------------- //

        if (Input.GetKeyDown(KeyCode.Z))
        {
            dbwin.console().print("로그 테스트 " + this.log_test_count);
            this.log_test_count++;
        }
    }
Esempio n. 19
0
	private void	resolve_pick_item_query(QueryItemPick query)
	{
		do {

			if(!query.isSuccess()) {

				break;
			}

			// 아이템 효능만 복사하고 삭제한다.

			ItemController	item = this.control.cmdItemPick(query, query.target);

			if(item == null) {

				break;
			}

			// 효과.
			EffectRoot.get().createItemGetEffect(this.control.getPosition());

			SoundManager.get().playSE(Sound.ID.DDG_SE_SYS02);

			switch(item.behavior.item_favor.category) {

				case Item.CATEGORY.CANDY:
				{
					// 아이템 창에 아이콘 표시.
					this.item_slot.candy.favor = item.behavior.item_favor.clone();

					ItemWindow.get().setItem(Item.SLOT_TYPE.CANDY, 0, this.item_slot.candy.favor);

					// 샷의 일정시간 파워업
					this.startShotBoost();
				}
				break;

				case Item.CATEGORY.SODA_ICE:
				case Item.CATEGORY.ETC:
				{
					// 빈 슬롯에 아이템 설정.
					int		slot_index = this.item_slot.getEmptyMiscSlot();

					if(slot_index >= 0) {

						this.item_slot.miscs[slot_index].item_id = query.target;
						this.item_slot.miscs[slot_index].favor   = item.behavior.item_favor.clone();

						// 아이템 창에 아이콘 표시.
						ItemWindow.get().setItem(Item.SLOT_TYPE.MISC, slot_index, this.item_slot.miscs[slot_index].favor);
					}
				}
				break;

				case Item.CATEGORY.FOOD:
				{
					// 체력 회복.
					if(GameRoot.get().isNowCakeBiking()) {

						this.control.vital.healFullInternal();

					} else {

						this.control.vital.healFull();

						// 레인보우 칼러 효과.
						this.skin_color_control.startHealing();
					}

					// 체력 회복을 알림.
					CharacterRoot.get().NotifyHitPoint(this.getAcountID(), this.control.vital.getHitPoint());

					// 아이템 폐기를 알림.
					this.control.cmdItemDrop(query.target);

					// 케이크를 먹은 수(케이크 무한제공용).
					this.cake_count++;
				}
				break;

				// 방 열쇠.
				case Item.CATEGORY.KEY:
				{
					PartyControl.get().getLocalPlayer().control.consumeKey(item);

					Item.KEY_COLOR	key_color = Item.Key.getColorFromInstanceName(item.name);

					// 아이템 창에 아이콘 표시.
					if(key_color != Item.KEY_COLOR.NONE) {

						ItemWindow.get().setItem(Item.SLOT_TYPE.KEY, (int)key_color, item.behavior.item_favor);
					}
				}
				break;

				// 플로어 이동 문 열쇠.
				case Item.CATEGORY.FLOOR_KEY:
				{
					MapCreator.getInstance().UnlockBossDoor();

					// 아이템 창에 아이콘 표시.
					ItemWindow.get().setItem(Item.SLOT_TYPE.FLOOR_KEY, 0, item.behavior.item_favor);
				}
				break;

				case Item.CATEGORY.WEAPON:
				{
					// 샷 변경(대파 발칸 / 유자 폭탄).
					SHOT_TYPE	shot_type = Item.Weapon.getShotType(item.name);

					if(shot_type != SHOT_TYPE.NONE) {

						this.changeBulletShooter(shot_type);
					}
				}
				break;
			}

			item.vanish();

		} while(false);

		query.set_expired(true);
	}
Esempio n. 20
0
    // 아이템 정보 패킷 획득 함수.
    public void OnReceiveItemPacket(PacketId id, byte[] data)
    {
        ItemPacket packet = new ItemPacket(data);
        ItemData   item   = packet.GetPacket();

        // 서버의 상태와 동기화합니다.
        ItemState istate = new ItemState();

        istate.item_id = item.itemId;
        ItemController.State state = (ItemController.State)item.state;
        istate.state = (state == ItemController.State.Dropped)? ItemController.State.None : state;
        istate.owner = item.ownerId;
        if (GlobalParam.get().item_table.ContainsKey(item.itemId))
        {
            GlobalParam.get().item_table.Remove(istate.item_id);
        }
        GlobalParam.get().item_table.Add(istate.item_id, istate);

        string log = "[CLIENT] Receive itempacket. " +
                     "itemId:" + item.itemId +
                     " state:" + state.ToString() +
                     " ownerId:" + item.ownerId;

        Debug.Log(log);

        if (state == ItemController.State.Picked)
        {
            Debug.Log("Receive item pick.");

            // 응답이 있는 쿼리를 검색.
            QueryItemPick query_pick = null;
            foreach (var query in this.queries)
            {
                QueryItemPick pick = query as QueryItemPick;
                if (pick != null && pick.target == item.itemId)
                {
                    query_pick = pick;
                    break;
                }
            }

            bool remote_pick = true;

            if (query_pick != null)
            {
                if (item.ownerId == GlobalParam.get().account_name)
                {
                    Debug.Log("Receive item pick local:" + item.ownerId);
                    item_query_done(query_pick, true);
                    remote_pick = false;
                }
                else
                {
                    Debug.Log("Receive item pick remote:" + item.ownerId);
                    item_query_done(query_pick, false);
                }
            }

            if (remote_pick == true)
            {
                // 리모트 캐릭터가 취득하게 합니다.
                chrController remote = CharacterRoot.getInstance().findPlayer(item.ownerId);
                if (remote)
                {
                    // 아이템 획득 쿼리 발행.
                    QueryItemPick query = remote.cmdItemQueryPick(item.itemId, false, true);
                    if (query != null)
                    {
                        item_query_done(query, true);
                    }
                }
            }
        }
        else if (state == ItemController.State.Dropped)
        {
            Debug.Log("Receive item drop.");

            // 응답이 있는 쿼리를 검색.
            QueryItemDrop query_drop = null;
            foreach (var query in this.queries)
            {
                QueryItemDrop drop = query as QueryItemDrop;
                if (drop != null && drop.target == item.itemId)
                {
                    query_drop = drop;
                    break;
                }
            }

            bool remote_drop = true;

            if (query_drop != null)
            {
                // 요청에 대한 응답이 있을 때.
                if (item.ownerId == GlobalParam.get().account_name)
                {
                    // 자신이 획득.
                    Debug.Log("Receive item drop local:" + item.ownerId);
                    item_query_done(query_drop, true);
                    remote_drop = false;
                }
                else
                {
                    // 상대가 획득.
                    Debug.Log("Receive item pick remote:" + item.ownerId);
                    item_query_done(query_drop, false);
                }
            }

            if (remote_drop == true)
            {
                // 리모트 캐릭터가 회득하게 합니다.
                chrController remote = CharacterRoot.getInstance().findPlayer(item.ownerId);
                if (remote)
                {
                    // 아이템 획득 쿼리 발행.
                    Debug.Log("QuetyitemDrop:cmdItemQueryDrop");
                    QueryItemDrop query = remote.cmdItemQueryDrop(false);
                    if (query != null)
                    {
                        query.is_drop_done = true;
                        item_query_done(query, true);
                    }
                }
            }
        }
        else
        {
            Debug.Log("Receive item error.");
        }
    }
Esempio n. 21
0
    public override void    execute()
    {
        CameraControl camera = CameraControl.get();

        // ---------------------------------------------------------------- //
        // 다음 상태로 이동할지 체크합니다.

        switch (this.step.do_transition())
        {
        // 이벤트 시작.
        case STEP.START:
        {
            this.step.set_next(STEP.OPEN_DOOR);
            //camera.module.parallelMoveTo(this.get_locator_position("cam_loc_0"));

            Debug.Log("Name:" + this.player.controll.account_name);

            foreach (ItemManager.ItemState istate in GlobalParam.get().item_table.Values)
            {
                Debug.Log("Item:" + istate.item_id + " Own:" + istate.owner + " State:" + istate.state);

                if (istate.owner == this.player.controll.account_name &&
                    istate.state == ItemController.State.Picked)
                {
                    // 이미 아이템을 획득했다면 가지고 갈 수 있게 합니다.
                    ItemManager.get().activeItme(istate.item_id, true);
                    ItemManager.get().finishGrowingItem(istate.item_id);
                    QueryItemPick query = this.player.controll.cmdItemQueryPick(istate.item_id, false, true);
                    if (query != null)
                    {
                        query.is_anon = true;
                        query.set_done(true);
                        query.set_success(true);
                    }
                    ItemManager.get().setVisible(istate.item_id, true);
                }
            }

            // 리모트에서 이사 중은 로컬도 이사합니다.
            do
            {
                MovingData moving = GlobalParam.get().remote_moving;
                if (!moving.moving)
                {
                    break;
                }

                chrController remote = CharacterRoot.get().findCharacter(moving.characterId);
                if (remote == null)
                {
                    break;
                }

                chrBehaviorNet remote_player = remote.behavior as chrBehaviorNet;
                if (remote_player == null)
                {
                    break;
                }

                chrBehaviorNPC_House house = CharacterRoot.getInstance().findCharacter <chrBehaviorNPC_House>(moving.houseId);
                if (house == null)
                {
                    break;
                }

                Debug.Log("House move event call:" + moving.characterId + ":" + moving.houseId);

                remote_player.beginHouseMove(house);

                // '이사중~' 말풍선 표시.
                house.startHouseMove();
            } while(false);
        }
        break;

        // 배추가 옆으로 움직이고 & 대야를 타고 플레이어가 등장.
        case STEP.OPEN_DOOR:
        {
            if (this.hakusai_fcurve.isDone() && this.tarai_fcurve.isDone())
            {
                this.step.set_next(STEP.GET_OFF_TARAI_0);
            }
        }
        break;

        // 대야에서 내립니다(기슭으로 점프).
        case STEP.GET_OFF_TARAI_0:
        {
            if (!this.player_jump.isMoving())
            {
                this.step.set_next(STEP.GET_OFF_TARAI_1);
            }
        }
        break;

        // 대야에서 내립니다(조금 걷기).
        case STEP.GET_OFF_TARAI_1:
        {
            if (!this.player_move.isMoving())
            {
                this.step.set_next(STEP.CLOSE_DOOR);
            }
        }
        break;


        // 배추가 돌아오고 & 대야가 밖으로 이동.
        case STEP.CLOSE_DOOR:
        {
            if (this.hakusai_fcurve.isDone() && this.tarai_fcurve.isDone())
            {
                this.step.set_next(STEP.END);
            }
        }
        break;

        case STEP.END:
        {
            camera.module.popPosture();

            this.step.set_next(STEP.IDLE);
        }
        break;
        }

        // ---------------------------------------------------------------- //
        // 상태가 전환됐을 때의 초기화.

        while (this.step.get_next() != STEP.NONE)
        {
            dbwin.console().print(this.step.ToString());

            switch (this.step.do_initialize())
            {
            // 이벤트 시작.
            case STEP.START:
            {
                camera.module.pushPosture();

                this.player.beginOuterControll();
                this.player.controll.cmdSetPosition(this.tarai_leave_spline.curve.cvs.back().position);

                this.tarai_fune.transform.position = this.tarai_leave_spline.curve.cvs.back().position;

                if (!this.is_local_player)
                {
                    SoundManager.get().playSE(Sound.ID.SMN_JINGLE01);
                }
            }
            break;

            // 배추가 옆으로 이동하고 & 대야를 타고 플레이어가 등장.
            case STEP.OPEN_DOOR:
            {
                this.hakusai_set.setControl(true);
                this.hakusai_fcurve.setSlopeAngle(10.0f, 10.0f);
                this.hakusai_fcurve.setDuration(4.0f);
                this.hakusai_fcurve.start();
                this.hakusai_tracer.restart();

                this.tarai_fcurve.setSlopeAngle(60.0f, 5.0f);
                this.tarai_fcurve.setDuration(3.5f);
                this.tarai_fcurve.setDelay(0.5f);
                this.tarai_fcurve.start();
            }
            break;

            // 대야에서 내립니다(기슭으로 점프).
            case STEP.GET_OFF_TARAI_0:
            {
                Vector3 start = this.player.controll.getPosition();
                Vector3 goal  = this.get_locator_position("chr_loc_0");

                this.player_jump.start(start, goal, 1.0f);
            }
            break;

            // 대야에서 내립니다(조금 걷기).
            case STEP.GET_OFF_TARAI_1:
            {
                this.player_move.position.start = this.player.controll.getPosition();
                this.player_move.position.goal  = this.get_locator_position("chr_loc_1");
                this.player_move.startConstantVelocity(chrBehaviorLocal.MOVE_SPEED);
            }
            break;

            // 배추가 돌아오고 & 대야가 밖으로 이동.
            case STEP.CLOSE_DOOR:
            {
                this.hakusai_fcurve.setSlopeAngle(10.0f, 10.0f);
                this.hakusai_fcurve.setDuration(4.0f);
                this.hakusai_fcurve.setDelay(1.0f);
                this.hakusai_fcurve.start();
                this.hakusai_tracer.restart();
                this.hakusai_tracer.setCurrentByDistance(this.hakusai_tracer.curve.calcTotalDistance());

                this.tarai_tracer.attach(this.tarai_enter_spline.curve);
                this.tarai_tracer.restart();
                this.tarai_fcurve.reset();
                this.tarai_fcurve.setSlopeAngle(10.0f, 60.0f);
                this.tarai_fcurve.setDuration(2.5f);
                this.tarai_fcurve.start();

                this.ripple_effect.is_created = false;
            }
            break;

            case STEP.END:
            {
                // 이벤트 종료.
                this.hakusai_set.reset();
                this.hakusai_set.setControl(false);

                this.player.endOuterControll();

                this.player = null;
            }
            break;
            }
        }

        // ---------------------------------------------------------------- //
        // 각 상태에서의 실행 처리.

        switch (this.step.do_execution(Time.deltaTime))
        {
        // 배추가 옆으로 움직인다 & 대야를 타고 플레이어가 등장..
        case STEP.OPEN_DOOR:
        {
            this.hakusai_fcurve.execute(Time.deltaTime);
            this.hakusai_tracer.proceedToDistance(this.hakusai_tracer.curve.calcTotalDistance() * this.hakusai_fcurve.getValue());
            this.hakusai_set.setPosition(this.hakusai_tracer.cv.position);

            this.tarai_fcurve.execute(Time.deltaTime);
            this.tarai_tracer.proceedToDistance(this.tarai_tracer.curve.calcTotalDistance() * (1.0f - this.tarai_fcurve.getValue()));

            SimpleSpline.ControlVertex cv = this.tarai_tracer.getCurrent();

            this.tarai_fune.setPosition(cv.position);
            this.player.controll.cmdSetPosition(cv.position);
            this.player.controll.cmdSmoothHeadingTo(cv.position - cv.tangent.Y(0.0f));

            if (this.tarai_fcurve.isTriggerDone())
            {
                this.ripple_effect.is_created = false;
            }
        }
        break;

        // 대야에서 내립니다(기슭을 향해 점프).
        case STEP.GET_OFF_TARAI_0:
        {
            this.player_jump.execute(Time.deltaTime);
            this.player.controll.cmdSetPosition(this.player_jump.position);
            this.player.controll.cmdSmoothHeadingTo(this.player_jump.goal);
        }
        break;

        // 대야에서 내립니다(조금 걷는다).
        case STEP.GET_OFF_TARAI_1:
        {
            this.player_move.execute(Time.deltaTime);
            this.player.controll.cmdSetPosition(this.player_move.position.current);
            this.player.controll.cmdSmoothHeadingTo(this.player_move.position.goal);
            this.player.playWalkMotion();
        }
        break;

        // 배추가 돌아옵니다 & 대야가 밖으로 이동.
        case STEP.CLOSE_DOOR:
        {
            this.hakusai_fcurve.execute(Time.deltaTime);
            this.hakusai_tracer.proceedToDistance(this.hakusai_tracer.curve.calcTotalDistance() * (1.0f - this.hakusai_fcurve.getValue()));
            this.hakusai_set.setPosition(this.hakusai_tracer.getCurrent().position);

            this.tarai_fcurve.execute(Time.deltaTime);
            this.tarai_tracer.proceedToDistance(this.tarai_tracer.curve.calcTotalDistance() * (1.0f - this.tarai_fcurve.getValue()));
            this.tarai_fune.transform.position = this.tarai_tracer.getCurrent().position;
            this.player.stopWalkMotion();
        }
        break;
        }

        // 대야 뒤에 나오는 물결.
        if (!this.ripple_effect.is_created || Vector3.Distance(this.ripple_effect.last_position, this.tarai_fune.getPosition()) > 2.0f)
        {
            this.ripple_effect.is_created    = true;
            this.ripple_effect.last_position = this.tarai_fune.transform.position;

            EffectRoot.get().createRipple(this.ripple_effect.last_position);
        }

        // ---------------------------------------------------------------- //
    }
Esempio n. 22
0
	// ================================================================ //
	// 鍮꾪뿤?대퉬?댁슜 而ㅻ㎤??
	// 荑쇰━ 怨?

	// ?⑥뼱???덈뒗 ?꾩씠?쒖쓣 二쇱썙???섎뒗媛€?.
	public QueryItemPick	queryPickItem(string owner_id, string item_id, bool is_local, bool forece_pickup)
	{
		ItemController	item = null;
		QueryItemPick	query = null;
		bool			needMediation = is_local;

		do {
			
			item = this.find_item(item_id);
			
			if(item == null) {

				needMediation = false;
				break;
			}

			// ?깆옣 以묒씤 寃껋? 二쇱슱 ???녿떎.
			if(!item.isPickable() && !forece_pickup) {

				needMediation = false;
				break;
			}

			// ?대? ?꾧뎔媛€ 媛€吏€怨??덈뒗 寃껋? 二쇱슱 ???녿떎.
			if(item.picker != "") {

				needMediation = false;
				break;
			}

			query = new QueryItemPick(owner_id, item_id);

			QueryManager.get().registerQuery(query);

			// ?띾뱷 以??곹깭濡?蹂€寃쏀븳??
			this.setItemState(item_id, ItemController.State.PickingUp, owner_id);

		} while(false);

		if (GameRoot.get().isNowCakeBiking() == false) {
			if(needMediation) {
				// ?꾩씠???띾뱷 臾몄쓽瑜??쒕떎.
				SendItemStateChanged(item_id, ItemController.State.PickingUp, owner_id);
			}
		}

		return(query);
	}
Esempio n. 23
0
	private void	resolve_pick_item_query(QueryItemPick query)
	{
		do {

			if(!query.isSuccess()) {

				break;
			}

			// ?꾩씠???④낵留?蹂듭궗?섍퀬 ??젣?쒕떎.

			ItemController	item = this.control.cmdItemPick(query, query.target);

			if(item == null) {

				break;
			}

			// ?댄럺??
			EffectRoot.get().createItemGetEffect(this.control.getPosition());

			SoundManager.get().playSE(Sound.ID.DDG_SE_SYS02);

			Debug.Log("Item favor category:" + item.behavior.item_favor.category);
			switch(item.behavior.item_favor.category) {

				case Item.CATEGORY.FOOD:
				{
					this.control.vital.healFull();
					
					this.skin_color_control.startHealing();

					this.cake_count++;
				}
				break;

				case Item.CATEGORY.KEY:
				{
					PartyControl.get().getLocalPlayer().control.consumeKey(item);
				}
				break;	
				
				case Item.CATEGORY.FLOOR_KEY:
				{
					PartyControl.get().getLocalPlayer().control.consumeKey(item);
				}
				break;	

				case Item.CATEGORY.CANDY:
				{
					this.startShotBoost();
				}
				break;

				case Item.CATEGORY.WEAPON:
				{
					SHOT_TYPE	shot_type = Item.Weapon.getShotType(item.name);
					
					if(shot_type != SHOT_TYPE.NONE) {
						
						this.changeBulletShooter(shot_type);
					}
				}
				break;
			}
			
			item.vanish();

		} while(false);

		query.set_expired(true);
	}
Esempio n. 24
0
	// ?⑥뼱???덈뒗 ?꾩씠??以띻린.
	public ItemController	pickItem(QueryItemPick query, string owner_id, string item_id)
	{
		// ?꾨줈洹몃옩??踰꾧렇瑜?留됯퀬??荑쇰━媛€ ?놁쑝硫?
		// 以띿? 紐삵븯寃??덈떎.

		ItemController	item = null;
		
		do {
			
			// ?쇰떒 荑쇰━??寃곌낵??泥댄겕.
			if(!query.isSuccess()) {

				break;
			}
	
			item = this.find_item(item_id);
			
			if(item == null) {
				
				break;
			}

			item.picker = owner_id;
			item.startPicked();

			if (item_id.StartsWith("key")) {
				PartyControl.get().pickKey(item_id, owner_id);
			}

		} while(false);

		return(item);
	}
Esempio n. 25
0
    private void    resolve_pick_item_query(QueryItemPick query)
    {
        do
        {
            if (!query.isSuccess())
            {
                break;
            }

            // 아이템 효과만 복사하고 삭제한다.

            ItemController item = this.control.cmdItemPick(query, query.target);

            if (item == null)
            {
                break;
            }

            // 이펙트.
            EffectRoot.get().createItemGetEffect(this.control.getPosition());

            SoundManager.get().playSE(Sound.ID.DDG_SE_SYS02);

            Debug.Log("Item favor category:" + item.behavior.item_favor.category);
            switch (item.behavior.item_favor.category)
            {
            case Item.CATEGORY.FOOD:
            {
                this.control.vital.healFull();

                this.skin_color_control.startHealing();

                this.cake_count++;
            }
            break;

            case Item.CATEGORY.KEY:
            {
                PartyControl.get().getLocalPlayer().control.consumeKey(item);
            }
            break;

            case Item.CATEGORY.FLOOR_KEY:
            {
                PartyControl.get().getLocalPlayer().control.consumeKey(item);
            }
            break;

            case Item.CATEGORY.CANDY:
            {
                this.startShotBoost();
            }
            break;

            case Item.CATEGORY.WEAPON:
            {
                SHOT_TYPE shot_type = Item.Weapon.getShotType(item.name);

                if (shot_type != SHOT_TYPE.NONE)
                {
                    this.changeBulletShooter(shot_type);
                }
            }
            break;
            }

            item.vanish();
        } while(false);

        query.set_expired(true);
    }
Esempio n. 26
0
	// 떨어져 있는 아이템을 줍습니다.
	public ItemController	pickItem(QueryItemPick query, string owner_id, string item_id)
	{
		// 프로그램의 버그를 막고자 쿼리가 없으면
		// 주울 수 없게 했습니다.

		ItemController	item = null;
		
		do {
			
			// 일단 쿼리 결과도 체크합니다.
			if(!query.isSuccess()) {

				break;
			}
	
			item = this.find_item(item_id);
			
			if(item == null) {
				
				break;
			}

			item.picker = owner_id;
			item.startPicked();

		} while(false);

		return(item);
	}
Esempio n. 27
0
	// ================================================================ //
	// 비헤이비어용 커맨드.
	// 쿼리.

	// 떨어져 있는 아이템을 주워도 되는가?.
	public QueryItemPick	queryPickItem(string owner_id, string item_id, bool local, bool force)
	{
		ItemController		item = null;
		QueryItemPick		query = null;
		bool				notify = false;

		do {
			
			item = this.find_item(item_id);
			
			if(item == null) {
				break;
			}
		
			// 성장 중인 것은 주울 수 없습니다.
			if(!item.isPickable() && !force) {
				
				break;
			}
			
			// 이미 누군가가 소지 중인 것은 주울 수 없습니다.
			if(item.picker != "") {
				
				break;
			}
			
			query = new QueryItemPick(item_id);
			
			this.queries.Add(query);
			notify = true;
		} while(false);

		// 로컬 캐릭터가 아이템의 쿼리를 발행했을 때만 서버에 송신합니다.]
		if(notify && local) {
			// 아이템의 스테이트를 네트워크로 보냅니다.
			SendItemStateChanged(item_id, ItemController.State.PickingUp, owner_id);
		}

		return(query);
	}
Esempio n. 28
0
    // ================================================================ //

    // 아이템 정보 패킷 취득 함수.
    public void OnReceiveItemPacket(int node, PacketId id, byte[] data)
    {
        ItemPacket packet = new ItemPacket(data);
        ItemData   item   = packet.GetPacket();

        // 서버 상태와 동기화.
        ItemState istate = new ItemState();

        istate.item_id = item.itemId;
        ItemController.State state = (ItemController.State)item.state;
        istate.state = (state == ItemController.State.Dropped)? ItemController.State.None : state;
        istate.owner = item.ownerId;
        if (GlobalParam.getInstance().item_table.ContainsKey(istate.item_id))
        {
            GlobalParam.getInstance().item_table.Remove(istate.item_id);
        }
        GlobalParam.getInstance().item_table.Add(istate.item_id, istate);

        string log = "[CLIENT] Receive itempacket [" +
                     "itemId:" + item.itemId +
                     " state:" + state.ToString() +
                     " ownerId:" + item.ownerId + "]";

        Debug.Log(log);
        dbwin.console().print(log);

        if (state == ItemController.State.Picked)
        {
            Debug.Log("Receive item pick.");
            dbwin.console().print("Receive item pick.");

            // 응답이 있는  쿼리를 탐색.
            QueryItemPick query_pick = QueryManager.get().findQuery <QueryItemPick>(x => x.target == item.itemId);

            bool remote_pick = true;

            if (query_pick != null)
            {
                string account_name = PartyControl.get().getLocalPlayer().getAcountID();
                if (item.ownerId == account_name)
                {
                    Debug.Log("Receive item pick local:" + item.ownerId);
                    dbwin.console().print("Receive item pick local:" + item.ownerId);

                    item_query_done(query_pick, true);
                    remote_pick = false;
                }
                else
                {
                    Debug.Log("Receive item pick remote:" + item.ownerId);
                    dbwin.console().print("Receive item pick remote:" + item.ownerId);

                    item_query_done(query_pick, false);
                }
            }

            if (remote_pick == true)
            {
                Debug.Log("Remote pick item:" + item.ownerId);
                dbwin.console().print("Remote pick item:" + item.ownerId);

                // 리모트 캐릭터가 가지게 한다.
                chrController remote = CharacterRoot.getInstance().findPlayer(item.ownerId);
                if (remote)
                {
                    // 아이템 획득 쿼리 발행.
                    QueryItemPick query = remote.cmdItemQueryPick(item.itemId, false, true);
                    if (query != null)
                    {
                        item_query_done(query, true);
                    }
                }
            }

            // 아이템 획득 상태 변경.
            this.setItemState(item.itemId, ItemController.State.Picked, item.ownerId);
        }
        else if (state == ItemController.State.Dropped)
        {
            Debug.Log("Receive item drop.");

            // 응답이 있는 쿼리를 검색.
            QueryItemDrop query_drop = QueryManager.get().findQuery <QueryItemDrop>(x => x.target == item.itemId);


            bool remote_drop = true;

            if (query_drop != null)
            {
                // 요청에 대한 응답이 있다.
                string account_name = AccountManager.get().getAccountData(GlobalParam.get().global_account_id).avator_id;
                if (item.ownerId == account_name)
                {
                    // 자신이 획득.
                    Debug.Log("Receive item drop local:" + item.ownerId);
                    item_query_done(query_drop, true);
                    remote_drop = false;
                }
                else
                {
                    // 상대가 획득.
                    Debug.Log("Receive item pick remote:" + item.ownerId);
                    item_query_done(query_drop, false);
                }
            }

            if (remote_drop == true)
            {
                // 리모트 캐릭터가 획득.
                chrController remote = CharacterRoot.getInstance().findPlayer(item.ownerId);
                if (remote)
                {
                    // 아이템획득 쿼리 발행.
                    Debug.Log("QuetyitemDrop:cmdItemQueryDrop");
                    remote.cmdItemDrop(item.itemId, false);
                }
            }
        }
        else
        {
            Debug.Log("Receive item error.");
        }
    }
Esempio n. 29
0
	private void	resolve_pick_item_query(QueryItemPick query)
	{
		do {

			if(!query.isSuccess()) {

				break;
			}

			// ?꾩씠???⑤뒫留?蹂듭궗?섍퀬 ??젣?쒕떎.

			ItemController	item = this.control.cmdItemPick(query, query.target);

			if(item == null) {

				break;
			}

			// ?④낵.
			EffectRoot.get().createItemGetEffect(this.control.getPosition());

			SoundManager.get().playSE(Sound.ID.DDG_SE_SYS02);

			switch(item.behavior.item_favor.category) {

				case Item.CATEGORY.CANDY:
				{
					// ?꾩씠??李쎌뿉 ?꾩씠肄??쒖떆.
					this.item_slot.candy.favor = item.behavior.item_favor.clone();

					ItemWindow.get().setItem(Item.SLOT_TYPE.CANDY, 0, this.item_slot.candy.favor);

					// ?룹쓽 ?쇱젙?쒓컙 ?뚯썙??					this.startShotBoost();
				}
				break;

				case Item.CATEGORY.SODA_ICE:
				case Item.CATEGORY.ETC:
				{
					// 鍮??щ’???꾩씠???ㅼ젙.
					int		slot_index = this.item_slot.getEmptyMiscSlot();

					if(slot_index >= 0) {

						this.item_slot.miscs[slot_index].item_id = query.target;
						this.item_slot.miscs[slot_index].favor   = item.behavior.item_favor.clone();

						// ?꾩씠??李쎌뿉 ?꾩씠肄??쒖떆.
						ItemWindow.get().setItem(Item.SLOT_TYPE.MISC, slot_index, this.item_slot.miscs[slot_index].favor);
					}
				}
				break;

				case Item.CATEGORY.FOOD:
				{
					// 泥대젰 ?뚮났.
					if(GameRoot.get().isNowCakeBiking()) {

						this.control.vital.healFullInternal();

					} else {

						this.control.vital.healFull();

						// ?덉씤蹂댁슦 移쇰윭 ?④낵.
						this.skin_color_control.startHealing();
					}

					// 泥대젰 ?뚮났???뚮┝.
					CharacterRoot.get().NotifyHitPoint(this.getAcountID(), this.control.vital.getHitPoint());

					// ?꾩씠???먭린瑜??뚮┝.
					this.control.cmdItemDrop(query.target);

					// 耳€?댄겕瑜?癒뱀? ??耳€?댄겕 臾댄븳?쒓났??.
					this.cake_count++;
				}
				break;

				// 諛??댁뇿.
				case Item.CATEGORY.KEY:
				{
					PartyControl.get().getLocalPlayer().control.consumeKey(item);

					Item.KEY_COLOR	key_color = Item.Key.getColorFromInstanceName(item.name);

					// ?꾩씠??李쎌뿉 ?꾩씠肄??쒖떆.
					if(key_color != Item.KEY_COLOR.NONE) {

						ItemWindow.get().setItem(Item.SLOT_TYPE.KEY, (int)key_color, item.behavior.item_favor);
					}
				}
				break;

				// ?뚮줈???대룞 臾??댁뇿.
				case Item.CATEGORY.FLOOR_KEY:
				{
					MapCreator.getInstance().UnlockBossDoor();

					// ?꾩씠??李쎌뿉 ?꾩씠肄??쒖떆.
					ItemWindow.get().setItem(Item.SLOT_TYPE.FLOOR_KEY, 0, item.behavior.item_favor);
				}
				break;

				case Item.CATEGORY.WEAPON:
				{
					// ??蹂€寃??€??諛쒖뭏 / ?좎옄 ??깂).
					SHOT_TYPE	shot_type = Item.Weapon.getShotType(item.name);

					if(shot_type != SHOT_TYPE.NONE) {

						this.changeBulletShooter(shot_type);
					}
				}
				break;
			}

			item.vanish();

		} while(false);

		query.set_expired(true);
	}
Esempio n. 30
0
	// ================================================================ //
	// 비헤이비어용 커맨드.
	// 쿼리 계.

	// 떨어져 있는 아이템을 주워도 되는가?.
	public QueryItemPick	queryPickItem(string owner_id, string item_id, bool is_local, bool forece_pickup)
	{
		ItemController	item = null;
		QueryItemPick	query = null;
		bool			needMediation = is_local;

		do {
			
			item = this.find_item(item_id);
			
			if(item == null) {

				needMediation = false;
				break;
			}

			// 성장 중인 것은 주울 수 없다.
			if(!item.isPickable() && !forece_pickup) {

				needMediation = false;
				break;
			}

			// 이미 누군가 가지고 있는 것은 주울 수 없다.
			if(item.picker != "") {

				needMediation = false;
				break;
			}

			query = new QueryItemPick(owner_id, item_id);

			QueryManager.get().registerQuery(query);

			// 획득 중 상태로 변경한다.
			this.setItemState(item_id, ItemController.State.PickingUp, owner_id);

		} while(false);

		if (GameRoot.get().isNowCakeBiking() == false) {
			if(needMediation) {
				// 아이템 획득 문의를 한다.
				SendItemStateChanged(item_id, ItemController.State.PickingUp, owner_id);
			}
		}

		return(query);
	}
Esempio n. 31
0
    private void    resolve_pick_item_query(QueryItemPick query)
    {
        do
        {
            if (!query.isSuccess())
            {
                break;
            }

            // 아이템 효능만 복사하고 삭제한다.

            ItemController item = this.control.cmdItemPick(query, query.target);

            if (item == null)
            {
                break;
            }

            // 효과.
            EffectRoot.get().createItemGetEffect(this.control.getPosition());

            SoundManager.get().playSE(Sound.ID.DDG_SE_SYS02);

            switch (item.behavior.item_favor.category)
            {
            case Item.CATEGORY.CANDY:
            {
                // 아이템 창에 아이콘 표시.
                this.item_slot.candy.favor = item.behavior.item_favor.clone();

                ItemWindow.get().setItem(Item.SLOT_TYPE.CANDY, 0, this.item_slot.candy.favor);

                // 샷의 일정시간 파워업
                this.startShotBoost();
            }
            break;

            case Item.CATEGORY.SODA_ICE:
            case Item.CATEGORY.ETC:
            {
                // 빈 슬롯에 아이템 설정.
                int slot_index = this.item_slot.getEmptyMiscSlot();

                if (slot_index >= 0)
                {
                    this.item_slot.miscs[slot_index].item_id = query.target;
                    this.item_slot.miscs[slot_index].favor   = item.behavior.item_favor.clone();

                    // 아이템 창에 아이콘 표시.
                    ItemWindow.get().setItem(Item.SLOT_TYPE.MISC, slot_index, this.item_slot.miscs[slot_index].favor);
                }
            }
            break;

            case Item.CATEGORY.FOOD:
            {
                // 체력 회복.
                if (GameRoot.get().isNowCakeBiking())
                {
                    this.control.vital.healFullInternal();
                }
                else
                {
                    this.control.vital.healFull();

                    // 레인보우 칼러 효과.
                    this.skin_color_control.startHealing();
                }

                // 체력 회복을 알림.
                CharacterRoot.get().NotifyHitPoint(this.getAcountID(), this.control.vital.getHitPoint());

                // 아이템 폐기를 알림.
                this.control.cmdItemDrop(query.target);

                // 케이크를 먹은 수(케이크 무한제공용).
                this.cake_count++;
            }
            break;

            // 방 열쇠.
            case Item.CATEGORY.KEY:
            {
                PartyControl.get().getLocalPlayer().control.consumeKey(item);

                Item.KEY_COLOR key_color = Item.Key.getColorFromInstanceName(item.name);

                // 아이템 창에 아이콘 표시.
                if (key_color != Item.KEY_COLOR.NONE)
                {
                    ItemWindow.get().setItem(Item.SLOT_TYPE.KEY, (int)key_color, item.behavior.item_favor);
                }
            }
            break;

            // 플로어 이동 문 열쇠.
            case Item.CATEGORY.FLOOR_KEY:
            {
                MapCreator.getInstance().UnlockBossDoor();

                // 아이템 창에 아이콘 표시.
                ItemWindow.get().setItem(Item.SLOT_TYPE.FLOOR_KEY, 0, item.behavior.item_favor);
            }
            break;

            case Item.CATEGORY.WEAPON:
            {
                // 샷 변경(대파 발칸 / 유자 폭탄).
                SHOT_TYPE shot_type = Item.Weapon.getShotType(item.name);

                if (shot_type != SHOT_TYPE.NONE)
                {
                    this.changeBulletShooter(shot_type);
                }
            }
            break;
            }

            item.vanish();
        } while(false);

        query.set_expired(true);
    }