Ejemplo n.º 1
0
    /// <summary>
    /// Checks for the trigger to being fired and fires the spell
    /// otherwise we show the aim
    /// </summary>
    /// <param name="deltaTime"></param>
    internal void Update(float deltaTime)
    {
        if (currentSpellDefinition == null)
        {
            return;
        }

        if (deviceInput.MouseButtonHeldDown())
        {
            currentSpellDefinition.SetOnCooldown();
            UISpellButtonWrapper.instance.SendMessage(currentSpellDefinition, InGameWrapper.instance.playersWrapper.GetOnlyLocalPlayer().GetGmj().transform.position);
            currentSpellDefinition = null;
            aimGmj.SetActive(false);
        }
        else
        {
            if (EventSystemReference.instance.EventSystem.IsPointerOverGameObject())
            {
                return;
            }
            if (deviceInput.PositionUpdated())
            {
                RaycastHit hit      = new RaycastHit();
                Ray        mouseRay = InGameWrapper.instance.camera.ScreenPointToRay(deviceInput.GetMousePosition());
                if (Physics.Raycast(mouseRay, out hit, 100f, aimData.groundMask))
                {
                    aimGmj.transform.position = hit.point;
                    var player = InGameWrapper.instance.playersWrapper.GetOnlyLocalPlayer().GetGmj().transform;
                    aimGmj.transform.LookAt(player.transform);
                    aimGmj.transform.rotation = Quaternion.Euler(0, aimGmj.transform.eulerAngles.y, 0);
                }
            }
        }
    }
 /// <summary>
 /// Checks input for a change in target position
 /// </summary>
 private void CheckMovementInput()
 {
     if (spellCaster.IsCasting() || InGameWrapper.instance.aimWrapper.IsAiming())
     {
         return;
     }
     if (deviceInput.MouseButtonHeldDown())
     {
         if (EventSystemReference.instance.EventSystem.IsPointerOverGameObject(deviceInput.GetMousePointerId()))
         {
             return;
         }
         RaycastHit hit      = new RaycastHit();
         Ray        mouseRay = InGameWrapper.instance.camera.ScreenPointToRay(Input.mousePosition);
         if (Physics.Raycast(mouseRay, out hit, 100f, generalPlayerData.groundMask))
         {
             Debug.DrawLine(playerGmj.transform.position, hit.point);
             var newTargetPos = new Vector3(hit.point.x, playerGmj.transform.position.y, hit.point.z);
             if (newTargetPos == targetPos)
             {
                 return;
             }
             InGameWrapper.instance.cursorWrapper.SetPosition(newTargetPos);
             SetTargetPos(new Vector3(hit.point.x, StaticVariables.GetYPos(), hit.point.z));
         }
     }
 }