Exemplo n.º 1
0
    private void AddBeverage(Collider other)
    {
        WaterBall waterBall = m_ObjectPool.GetSpecificWaterBall(other);

        if (m_GlasContents.ContainsKey(waterBall.m_Beverage))
        {
            if (m_LastBeverage != waterBall.m_Beverage)
            {
                m_ShotProgress = 0f;
                m_LastBeverage = waterBall.m_Beverage;
            }

            m_ShotProgress += 1.5f * Time.deltaTime;
            if (m_ShotProgress >= 1f)
            {
                //m_Renderer.material = waterBall.GetMaterial();
                m_Renderer.material.SetColor("_TopColor", waterBall.GetMaterial().color);
                m_FillAmount -= 0.050f;
                m_Renderer.material.SetFloat("_FillAmount", m_FillAmount);
                m_GlasContents[waterBall.m_Beverage]++;
                m_ShotProgress = 0f;
                UpdateBeverageUI(waterBall.m_Beverage, m_GlasContents[waterBall.m_Beverage]);
                waterBall.Deactivate();
            }
        }
        else
        {
            m_LastBeverage = waterBall.m_Beverage;
            m_GlasContents.Add(waterBall.m_Beverage, 0);
            CreateNewBeverageUI(waterBall.m_Beverage);
            waterBall.Deactivate();
        }
        m_FillAmount = Mathf.Clamp(m_FillAmount, m_MinFillAmount, m_MaxFillAmount);
    }
Exemplo n.º 2
0
    public void DoThrow(Vector3 pos, Vector3 velocity)
    {
        BasePlayer ownerPlayer = GetOwnerPlayer();

        if (ownerPlayer == null)
        {
            return;
        }
        Item item = GetItem();

        if (item == null || item.contents == null)
        {
            return;
        }
        Item slot = item.contents.GetSlot(0);

        if (slot != null && slot.amount > 0)
        {
            Vector3   vector    = ownerPlayer.eyes.position + ownerPlayer.eyes.BodyForward() * 1f;
            WaterBall waterBall = GameManager.server.CreateEntity(thrownWaterObject.resourcePath, vector, Quaternion.identity) as WaterBall;
            if ((bool)waterBall)
            {
                waterBall.liquidType         = slot.info;
                waterBall.waterAmount        = slot.amount;
                waterBall.transform.position = vector;
                waterBall.SetVelocity(velocity);
                waterBall.Spawn();
            }
            slot.UseItem(slot.amount);
            slot.MarkDirty();
            SendNetworkUpdateImmediate();
        }
    }
    public void DoThrow(Vector3 pos, Vector3 velocity)
    {
        BasePlayer ownerPlayer = this.GetOwnerPlayer();

        if (Object.op_Equality((Object)ownerPlayer, (Object)null))
        {
            return;
        }
        Item obj = this.GetItem();

        if (obj == null || obj.contents == null)
        {
            return;
        }
        Item slot = obj.contents.GetSlot(0);

        if (slot == null || slot.amount <= 0)
        {
            return;
        }
        Vector3   pos1   = Vector3.op_Addition(ownerPlayer.eyes.position, Vector3.op_Multiply(ownerPlayer.eyes.BodyForward(), 1f));
        WaterBall entity = GameManager.server.CreateEntity(this.thrownWaterObject.resourcePath, pos1, Quaternion.get_identity(), true) as WaterBall;

        if (Object.op_Implicit((Object)entity))
        {
            entity.liquidType  = slot.info;
            entity.waterAmount = slot.amount;
            ((Component)entity).get_transform().set_position(pos1);
            entity.SetVelocity(velocity);
            entity.Spawn();
        }
        slot.UseItem(slot.amount);
        slot.MarkDirty();
        this.SendNetworkUpdateImmediate(false);
    }
Exemplo n.º 4
0
    void shoot()
    {
        int dir = 1;

        if (faceDir == false)
        {
            dir = -1;
        }
        WaterBall newBullet = Instantiate(bullet, new Vector3(this.transform.position.x + (dir * xBulletOffset), this.transform.position.y + (yBulletOffset), this.transform.position.z), Quaternion.identity);

        newBullet.setDirs(dir, 0);
    }
Exemplo n.º 5
0
    private void DoSplash(BasePlayer attacker, Vector3 position, Vector3 direction, int amount)
    {
        Item item = GetItem();

        if (item != null && item.contents != null)
        {
            Item slot = item.contents.GetSlot(0);
            if (slot != null && slot.amount > 0 && !(slot.info == null))
            {
                WaterBall.DoSplash(position, SplashRadius, slot.info, amount);
                DamageUtil.RadiusDamage(attacker, LookupPrefab(), position, MinDmgRadius, MaxDmgRadius, Damage, 131072, true);
            }
        }
    }
Exemplo n.º 6
0
    public WaterBall GetWaterBall()
    {
        WaterBall waterball = m_WaterBalls[0];

        for (int i = 0; i < m_WaterBalls.Count; i++)
        {
            if (!m_WaterBalls[i].gameObject.activeInHierarchy)
            {
                waterball = m_WaterBalls[i];
                break;
            }
        }

        return(waterball);
    }
Exemplo n.º 7
0
    public WaterBall GetSpecificWaterBall(Collider wantedWaterBall)
    {
        WaterBall waterball = m_WaterBalls[0];

        for (int i = 0; i < m_WaterBalls.Count; i++)
        {
            if (wantedWaterBall.gameObject.GetInstanceID() == m_WaterBalls[i].GetInstanceID())
            {
                waterball = m_WaterBalls[i];
                break;
            }
        }

        return(waterball);
    }
Exemplo n.º 8
0
 private void AttackCheck()
 {
     if (Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButtonDown(0))
     {
         WaterBall waterBall = GameObject.Instantiate(
             Resources.Load("Prefabs/WaterBall") as GameObject,
             transform.position,
             Quaternion.identity,
             null
             ).GetComponent <WaterBall>();
         //waterBall.transform.position = transform.position;
         //waterBall.transform.forward = transform.forward;
         waterBall.StartCoroutine(waterBall.Launch(0.5f, transform.forward));
     }
 }
Exemplo n.º 9
0
    public void Pour()
    {
        WaterBall waterBall = m_ObjectPool.GetWaterBall();

        waterBall.Activate(m_BottleOpening.position, -transform.up, m_Beverage, m_WaterColor);
    }
Exemplo n.º 10
0
 public void GiveWater(WaterBall waterBall)
 {
     this.waterPower += waterBall.Power;
     IsReady          = true;
 }