Пример #1
0
 // Update is called once per frame
 void Update()
 {
     if (player)
     {
         if (active && player.GetTargetingSystem().GetTarget())
         {
             Vector3 targpos = player.GetTargetingSystem().GetTarget().position;
             Vector3 viewpos = Camera.main.WorldToViewportPoint(targpos);
             if (viewpos.x > 1 || viewpos.x < 0 || viewpos.y < 0 || viewpos.y > 1)
             {
                 spr.enabled      = true;
                 spr.sortingOrder = player.GetComponent <SpriteRenderer>().sortingOrder;
                 var x = (-player.transform.position + targpos);
                 x.z = 0;
                 float magcheck = Mathf.Max(viewpos.x, 1 - viewpos.x, viewpos.y, 1 - viewpos.y);
                 transform.localScale = new Vector3(1 / magcheck, 1 / magcheck, 1);
                 if (player.IsMoving() || init)
                 {
                     init = false;
                     transform.position = player.transform.position + x.normalized * 10;
                     // TODO: check condition for adding/subbing 90
                     transform.eulerAngles = new Vector3(0, 0, (Mathf.Rad2Deg * Mathf.Atan(x.y / x.x) - (x.x > 0 ? 90 : -90)));
                 }
             }
             else
             {
                 spr.enabled = false;
             }
         }
         else
         {
             spr.enabled = false;
         }
     }
 }
Пример #2
0
    void Update()
    {
        if (playerTargetArrow && player)
        {
            if (player.GetTargetingSystem().GetTarget())
            {
                playerTargetArrow.GetComponent <SpriteRenderer>().enabled =
                    UpdatePosition(playerTargetArrow, player.GetTargetingSystem().GetTarget().position);
            }
            else
            {
                playerTargetArrow.GetComponent <SpriteRenderer>().enabled = false;
            }
        }
        else if (playerTargetArrow)
        {
            playerTargetArrow.GetComponent <SpriteRenderer>().enabled = false;
        }

        foreach (var loc in arrows.Keys)
        {
            UpdatePosition(arrows[loc], loc.location);
        }

        foreach (var core in coreArrows.Keys)
        {
            if (!core)
            {
                coreArrows[core].GetComponent <SpriteRenderer>().enabled = false;
                continue;
            }

            UpdatePosition(coreArrows[core], core.transform.position, core.faction != PlayerCore.Instance.faction);
            if (core.faction != player.faction && coreArrows[core].GetComponent <SpriteRenderer>().enabled)
            {
                coreArrows[core].GetComponent <SpriteRenderer>().enabled = !core.IsInvisible;
            }
        }
    }
Пример #3
0
    public void UpdatePrimaryTargetInfo()
    {
        var targ = player.GetTargetingSystem().GetTarget();

        UpdateInfo(targ ? targ.gameObject : null, targetInfo);
    }