Esempio n. 1
0
    public IEnumerator PartsMove()
    {
        Vector3 target     = GetPlayer.transform.position + GetPlayer.transform.forward * 2f;
        Vector3 targetTemp = target;

        targetTemp.y += 2f;
        target        = targetTemp;

        float elapsedTime = 0;
        float finish1Time = 2f;
        float finish2Time = 5f;
        float moveSpeed   = 0.5f;

        while (elapsedTime <= finish1Time)
        {
            yield return(new WaitForSeconds(0.02f));

            elapsedTime       += Time.deltaTime;
            transform.position = Vector3.MoveTowards(transform.position, target, Time.deltaTime * 2f);
            if (transform.position.y >= target.y)
            {
                break;
            }
        }

        if (lineRend != null)
        {
            lineRend.enabled = true;
        }

        yield return(new WaitForSeconds(1f));

        //AssetManager.Effect.Retrieve("DirectionSound_PartsEquip", transform.position);

        while (elapsedTime <= finish2Time)
        {
            yield return(new WaitForSeconds(0.01f));

            elapsedTime       += Time.deltaTime;
            moveSpeed         += 0.3f;
            transform.position = Vector3.MoveTowards(transform.position, currentGun.m_gunPartPos.position, Time.deltaTime * moveSpeed);
            if (transform.position == currentGun.m_gunPartPos.position)
            {
                break;
            }
        }

        //if (UserType.Host != GameData.Instance.UserType)
        //{
        //    if (GameData.Instance.Player.m_id == GetPlayer.m_id)
        //    {
        //        Network.Instance.SendTCP("item packet", GetGunPartsStartData());
        //    }
        //}
        float partDuration = 20f;

        if (GetPlayer.IsDead)
        {
            partDuration = 0.01f;
        }

        switch (m_gunPartsType)
        {
        case GunPartsType.None:
            break;

        case GunPartsType.LaserParts:
            currentGun.m_laserPart.gameObject.SetActive(true);
            currentGun.m_laserPart.Init(GetPlayer, partDuration);
            break;

        case GunPartsType.FireParts:
            currentGun.m_firePart.gameObject.SetActive(true);
            currentGun.m_firePart.Init(GetPlayer, partDuration);
            break;

        case GunPartsType.GrenadeParts:
            currentGun.m_grenadePart.gameObject.SetActive(true);
            currentGun.m_grenadePart.Init(GetPlayer, partDuration);
            break;
        }

        currentGun.DissolveStart();

        //Effect attachSound = AssetManager.Effect.Retrieve("DirectionSound_PartsEquip", currentGun.m_gunPartPos.position);

        //attachSound.GetComponent<AudioSource>().time = 2.0f;

        Restore();
    }
Esempio n. 2
0
    public void ProcessDirectionPacketData(JObject packetData)
    {
        ItemState itemState = (ItemState)packetData.Value <int>("type");
        int       itemID    = packetData.Value <int>("id");
        Item      item      = FindItemByID(itemID);

        string   PartsGetplayer = packetData.Value <string>("playerid");
        KGPlayer GetPlayer      = PlayerManager.Instance.FindPlayerByID(PartsGetplayer) as KGPlayer;

        switch (itemState)
        {
        case ItemState.Spwan:
            string itemName = packetData.Value <string>("name");

            if (GetPlayer == null)     //파츠가 아닐때
            {
                if (item != null)
                {
                    return;
                }
            }
            else     //파츠일때만 겟플레이어가 있음. 플레이어 아이디가 같으면 리턴
            {
                if (GameData.Instance.UserType == UserType.User)
                {
                    if (GetPlayer.m_id == GameData.Instance.Player.m_id)
                    {
                        return;
                    }
                }
            }

            if (GameData.Instance.UserType == UserType.Host && itemName != "GunParts")
            {
                return;
            }

            ItemType itemType = (ItemType)packetData.Value <int>("itemtype");

            if (ItemType.Heal == itemType)
            {
                float hp = packetData.Value <float>("heal");
                item = AssetManager.Items.Retrieve(itemName, hp) as Item;
            }
            else if (ItemType.GunParts == itemType && GetPlayer != null)
            {
                GunPartsType type = (GunPartsType)packetData.Value <int>("gunpartsType");
                item = AssetManager.Items.Retrieve(itemName, GetPlayer, type) as Item;
            }
            else
            {
                item = AssetManager.Items.Retrieve(itemName) as Item;
            }

            item.m_itemID = itemID;
            item.SetItemTransformFromPacket(packetData);

            break;

        case ItemState.Restore:
            if (null == item)
            {
                return;
            }
            item.Restore();
            break;

        case ItemState.GunPartsSet:

            GunPartsType partsType = (GunPartsType)packetData.Value <int>("parts");
            //GunPartsType partsType = packetData.Value<int>("")

            Rifle rifle = GetPlayer.CurrentWeapon as Rifle;

            switch (partsType)
            {
            case GunPartsType.None:
                break;

            case GunPartsType.LaserParts:
                rifle.m_laserPart.gameObject.SetActive(true);
                rifle.m_laserPart.Init(GetPlayer, 20f);
                break;

            case GunPartsType.FireParts:
                rifle.m_firePart.gameObject.SetActive(true);
                rifle.m_firePart.Init(GetPlayer, 20f);
                break;

            case GunPartsType.GrenadeParts:
                rifle.m_grenadePart.gameObject.SetActive(true);
                rifle.m_grenadePart.Init(GetPlayer, 20f);
                break;
            }

            rifle.DissolveStart();
            break;
        }
    }