コード例 #1
0
    public bool UseSpell(SpellCaster sc)
    {
        if (actor.unit && !actor.unit.isAlive)
        {
            // error = "can't attack when you're dead... noob";
            return(false);
        }
        RaycastHit hit = PlayerEntityController.GetClickedRaycast();

        sc.actorTarget = hit.transform.GetComponent <Actor>();
        sc.pointTarget = hit.point;
        string error;

        return(sc.TryCast(out error));
    }
コード例 #2
0
ファイル: AngelDash.cs プロジェクト: amasson42/Unity_rush01
 // Update is called once per frame
 void Update()
 {
     if (timer < 1.0f && !dashing)
     {
         // jumping in the air
         caster.transform.position += new Vector3(0, 100.0f * Time.deltaTime, 0);
         timer += Time.deltaTime;
     }
     else if (!dashing)
     {
         // looking for a ground target
         sight.SetActive(true);
         PlayerEntityController.instance.followCamera.verticalAngle   += Input.GetAxis("Mouse X");
         PlayerEntityController.instance.followCamera.horizontalAngle -= Input.GetAxis("Mouse Y");
         var hit = PlayerEntityController.GetClickedRaycast();
         caster.transform.LookAt(hit.point);
         if (hit.collider)
         {
             if (Input.GetMouseButtonDown(0))
             {
                 timer = 0;
                 sight.SetActive(false);
                 dashing            = true;
                 pointTarget        = hit.point;
                 transform.position = caster.transform.position;
                 totalDistance      = Vector3.Distance(transform.position, pointTarget);
                 PlayerEntityController.instance.followCamera.offset = Vector3.zero;
             }
         }
     }
     else
     {
         timer += Time.deltaTime;
         caster.transform.position = Vector3.MoveTowards(transform.position, pointTarget, timer * totalDistance);
         // dashing to the ground
         if (timer >= 1.0f)
         {
             caster.ReleaseMove();
             Cursor.lockState = CursorLockMode.None;
             PlayerEntityController.instance.followCamera.verticalAngle   = savedVerticalAngle;
             PlayerEntityController.instance.followCamera.horizontalAngle = savedHorizontalAngle;
             caster.agent.enabled   = true;
             casterCollider.enabled = true;
             Destroy(gameObject);
         }
     }
 }
コード例 #3
0
ファイル: HoverUi.cs プロジェクト: amasson42/Unity_rush01
    void Update()
    {
        RaycastHit hit = PlayerEntityController.GetClickedRaycast();

        if (hit.collider && hit.collider.gameObject.layer != LayerMask.NameToLayer("World") &&
            !MenuManager.OnInterface())
        {
            hover = hit.collider.GetComponent <Actor>();
            if (hover)
            {
                canvas.enabled = false;
            }
            ShowItemInfo(hit.collider.GetComponent <ItemEntity>());
            highlightNode.transform.position = hit.transform.position;
            highlightNode.SetActive(true);
        }
        else
        {
            highlightNode.SetActive(false);
            canvas.enabled = false;
        }
    }