Example #1
0
        /// <summary>
        /// Handle mouse hover
        /// </summary>
        private void HandleMouseHover()
        {
            RaycastHit hit;
            Ray        ray    = m_Camera.ScreenPointToRay(Input.mousePosition);
            Entity     entity = null;

            if (Physics.Raycast(ray, out hit) && (hit.transform.tag == "Player" || hit.transform.tag == "Entity"))
            {
                entity = hit.transform.GetComponent <Entity>();
                if (entity == this)
                {
                    entity = null;
                }
            }
            MessageSystem.SetEntityInfoData(entity);
        }
Example #2
0
        private void Update()
        {
            if (isLocalPlayer)
            {
                HandleInput();

                if (target != null)
                {
                    if (localCooldown <= 0 && Vector3.Distance(target.transform.position, transform.position) <= usedWeapon.attackRange)
                    {
                        Attack(target);
                    }

                    MessageSystem.SetEntityInfoData(target);
                }
                else
                {
                    HandleMouseHover();
                }

                // ATTACKING
                if (localCooldown > 0)
                {
                    localCooldown -= Time.deltaTime;
                }

                // ANIMATION
                bool nIsSprinting = isRunning && Input.GetKey(KeyCode.LeftShift);
                bool nIsWalking   = isRunning && Input.GetKey(KeyCode.LeftControl);
                if (nIsSprinting != isSprinting || nIsWalking != isWalking)
                {
                    CmdSetInput(nIsSprinting, nIsWalking);
                }

                // MOVEMENT
                if (movementClickCooldown > 0)
                {
                    movementClickCooldown -= Time.deltaTime;
                }

                UIStatsPanel.SetHealthbarValue(Health, maxHealth);
            }

            agent.speed = Speed;
        }