private void Start()
    {
        EffectCanvas.Instance.TitleText("Press [H] for info. about game");

        // Set position start of game
        if (!m_startGamePosition)
        {
            return;
        }

        m_player.transform.position = m_startGamePosition.position;
        m_player.transform.rotation = m_startGamePosition.rotation;

        // Set gun start of game
        m_player.ActiveGun(false);
        m_gunTable.PlaceGun();
    }
Example #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);
         *      }
         *  }
         * }*/
    }