Esempio n. 1
0
    public static void BeginLevel()
    {
        FogOfWar.DisableShaderFogFunction();
        if (FogOfWar.enable)
        {
            GC.Collect();
            GameObject gameObject = GameObject.Find("Design/Field");
            if (gameObject != null && gameObject.activeInHierarchy)
            {
                FieldObj component = gameObject.GetComponent <FieldObj>();
                if (component != null)
                {
                    if (!Singleton <WatchController> .get_instance().IsWatching)
                    {
                        FogOfWar.EnableShaderFogFunction();
                    }
                    component.InitField();
                    int inFakeSightRange = 0;
                    component.UnrealToGridX(Horizon.QueryMainActorFakeSightRadius(), out inFakeSightRange);
                    Singleton <GameFowManager> .get_instance().InitSurface(true, component, inFakeSightRange);

                    if (Singleton <GameFowManager> .get_instance().LoadPrecomputeData())
                    {
                        FogOfWar.Reset(component.FieldX, component.FieldY, component.NumX, component.NumY, (int)GameDataMgr.globalInfoDatabin.GetDataByKey(56u).dwConfValue);
                        FogOfWar.ClearAllFog(true);
                        float num  = Mathf.Max((float)component.FieldX / 1000f, 1f);
                        float num2 = Mathf.Max((float)component.FieldY / 1000f, 1f);
                        Shader.SetGlobalVector("_InvSceneSize", new Vector4(1f / num, 1f / num2, num, num2));
                    }
                }
            }
        }
    }
Esempio n. 2
0
    public static void CopyBitmap()
    {
        VInt2    mainActorFakeSightPos = FogOfWar.MainActorFakeSightPos;
        FieldObj pFieldObj             = Singleton <GameFowManager> .get_instance().m_pFieldObj;

        FowLos.PreCopyBitmap(mainActorFakeSightPos.x, mainActorFakeSightPos.y, pFieldObj.NumX, pFieldObj.NumY, Singleton <GamePlayerCenter> .get_instance().GetHostPlayer().PlayerCamp);
        FogOfWar._bitmapData = Singleton <GameFowManager> .get_instance().GetCommitPixels();
    }
Esempio n. 3
0
 public static void CopyBitmap()
 {
     FowLos.PreCopyBitmap();
     if (!Singleton <WatchController> .instance.IsWatching)
     {
         VInt2    mainActorFakeSightPos = FogOfWar.MainActorFakeSightPos;
         FieldObj pFieldObj             = Singleton <GameFowManager> .instance.m_pFieldObj;
         FowLos.PreCopyBitmapFakeSight(mainActorFakeSightPos.x, mainActorFakeSightPos.y, pFieldObj.NumX, pFieldObj.NumY);
     }
     FogOfWar._bitmapData = Singleton <GameFowManager> .instance.GetCommitPixels();
 }
Esempio n. 4
0
    public static void PreBeginLevel()
    {
        GameObject gameObject = GameObject.Find("Design/Field");

        if (gameObject != null && gameObject.activeInHierarchy)
        {
            FieldObj component = gameObject.GetComponent <FieldObj>();
            if (component != null && component.bSynced && component.fowOfflineData != null && component.fowOfflineData.Length > 0 && Singleton <BattleLogic> .get_instance().GetCurLvelContext().m_bEnableFow)
            {
                FogOfWar.enable = true;
            }
        }
    }
Esempio n. 5
0
            private ConditionObj CreateConditionObj <TB>(Func <TB, FieldObj> field, SQLSymbolSign symbol, object value, ConditonModel model)
            {
                TB       obj      = Activator.CreateInstance <TB>();
                FieldObj fieldObj = field(obj);

                fieldObj.FieldValue = value;
                ConditionObj cond = new ConditionObj();

                cond.FieldA = fieldObj;
                cond.Symbol = symbol;
                cond.Model  = model;
                return(cond);
            }
    public bool SaveTo(FieldObj inFieldObj)
    {
        DebugHelper.Assert(inFieldObj != null);
        DebugHelper.Assert(inFieldObj.m_fowCells != null);
        MemoryStream memoryStream = new MemoryStream();
        BinaryWriter binaryWriter = new BinaryWriter(memoryStream);

        binaryWriter.Write(this.VerificationCode);
        binaryWriter.Write(this.Version);
        binaryWriter.Write(this.CrcCode);
        int num = inFieldObj.NumX * inFieldObj.NumY;

        binaryWriter.Write(num);
        for (int i = 0; i < num; i++)
        {
            FOWSurfCell fOWSurfCell = inFieldObj.m_fowCells[i];
            if (fOWSurfCell.bValid)
            {
                int dataSize = fOWSurfCell.GetDataSize();
                binaryWriter.Write(dataSize);
                DebugHelper.Assert(fOWSurfCell.data != null);
                int[] array = new int[fOWSurfCell.data.Length];
                for (int j = 0; j < array.Length; j++)
                {
                    array[j] = (int)fOWSurfCell.data[j];
                }
                byte[] array2 = FOGameFowOfflineSerializer.IntArrToByteArr(array);
                binaryWriter.Write(array2, 0, array2.Length);
            }
            else
            {
                int num2 = 0;
                binaryWriter.Write(num2);
            }
        }
        binaryWriter.Write(987654321);
        binaryWriter.Flush();
        memoryStream.Flush();
        inFieldObj.fowOfflineData = memoryStream.ToArray();
        binaryWriter.Close();
        memoryStream.Close();
        return(true);
    }
Esempio n. 7
0
        public static bool CheckGrassAttaching(ref VInt3 newPos)
        {
            FieldObj pFieldObj = Singleton <GameFowManager> .instance.m_pFieldObj;
            VInt3    vInt      = new VInt3(newPos.x, newPos.z, 0);
            VInt2    zero      = VInt2.zero;

            pFieldObj.LevelGrid.WorldPosToGrid(vInt, out zero.x, out zero.y);
            FieldObj.SViewBlockAttr sViewBlockAttr = default(FieldObj.SViewBlockAttr);
            pFieldObj.QueryAttr(zero, out sViewBlockAttr);
            if (sViewBlockAttr.BlockType == 0 && pFieldObj.FindNearestGrid(zero, vInt, FieldObj.EViewBlockType.Grass, false, 1, null, out zero))
            {
                pFieldObj.LevelGrid.GridToWorldPos(zero.x, zero.y, out vInt);
                int num = MonoSingleton <GlobalConfig> .instance.GrassEyeAbsorbDist;
                num += pFieldObj.PaneX / 2;
                if (vInt.x + num > newPos.x && vInt.x - num < newPos.x && vInt.y + num > newPos.z && vInt.y - num < newPos.z)
                {
                    newPos = new VInt3(vInt.x, newPos.y, vInt.y);
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 8
0
    public bool ExploreCellsFast(VInt3 location, int surfSightRange, GameFowManager pFowMgr, FieldObj inFieldObj, COM_PLAYERCAMP camp, bool bStaticExplore, bool bDistOnly)
    {
        if (pFowMgr == null || inFieldObj == null)
        {
            return(false);
        }
        VInt2 vInt = VInt2.zero;

        pFowMgr.WorldPosToGrid(location, out vInt.x, out vInt.y);
        FieldObj.SViewBlockAttr sViewBlockAttr = default(FieldObj.SViewBlockAttr);
        if (inFieldObj.QueryAttr(vInt, out sViewBlockAttr) && sViewBlockAttr.BlockType == 2)
        {
            VInt2 zero = VInt2.zero;
            if (inFieldObj.FindNearestGrid(vInt, location, FieldObj.EViewBlockType.Brick, true, 3, null, out zero))
            {
                vInt = zero;
            }
        }
        if (bStaticExplore)
        {
            FowLos.TraverseStaticSurCell(surfSightRange, vInt.x, vInt.y, inFieldObj.NumX, inFieldObj.NumY, camp);
        }
        else
        {
            FowLos.TraverseSurCell(surfSightRange, vInt.x, vInt.y, inFieldObj.NumX, inFieldObj.NumY, camp, bDistOnly);
        }
        return(true);
    }
    public bool TryLoad(FieldObj inFieldObj)
    {
        DebugHelper.Assert(inFieldObj != null);
        if (inFieldObj.fowOfflineData == null || inFieldObj.fowOfflineData.Length == 0)
        {
            return(false);
        }
        MemoryStream memoryStream = new MemoryStream(inFieldObj.fowOfflineData);
        BinaryReader binaryReader = new BinaryReader(memoryStream);
        uint         num          = binaryReader.ReadUInt32();
        uint         num2         = binaryReader.ReadUInt32();
        uint         num3         = binaryReader.ReadUInt32();

        if (num != this.VerificationCode || this.Version != num2)
        {
            return(false);
        }
        int num4 = inFieldObj.NumX * inFieldObj.NumY;
        int num5 = binaryReader.ReadInt32();

        if (num4 != num5)
        {
            return(false);
        }
        GameFowManager.InitSurfCellsArray(num4);
        GameFowManager.InitLevelGrid(num4, inFieldObj.LevelGrid.GridInfo.CellNumX, inFieldObj.LevelGrid.GridInfo.CellNumY, inFieldObj.LevelGrid.GridInfo.CellSizeX, inFieldObj.LevelGrid.GridInfo.CellSizeY, inFieldObj.LevelGrid.GridInfo.GridPos.x, inFieldObj.LevelGrid.GridInfo.GridPos.y);
        int num6 = 0;

        inFieldObj.UnrealToGridX(Horizon.QueryGlobalSight(), out num6);
        for (int i = 0; i < num4; i++)
        {
            int gridCellX = inFieldObj.LevelGrid.GetGridCellX(i);
            int gridCellY = inFieldObj.LevelGrid.GetGridCellY(i);
            int xMin      = Mathf.Max(0, gridCellX - num6);
            int xMax      = Mathf.Min(inFieldObj.NumX - 1, gridCellX + num6);
            int yMin      = Mathf.Max(0, gridCellY - num6);
            int yMax      = Mathf.Min(inFieldObj.NumY - 1, gridCellY + num6);
            int num7      = binaryReader.ReadInt32();
            if (num7 > 0)
            {
                byte[] array = new byte[num7];
                binaryReader.Read(array, 0, num7);
                uint[] array2 = FOGameFowOfflineSerializer.ByteArrToUIntArr(array);
                DebugHelper.Assert(array2.Length == num7 / 4);
                GameFowManager.InitSurfCell(i, xMin, xMax, yMin, yMax, true);
                IntPtr intPtr = Marshal.AllocHGlobal(num7);
                Marshal.Copy(array, 0, intPtr, num7);
                GameFowManager.SetSurfCellData(i, intPtr);
                Marshal.FreeHGlobal(intPtr);
            }
            else
            {
                GameFowManager.InitSurfCell(i, xMin, xMax, yMin, yMax, false);
            }
            FieldObj.SViewBlockAttr sViewBlockAttr = default(FieldObj.SViewBlockAttr);
            inFieldObj.QueryAttr(gridCellX, gridCellY, out sViewBlockAttr);
            GameFowManager.InitLevelGridCell(i, (int)sViewBlockAttr.BlockType, (int)sViewBlockAttr.LightType);
        }
        int num8 = binaryReader.ReadInt32();

        if (num8 != 987654321)
        {
        }
        binaryReader.Close();
        memoryStream.Close();
        return(true);
    }