Exemplo n.º 1
0
    // 소환수를 소환한다.
    public void     notifySummonBeast(Character.BEAST_TYPE beast_type)
    {
        string beast_name = "";

        do
        {
            if (this.beast != null)
            {
                break;
            }

            switch (beast_type)
            {
            case Character.BEAST_TYPE.DOG:
            {
                beast_name = "Dog";
            }
            break;

            case Character.BEAST_TYPE.NEKO:
            {
                beast_name = "Neko";
            }
            break;
            }

            if (beast_name == "")
            {
                break;
            }

            // 소환수 출현 알림.
            if (m_network != null)
            {
                SummonData data = new SummonData();

                data.summon = beast_name;

                SummonPacket packet     = new SummonPacket(data);
                int          serverNode = m_network.GetServerNode();
                m_network.SendReliable <SummonData>(serverNode, packet);

                Debug.Log("[CLIENT] send summon beast:" + beast_name);
            }
        } while(false);
    }
Exemplo n.º 2
0
    // 소환수 출현 체크.
    private void    checkSummonBeast()
    {
        if (m_network == null)
        {
            return;
        }

        bool isInRange = true;

        if (this.players.Count <= 1)
        {
            // 혼자일 때는 나타나지 않음.
            return;
        }

        chrBehaviorLocal local_behavior = this.getLocalPlayer();

        Vector3 local_pos = local_behavior.transform.position;

        for (int gid = 0; gid < NetConfig.PLAYER_MAX; ++gid)
        {
            int node = m_network.GetClientNode(gid);

            if (m_network.IsConnected(node) == false)
            {
                continue;
            }

            chrBehaviorPlayer remote_behavior = this.getFriendByGlobalIndex(gid);

            if (remote_behavior == null)
            {
                isInRange = false;
                break;
            }

            // 5m 범위 내에 모여 있으면 나타난다.
            Vector3 remote_pos = remote_behavior.transform.position;
            if ((local_pos - remote_pos).magnitude > 5.0f)
            {
                isInRange = false;
                break;
            }
        }

        if (isInRange)
        {
            this.summon_time += Time.deltaTime;
        }
        else
        {
            // 출현 조건을 리셋.
            this.summon_time = 0.0f;
        }

        if (this.summon_time > SUMMON_TIME_CONDITION)
        {
            Character.BEAST_TYPE type = (Random.Range(0, 10) < 7)? Character.BEAST_TYPE.DOG : Character.BEAST_TYPE.NEKO;
            notifySummonBeast(type);
            this.summon_time = 0.0f;
        }
    }