Exemplo n.º 1
0
    public void Hold(Transform _tr)
    {
        if (m_holdItem != null)
        {
            Drop();
        }

        Rabboid rab = _tr.GetComponent <Rabboid>();

        m_holdItem = _tr;
        m_holdItem.transform.position = transform.position;
        if (rab)
        {
            m_holdItem.position += transform.forward * rab.RabboidStats.m_size * 0.3f;
        }
        m_holdItem.GetComponent <Rigidbody>().isKinematic = true;
        m_holdItem.parent   = transform;
        m_holdItem.rotation = Quaternion.Euler(0, transform.rotation.eulerAngles.y, 0);
        if (rab)
        {
            m_gotRabboid = true;
            m_holdItem.GetComponentInChildren <MeshCollider>().enabled = false;
        }
    }
Exemplo n.º 2
0
    void Grab()
    {
        bool tryingToPutRabbitinCage = false;

        if (m_hitTarget)
        {
            BunnyPen bpen = m_hitTarget.GetComponent <BunnyPen>();
            if (m_holdHand.IsHolding() && bpen == null)
            {
                m_holdHand.Drop();
                return;
            }
            tryingToPutRabbitinCage = true;
        }

        if (!tryingToPutRabbitinCage && m_holdHand.IsHolding())
        {
            m_holdHand.Drop();
            return;
        }

        if (!m_hitTarget)
        {
            return;
        }

        GunTable table = m_hitTarget.GetComponent <GunTable>();

        if (table != null)
        {
            Debug.Log("table found");
            if (m_playerControl.IsGunActive())
            {//gun is active //place gun
                m_playerControl.ActiveGun(false);
                table.PlaceGun();
            }
            else
            {//gun is not active // take gun
                m_playerControl.ActiveGun(true);
                table.TakeGun();
            }
        }

        BunnyPen pen = m_hitTarget.GetComponent <BunnyPen>();

        if (pen != null)
        {
            RabboidResult rabboidResult = new RabboidResult();

            if (pen.m_penData.m_bunnyInside && m_holdHand.IsHolding())
            {
                return;
            }
            else if (!pen.m_penData.m_bunnyInside && !m_holdHand.IsHolding())
            {
                return;
            }

            if (m_holdHand.IsHoldingBunny())
            {
                // Put the rabbit in the cage in the players hand
                rabboidResult = m_holdHand.GetBunnyData();
                pen.PlayerInteract(true, rabboidResult);
                m_holdHand.DestroyItem();
            }
            else
            {
                // Pick up the caged rabbit
                Transform bunny = pen.GetRabboid();
                pen.PlayerInteract(false, rabboidResult);
                m_holdHand.Hold(bunny.transform);
            }
        }

        Rabboid rab = m_hitTarget.GetComponent <Rabboid>();

        if (rab != null && !rab.m_insidePen)
        {
            m_holdHand.Hold(rab.transform);
            return;
        }

        PickUp pickUp = m_hitTarget.GetComponent <PickUp>();

        if (pickUp != null)
        {
            if (m_inventory.AddToInventory(pickUp))
            {
                //Debug.Log("sphere pickup");
                SoundEffectsPlayer.Instance.PlaySound("PickUp");
                Destroy(pickUp.gameObject);
                return;
            }
        }

        //didnt hit anything//drop holditem

        /*if (Physics.Raycast(rayy, out hit, m_range))
         * {
         *  PickUp pickup = hit.transform.GetComponent<PickUp>();
         *  if(pickup != null)
         *  {
         *      //Debug.Log("pick up " + pickup.name);
         *      if(m_inventory.AddToInventory(pickup))
         *      {
         *         // Debug.Log("added" + pickup.name);
         *          Destroy(pickup.gameObject);
         *      }
         *  }
         * }*/
    }
Exemplo n.º 3
0
    void RaycastCheck()
    {
        RaycastHit hit;
        Ray        rayy = new Ray(transform.position, m_grabCam.transform.forward);

        if (Physics.SphereCast(rayy, 0.5f, out hit, m_range, m_pickupLayer))
        {
            if (m_text)
            {
                m_text.text = "";
            }

            // See if hit bunnycage
            BunnyPen pen = hit.transform.GetComponent <BunnyPen>();
            if (pen != null)
            {
                m_hitTarget = hit.transform;
                if (m_text)
                {
                    if (pen.m_penData.m_bunnyInside)
                    {
                        m_text.text = "Open";
                    }
                    else if (m_holdHand.IsHoldingBunny())
                    {
                        m_text.text = "Close";
                    }
                }
                return;
            }

            // See if hit table
            GunTable table = hit.transform.GetComponent <GunTable>();
            if (table != null)
            {
                if (m_text)
                {
                    m_text.text = "Interact";
                }
            }

            // See if hit rabboid
            Rabboid rab = hit.transform.GetComponent <Rabboid>();
            if (rab != null && !rab.m_insidePen)
            {
                if (m_text)
                {
                    m_text.text = "Grab";
                }
            }

            // See if hit pickup
            PickUp pickUp = hit.transform.GetComponent <PickUp>();
            if (pickUp != null)
            {
                if (m_text)
                {
                    m_text.text = pickUp.m_name;
                }
            }
            m_hitTarget = hit.transform;

            BunnyOrderSlot bunnyOrder = hit.transform.GetComponent <BunnyOrderSlot>();
            if (bunnyOrder != null)
            {
                if (m_text && bunnyOrder.GetIsActive())
                {
                    m_text.text = bunnyOrder.m_interactText;
                }
            }
        }
        else
        {
            m_hitTarget = null;
            if (m_text)
            {
                m_text.text = "";
            }
        }
    }
Exemplo n.º 4
0
    private void OnTriggerEnter(Collider other)
    {
        Transform parent = other.transform.parent;

        if (parent != null)
        {
            Rabboid rabboid = other.transform.parent.GetComponent <Rabboid>();
            if (rabboid != null)
            {
                if (m_customerOrder.m_isActive)
                {
                    RabboidResult RabboidStats = other.transform.parent.GetComponent <Rabboid>().RabboidStats;
                    // Check the order
                    int rabbitScore           = 10; // Score is given based on how close the rabbit is to what the order wanted.
                    int negativePointModifier = 2;
                    int positivePointModifier = 2;

                    // Check Size
                    if (m_customerOrder.m_size == RabboidCalculator.NORMAL_SIZE)
                    {
                        if (RabboidStats.m_size <= RabboidCalculator.SMALL_SIZE)
                        {
                            rabbitScore -= negativePointModifier;
                        }
                        else if (RabboidStats.m_size >= RabboidCalculator.LARGE_SIZE)
                        {
                            rabbitScore -= negativePointModifier;
                        }
                        else
                        {
                            rabbitScore += positivePointModifier;
                        }
                    }
                    else if (m_customerOrder.m_size == RabboidCalculator.SMALL_SIZE)
                    {
                        if (RabboidStats.m_size <= RabboidCalculator.SMALL_SIZE)
                        {
                            rabbitScore += positivePointModifier;
                        }
                        else if (RabboidStats.m_size >= RabboidCalculator.LARGE_SIZE)
                        {
                            rabbitScore -= negativePointModifier * 2;
                        }
                        else
                        {
                            rabbitScore -= negativePointModifier;
                        }
                    }
                    else if (m_customerOrder.m_size == RabboidCalculator.LARGE_SIZE)
                    {
                        if (RabboidStats.m_size >= RabboidCalculator.LARGE_SIZE)
                        {
                            rabbitScore += positivePointModifier;
                        }
                        else if (RabboidStats.m_size <= RabboidCalculator.SMALL_SIZE)
                        {
                            rabbitScore -= negativePointModifier * 2;
                        }
                        else
                        {
                            rabbitScore -= negativePointModifier;
                        }
                    }

                    // Check Color
                    Color resultsColor = Color.white;
                    if (RabboidStats.m_resultColour != null)
                    {
                        resultsColor = RabboidStats.m_resultColour.m_color;
                    }
                    Color customerColor = Color.white;
                    if (m_customerOrder.m_colour != null)
                    {
                        customerColor = m_customerOrder.m_colour.m_color;
                    }
                    if (resultsColor == customerColor)
                    {
                        rabbitScore += positivePointModifier;
                    }
                    else
                    {
                        rabbitScore -= negativePointModifier;
                    }

                    // Check Body
                    if ((RabboidStats.m_backPart == null && m_customerOrder.m_backPart == null) ||
                        (RabboidStats.m_backPart != null && m_customerOrder.m_backPart != null))
                    {
                        rabbitScore += positivePointModifier;
                    }
                    else
                    {
                        rabbitScore -= negativePointModifier;
                    }

                    // Check Head
                    if ((RabboidStats.m_mouthPart == null && m_customerOrder.m_mouthPart == null) ||
                        (RabboidStats.m_mouthPart != null && m_customerOrder.m_mouthPart != null))
                    {
                        rabbitScore += positivePointModifier;
                    }
                    else
                    {
                        rabbitScore -= negativePointModifier;
                    }

                    // Add coins based on performance
                    if (rabbitScore < 0)
                    {
                        rabbitScore = 0;
                    }

                    m_playerInventory.m_money += (uint)rabbitScore;
                    StartCoroutine(UpdateCoinCounter((uint)rabbitScore));

                    // Tidy up
                    //m_customerOrder.m_customer.GetComponent<Customer>().OrderComplete();
                    CancelOrder(false);
                    m_Customer.OrderComplete(rabbitScore);
                    m_bunny = other.transform;
                    DestroyBunny();
                }
            }
        }
    }