Example #1
0
 public void Update(UpdateContext context)
 {
     if (CPlayer.instance != null)
     {
         this._battle.GetChampionsNearby(CPlayer.instance, TargetType.Teamate,
                                         ( float )this._battle.FOWDistanceToPlayer, MAX_PLAYER_IN_FOW,
                                         ref this._tmpEntities);
         int count = this._tmpEntities.Count;
         for (int i = 0; i < count; i++)
         {
             CChampion champion  = this._tmpEntities[i];
             Vector3   screenPos = this._battle.camera.WorldToScreenPoint(champion.position);
             Ray       ray       = this._battle.camera.ScreenPointToRay(screenPos);
             Physics.Raycast(ray, out RaycastHit hit, 999, 1 << 8);
             this._tmpPos[i] = hit.point;
             this._tmpFov[i] = ( float )champion.fov;
         }
         this._FOWPlaneMat.SetInt("_NumPlayers", count);
         this._FOWPlaneMat.SetVectorArray("_PlayerPositions", this._tmpPos);
         this._FOWPlaneMat.SetFloatArray("_PlayerFovs", this._tmpFov);
         this._FOWPlaneMat.SetFloat("_FogRadius", ( float )CPlayer.instance.fov);
         this._tmpEntities.Clear();
     }
     if (this._bright)
     {
         Color color = this._FOWPlaneMat.GetColor("_Color");
         color = Color.Lerp(color, new Color(0, 0, 0, 0), ( float )context.deltaTime * 0.4f);
         this._FOWPlaneMat.SetColor("_Color", color);
     }
 }
Example #2
0
        public static void ItemUsed(CChampion target, bool result)
        {
            UIEvent e = Get();

            e.type   = UIEventType.ITEM_USED;
            e.target = target;
            e.b0     = result;
            e.Invoke();
        }
Example #3
0
        public static void PickItem(CChampion target, string itemId)
        {
            UIEvent e = Get();

            e.type   = UIEventType.PICK_ITEM;
            e.target = target;
            e.itemId = itemId;
            e.Invoke();
        }
Example #4
0
        private void InternalCreate(CChampion entity)
        {
            HUD hud = PopHUD();

            hud.owner   = entity;
            hud.visible = entity.graphic.visible;
            this._idToHud[entity.rid] = hud;
            this.root.AddChild(hud.root);
            this.root.AddChild(hud.arrow);
            hud.arrow.visible = false;
            hud.Update();
        }
Example #5
0
        private void UpdateTeammatePosition()
        {
            if (CPlayer.instance == null)
            {
                return;
            }
            Vector2 p0    = this._idToHud[CPlayer.instance.rid].root.position;
            float   sizeX = this.root.size.x;
            float   sizeY = this.root.size.y;

            foreach (KeyValuePair <string, HUD> kv in this._idToHud)
            {
                HUD       hud    = kv.Value;
                CChampion entity = hud.owner;
                if (entity == CPlayer.instance || entity.team != CPlayer.instance.team)
                {
                    continue;
                }
                Vector2 p1 = hud.position;
                if (p1.x >= 0 && p1.y >= 0 && p1.x <= sizeX && p1.y <= sizeY)
                {
                    hud.arrow.visible = false;
                    continue;
                }
                hud.arrow.visible = true;
                Vector2 dir   = (p1 - p0).normalized;
                float   angle = Mathf.Rad2Deg * Mathf.Acos(Vector2.Dot(dir, Vector2.right));
                if (dir.y < 0)
                {
                    angle = -angle;
                }
                hud.arrow.rotation = angle;
                Vector2 cross1 = dir.x > 0
                                                                         ? new Vector2(sizeX, (sizeX - p0.x) * (p1.y - p0.y) / (p1.x - p0.x) + p0.y)
                                                                         : new Vector2(0, (0 - p0.x) * (p1.y - p0.y) / (p1.x - p0.x) + p0.y);
                Vector2 cross2 = dir.y > 0
                                                                         ? new Vector2((sizeY - p0.y) * (p1.x - p0.x) / (p1.y - p0.y) + p0.x, sizeY)
                                                                         : new Vector2((0 - p0.y) * (p1.x - p0.x) / (p1.y - p0.y) + p0.x, 0);
                float   d1 = (cross1 - p0).sqrMagnitude;
                float   d2 = (cross2 - p0).sqrMagnitude;
                Vector2 p  = d1 < d2 ? cross1 : cross2;
                Vector2 s  = hud.arrow.size * 0.5f;
                if (p.x > sizeX - s.x)
                {
                    p.x = sizeX - s.x;
                }
                else if (p.x < s.x)
                {
                    p.x = s.x;
                }
                if (p.y > sizeY - s.y)
                {
                    p.y = sizeY - s.y;
                }
                else if (p.y < s.y)
                {
                    p.y = s.y;
                }
                hud.arrow.position = p;
            }
        }