Exemplo n.º 1
0
    protected void RcvBoost(E_ItemID gadget)
    {
        if (uLink.Network.isServer == true)
        {
            return;
        }

        Item item = Owner.GadgetsComponent.GetGadget(gadget);

        if (item == null)
        {
            return;
        }

        PlayerPersistantInfo ppi = PPIManager.Instance.GetPPI(Owner.NetworkView.owner);

        if (ppi == null)
        {
            return;
        }

        BoostInfo boost = new BoostInfo()
        {
            Settings     = item.Settings,
            TimeToEnd    = Time.timeSinceLevelLoad + item.Settings.BoostTimer,
            CurrentPower = 1
        };

        if (item.Settings.BoostSoundOn)
        {
            Owner.SoundPlay(item.Settings.BoostSoundOn);
        }

        if (item.Settings.BoostEffect)
        {
            boost.Effect = GameObject.Instantiate(item.Settings.BoostEffect) as ParticleSystem;
            Transform t = boost.Effect.transform;
            t.parent        = Owner.HatTarget;
            t.localPosition = Vector3.zero;
            t.localRotation = Quaternion.identity;

            if (IsBoostActive(E_ItemBoosterBehaviour.Invisible) == false)
            {
                boost.Effect.Play(true);
            }
        }
        else
        {
            boost.Effect = null;
        }

        if (item.Settings.BoosterBehaviour == E_ItemBoosterBehaviour.Invisible)
        {
            //Owner.SetInvisibleOn(item.Settings.BoostModifier);
            boost.CurrentPower = 0.0f;
            Owner.SetInvisibleOn(boost.CurrentPower);

            StopAllCoroutines();
            StartCoroutine(Coroutine_InvisibilityStart(boost, INVISIBLE_BOOST_MODIFIER_DEFAULT));

            SetBoostEffect(false);
        }

        ActiveBoosts.Add(boost);
        ppi.ConsumableItemUsed(gadget);

        item.BoostUsed();
    }