Exemplo n.º 1
0
    protected void onENTITY_SHOW_HERO(System.Object objEvent)
    {
        U3D_Render.Utility.SEntityShowHero pEvent = (U3D_Render.Utility.SEntityShowHero)objEvent;
        if (pEvent.ev == null)
        {
            return;
        }

        GFxMinimapManager.Instance.SetObjectVisible(pEvent.ev.ID, pEvent.ev.createinfo.nMinimapIcon, pEvent.bIsHide ? 0 : 1);
    }
Exemplo n.º 2
0
    // 判断是否有障碍物,  true隐藏,  false代表显示
    public void CheckEntityOcclusions()
    {
        foreach (U3D_Render.EntityView ev in this.listEntity)
        {
            if (ev == null || ev.gameObject == null)
            {
                continue;
            }

            if (ev.StateMachine.GetState() == GameLogic.EntityState.Dead)
            {
                continue;
            }

            if (ev.Type != ENTITY_TYPE.TYPE_PLAYER_ROLE)
            {
                continue;
            }

            bool bInDarkCorner = false;
            int  nMask         = ev.Property.GetNumProp(ENTITY_PROPERTY.PROPERTY_MASK);
            if ((nMask & (int)ENTITY_MASKFLAG.MASKFLAG_DISABLE_MINIMAP_SIGHT_CHECK) == 0)
            {
                Vector3 VecSourcePos = ev.gameObject.transform.position;
                VecSourcePos.y += 1;

                IList <U3D_Render.EntityView> EnemyAroundEntity = MapFinderManager.Nearest(ev.StateMachine.transform.position, ev.Sight, SPELL.CampFlag.CampFlag_Self);

                if (EnemyAroundEntity == null)
                {
                    return;
                }

                Vector3    VecTargetPos, RaycastDir;
                float      RaycastDistance;
                RaycastHit raycastHitInfo;
                LayerMask  raycastLayer = (1 << (LayerMask.NameToLayer(Config.LayerDefault)) | (1 << LayerMask.NameToLayer(Config.LayerBuilding)));

                int nCount = 0;
                foreach (U3D_Render.EntityView Enemy_Ev in EnemyAroundEntity)
                {
                    if (Enemy_Ev.gameObject == null)
                    {
                        return;
                    }
                    VecTargetPos    = Enemy_Ev.gameObject.transform.position;
                    VecTargetPos.y += 1;

                    RaycastDir = (VecTargetPos - VecSourcePos).normalized;
                    float tmpDis   = (VecTargetPos - VecSourcePos).magnitude;
                    float tmpSight = ev.Sight;
                    RaycastDistance = tmpDis > tmpSight ? tmpSight : tmpDis;
                    Debug.DrawLine(VecSourcePos, VecSourcePos + RaycastDir * RaycastDistance, Color.blue);
                    Ray ray = new Ray(VecSourcePos, RaycastDir);
                    if (Physics.Raycast(ray, out raycastHitInfo, RaycastDistance, raycastLayer) == false)
                    {
                        break;
                    }
                    nCount++;
                }


                if (nCount == EnemyAroundEntity.Count())
                {
                    bInDarkCorner = true;
                }
            }

            // 变化了才发出事件
            if (bInDarkCorner != ev.m_bInDarkCorner)
            {
                ev.m_bInDarkCorner = bInDarkCorner;

                U3D_Render.Utility.SEntityShowHero event_data = new U3D_Render.Utility.SEntityShowHero();
                event_data.ev      = ev;
                event_data.bIsHide = bInDarkCorner;
                if (event_data.ev != null)
                {
                    U3D_Render.Utility.EventManager.FireExecute(U3D_Render.Utility.EVENT.ENTITY_SHOW_HERO, ev.ID, event_data);
                }
            }
        }
    }