Exemplo n.º 1
0
        /// <summary>
        /// Check for movement.
        /// </summary>
        protected override void Update()
        {
            base.Update();

            if (Vector3.Distance(transform.position, lastMovement) > checkDistance)
            {
                lastMovement = transform.position;

                UNTarget.CheckTargets(this, seekingDistance);
            }

            if (attackTrees && detectTreeInstancesInteraction && playerCamera != null && Input.GetMouseButtonDown(0))
            {
                Ray        ray = playerCamera.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0));
                RaycastHit hit;

                if (Physics.Raycast(ray, out hit, 10))
                {
                    if (hit.transform.GetComponentInParent <uNature.Core.Pooling.IHarvestableItem>() != null)
                    {
                        hit.transform.GetComponentInParent <uNature.Core.Pooling.IHarvestableItem>().Hit(20);
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Called on start, initiate initial check targets.
        /// </summary>
        public virtual IEnumerator Start()
        {
            lastMovement = transform.position;

            yield return(new WaitForSeconds(0.1f));

            if (!Application.isPlaying)
            {
                yield break;
            }

            lastMovement = transform.position;
            UNTarget.CheckTargets(this, seekingDistance);
        }