示例#1
0
    public void Use(ItemHand ih)
    {
        RaycastHit hit = new RaycastHit();
        Ray        ray = new Ray(playerCam.transform.position, playerCam.transform.forward);

        if (Physics.Raycast(ray, out hit, useRange))
        {
            if (hit.transform.tag == "Stove")
            {
                Transform tmpPos = hit.transform.Find("PotLocation");
                if (tmpPos.childCount > 0)
                {
                    GameObject oldPot = tmpPos.GetChild(0).gameObject;
                    Destroy(oldPot);
                    inventory.replaceHoldableItem(ih.getSelectedItem(), emptyBucket);

                    GameObject tmpPot = Instantiate(filledPlacedPot, tmpPos);
                    tmpPot.name = filledPlacedPot.name;
                }
            }
            else if (hit.transform.name == "potEmtyPickUpeble")
            {
                Transform tmpPos;
                if (hit.transform.parent.name == "PotLocation")
                {
                    tmpPos = hit.transform.parent;
                    Destroy(hit.transform.gameObject);
                    inventory.replaceHoldableItem(ih.getSelectedItem(), emptyBucket);

                    GameObject tmpPot = Instantiate(filledPlacedPot, tmpPos);
                    tmpPot.name = filledPlacedPot.name;
                }
            }
        }
    }
示例#2
0
    public void Use(ItemHand ih)
    {
        RaycastHit hit = new RaycastHit();
        Ray        ray = new Ray(playerCam.transform.position, playerCam.transform.forward);

        if (Physics.Raycast(ray, out hit, useRange))
        {
            if (hit.transform.tag == "Terrain")
            {
                //Fill With Snow;
                //Exchange Object
                print("Fill With Snow");

                //inventory.removeHoldableItem(ih.getSelectedItem());
                inventory.replaceHoldableItem(ih.getSelectedItem(), filledHoldeblePot);
                //inventory.addItem(filledHoldeblePot);
                Destroy(gameObject);
                //ih.IncrementSelectedItem();
            }
            else
            {
                print("Aint allowed to take snow from this Item");
            }
        }
    }
示例#3
0
    public void Use(ItemHand ih)
    {
        RaycastHit hit = new RaycastHit();
        Ray        ray = new Ray(playerCam.transform.position, playerCam.transform.forward);

        if (Physics.Raycast(ray, out hit, useRange, layerMask))
        {
            print(hit.transform.gameObject);
            if (hit.transform.name == locationName)
            {
                GameObject placedTrap = Instantiate(trapToPlace, hit.point, Quaternion.identity);
                Destroy(hit.transform.gameObject);
                inventory.removeHoldableItem(ih.getSelectedItem());
                Destroy(gameObject);
                Vector3 rotation = new Vector3(0f, playerCam.transform.rotation.eulerAngles.y + rotationDegrees, 0f);
                placedTrap.transform.Rotate(rotation);
            }
            else
            {
                Debug.Log(hit.transform.gameObject);
                //  print("Aint allowed to put trap here");
            }
        }
        else
        {
            //   print("Aint allowed to put trap here");
        }
    }
示例#4
0
 private void Update()
 {
     if (activated)
     {
         if (charMove != null)
         {
             if (!charMove.GetForcedMove())
             {
                 AxeSwing axeSwing = activeItem.GetComponent <AxeSwing>();
                 if (axeSwing != null)
                 {
                     // Play animation here
                     ItemHand itemHand = Camera.main.GetComponentInChildren <ItemHand>();
                     if (itemHand != null && chopFinished)
                     {
                         axeSwing.Use(itemHand);
                         chopFinished = false;
                     }
                     if (!chopFinished)
                     {
                         if (!axeSwing.IsChopping)
                         {
                             chopFinished = true;
                         }
                     }
                     if (chopFinished)
                     {
                         activated = false;
                         charMove.CutsceneRelease();
                         hitPoints--;
                         if (hitPoints <= 0)
                         {
                             // Tree dying stuff goes here
                             for (int i = 0; i < firewoodAmount; i++)
                             {
                                 Instantiate(firewood, transform.position + new Vector3(0, 0.2f + (0.5f * i), 0), Quaternion.LookRotation(Vector3.up));
                             }
                             gameObject.SetActive(false);
                         }
                     }
                 }
                 else
                 {
                     Debug.Log("axeSwing is null");
                 }
             }
         }
         else
         {
             Debug.Log("charMove is null");
         }
     }
 }
示例#5
0
    public void Use(ItemHand ih)
    {
        inventory = Inventory.instance;
        //Debug.Log(ih.ActiveItem);
        Vector3 throwDirection = Camera.main.transform.forward;

        rb.isKinematic = false;
        rb.AddForce(throwDirection * throwForce, ForceMode.Impulse);
        rb.AddRelativeTorque((new Vector3(0f, -1f, 0f)) * 10000);
        rb.collisionDetectionMode = CollisionDetectionMode.Continuous;
        rb.transform.GetComponent <Collider>().enabled = true;
        rb.gameObject.layer = 0;
        transform.parent    = null;
        inventory.removeHoldableItem(ih.getSelectedItem());
        GameObject.FindGameObjectWithTag("Dog").GetComponent <Dog> ().Fetch(transform);
        //ih.ActiveItem = null;
    }
示例#6
0
 public void AxeInteract()
 {
     playerObj = GameObject.FindWithTag("Player");
     if (playerObj != null)
     {
         charMove = playerObj.GetComponent <CharacterMovement>();
     }
     if (charMove != null)
     {
         ItemHand itemHand = Camera.main.GetComponentInChildren <ItemHand>();
         if (itemHand != null)
         {
             activeItem = itemHand.ActiveItem;
         }
         if (activeItem != null)
         {
             if (activeItem.tag == "Axe")
             {
                 activated = true;
                 float   hAngle;
                 Vector2 deltaVector = new Vector2(transform.position.x - playerObj.transform.position.x, transform.position.z - playerObj.transform.position.z);
                 hAngle  = Mathf.Atan2(deltaVector.x, deltaVector.y);
                 hAngle *= 360;
                 hAngle /= Mathf.PI * 2;
                 hAngle += 1.8f;
                 while (hAngle < 0)
                 {
                     hAngle += 360;
                 }
                 while (hAngle >= 360)
                 {
                     hAngle -= 360;
                 }
                 Vector2 targetLook      = new Vector2(hAngle, 0f);
                 Vector3 cuttingposition = new Vector3(-deltaVector.x, 0, -deltaVector.y);
                 cuttingposition.Normalize();
                 charMove.ForceMovement(transform.position + new Vector3(cuttingposition.x * cuttingDistance, charMove.transform.position.y - transform.position.y,
                                                                         cuttingposition.z * cuttingDistance), targetLook, false);
             }
         }
     }
 }
示例#7
0
 void Start()
 {
     if (player == null)
     {
         player = GameObject.FindGameObjectWithTag("Player").transform;
     }
     if (itemBone == null)
     {
         itemBone = transform;
     }
     if (terrain == null)
     {
         terrain = Terrain.activeTerrain;
     }
     ai                = GetComponent <DogAI>();
     animator          = GetComponent <Animator>();
     navAgent          = GetComponent <NavMeshAgent> ();
     itemHand          = player.GetComponentInChildren <ItemHand> ();
     characterMovement = player.GetComponent <CharacterMovement> ();
 }
示例#8
0
    public void Use(ItemHand ih)
    {
        RaycastHit hit = new RaycastHit();
        Ray        ray = new Ray(playerCam.transform.position, playerCam.transform.forward);

        if (Physics.Raycast(ray, out hit, useRange))
        {
            if (hit.transform.tag == "Stove")
            {
                print("Place On Stove");
                Transform  tmpPos = hit.transform.Find("PotLocation");
                GameObject tmpPot = Instantiate(filledPlacedPot, tmpPos);
                tmpPot.name = filledPlacedPot.name;
                inventory.removeHoldableItem(ih.getSelectedItem());
                Destroy(gameObject);
            }
            else
            {
                print("Aint allowed to Place Item Here");
            }
        }
    }
示例#9
0
 public void Use(ItemHand ih)
 {
     SwingAxe();
 }