コード例 #1
0
    public override void VisualiseAim(Transform userTransform, Vector3 endPoint)
    {
        if (aimCursor == null)
        {
            aimCursor = Instantiate(cursor);
            aimCursor.SetActive(false);
        }

        //Turn user to face target.
        Vector3 dir      = new Vector3(endPoint.x, userTransform.position.y, endPoint.z) - userTransform.position;
        Vector3 rotation = Vector3.RotateTowards(userTransform.transform.forward, dir, 360, 0f);

        userTransform.transform.rotation = Quaternion.LookRotation(rotation);

        aimCursor.SetActive(true);
        aimCursor.transform.position = endPoint;

        //Determine how long the launch would take.
        Vector3 instantationPoint = ItemThrower.CalculateInstantiationPoint(userTransform, instantiationDistanceFromPlayer);

        Calculations.LaunchData launch = Calculations.DetermineRequiredLaunchToReachPoint(instantationPoint, endPoint, 1);

        //Determine points along path and drawn them.
        //Vector3[] arc = new Vector3[arcVisualisationResolution];
        //for (int i = 0; i < arcVisualisationResolution; i++)
        //   arc[i] = instantationPoint + Calculations.DetermineDisplacementAlongLaunchArc(launch.launchVelocity, launch.travelTime / (arcVisualisationResolution * 1f));
        //arcVisuliser.VisualisePath(arc);
    }
コード例 #2
0
        protected override void Awake()
        {
            base.Awake();

            // Debug.Log(itemSlotUI);
            // Debug.Log(itemSlotUI.ReferencedSlotItem);
            ((InventorySlotUI)itemSlotUI).LogItemSlot();

            itemThrower = new ItemThrower((InventorySlotUI)itemSlotUI);
        }
コード例 #3
0
    public override void Fire(Transform userTransform, Vector3 endpoint)
    {
        //Find the point the given distance infront of the player and intantiate the item there.
        Vector3   instantationPoint = ItemThrower.CalculateInstantiationPoint(userTransform, instantiationDistanceFromPlayer);
        Rigidbody instance          = Instantiate(item, instantationPoint, userTransform.rotation);

        //Apply the required velocity to the instance so that it lands on the end point.
        instance.velocity = Calculations.DetermineRequiredLaunchToReachPoint(instantationPoint, endpoint, 1).launchVelocity;

        aimCursor.SetActive(false);
        //arcVisuliser.HidePath();
    }
コード例 #4
0
    public override void Use(Transform userTranform, Inventory inventory)
    {
        Vector3 instantationPoint = ItemThrower.CalculateInstantiationPoint(userTranform, instantiationDistanceFromPlayer);

        Instantiate(droppedItem, new Vector3(instantationPoint.x, userTranform.position.y + dropFromHeight, instantationPoint.z), userTranform.rotation);
    }