Inheritance: MonoBehaviour
 private void ChangePositionTo(HexCell location)
 {
     FogOfWar.Hide(this);
     m_location = location;
     m_pawn.TeleportTo(location);
     FogOfWar.Show(this);
 }
Exemplo n.º 2
0
 public void ChangeFaction(FogOfWar.Players _Faction)
 {
     Debug.Log("Changeing to: " + _Faction);
     FogOfWar.UnRegisterRevealer(_Revealer.sceneReference.GetInstanceID());
     _Revealer.faction = _Faction;
     FogOfWar.RegisterRevealer(_Revealer);
 }
Exemplo n.º 3
0
    public void AddFaction()
    {
        System.Array revealFactions = System.Enum.GetValues(typeof(FogOfWar.Players));

        if (Factions.Count >= revealFactions.Length)
        {
            Debug.LogWarning("[UFoW] Cant add more Factions because the limit of " + revealFactions.Length + " is reached. Check the Documentation on how to add more Factions. (Default = 8)");
            return;
        }

        int     LevelSize = LevelWidth * LevelHeight;
        Faction f         = new Faction(LevelSize, Factions.Count);

        for (int i = 0; i < LevelSize; i++)
        {
            f.FogOfWarMapData[i] = new Color(0.0f, RevealOpacities.b, 0.0f, 0.0f);
        }

        f.FogTexture            = new Texture2D(LevelWidth, LevelHeight, TextureFormat.RGBA32, false);
        f.FogTexture.filterMode = FogTextureFilterMode;

        //Create a new RenderTexture to Blur the Fog
        f.BluredRenderTexture            = new RenderTexture(LevelWidth * UpSample, LevelHeight * UpSample, 0);
        f.BluredRenderTexture.filterMode = FogTextureFilterMode;

        f.ID             = Mathf.FloorToInt(Mathf.Pow(2, Factions.Count));
        f.RevealFactions = (FogOfWar.Players)f.ID;
        Factions.Add(f);
        FogOfWar.InitializeFogOfWar(LevelWidth, LevelHeight, Factions, RevealFaction);
    }
Exemplo n.º 4
0
 void Start()
 {
     gcRef   = FindObjectOfType <GameControl>();
     fogRef  = FindObjectOfType <FogOfWar>();
     refMPU  = FindObjectOfType <MenuPopUp>();
     cellRef = FindObjectOfType <Cell>();
 }
    private void DiscoverMap()
    {
        int posX = (int)transform.position.x;
        int posY = (int)transform.position.y;

        FogOfWar.DiscoverTiles(posX, posY);
    }
Exemplo n.º 6
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));
                    }
                }
            }
        }
    }
Exemplo n.º 7
0
    public static void CommitToMaterials()
    {
        if (!CheatCommandReplayEntry.commitFOWMaterial)
        {
            return;
        }
        if (FogOfWar._bitmapData == null)
        {
            return;
        }
        FogOfWar._bitmapTexture.LoadRawTextureData(FogOfWar._bitmapData);
        FogOfWar._bitmapTexture.Apply();
        RenderTexture renderTexture = FogOfWar.fowTextures[0];

        FogOfWar.fowTextures[0] = FogOfWar.fowTextures[1];
        FogOfWar.fowTextures[1] = renderTexture;
        FogOfWar.fowTextures[0].DiscardContents();
        Graphics.Blit(FogOfWar._bitmapTexture, FogOfWar.fowTextures[0]);
        FogOfWar.SetBlurVectors(1f / (float)FogOfWar.fowTextures[0].width, 0f);
        FogOfWar.fowTextures[2].DiscardContents();
        Graphics.Blit(FogOfWar.fowTextures[0], FogOfWar.fowTextures[2], FogOfWar.fowMats[0]);
        FogOfWar.SetBlurVectors(0f, 1f / (float)FogOfWar.fowTextures[0].height);
        FogOfWar.fowTextures[0].DiscardContents();
        Graphics.Blit(FogOfWar.fowTextures[2], FogOfWar.fowTextures[0], FogOfWar.fowMats[0]);
        RenderTexture.active = null;
        FogOfWar.commitFrame = (long)((ulong)Singleton <FrameSynchr> .get_instance().CurFrameNum);
        FogOfWar.UpdateTextures();
    }
        void UpdateGridBrush()
        {
            if (map != null)
            {
                if (map.ShowGrid)
                {
                    double xSize  = map.CellSize.Width / map.Image.Width;
                    double ySize  = map.CellSize.Height / map.Image.Height;
                    double xStart = map.CellOrigin.X / map.Image.Width;
                    double yStart = map.CellOrigin.Y / map.Image.Height;

                    ImageBrush brush = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/Images/square.png")));
                    brush.TileMode = TileMode.Tile;
                    brush.Viewport = new Rect(xStart, yStart, xSize, ySize);

                    MapGridCanvas.Background = brush;
                    FogOfWar.InvalidateVisual();
                }
                else
                {
                    MapGridCanvas.Background = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));

                    FogOfWar.InvalidateVisual();
                }
            }
        }
        void UpdateGridBrush()
        {
            if (map != null)
            {
                if (map.ShowGrid)
                {
                    double xSize  = map.CellSize.Width / map.Image.Width;
                    double ySize  = map.CellSize.Height / map.Image.Height;
                    double xStart = map.CellOrigin.X / map.Image.Width;
                    double yStart = map.CellOrigin.Y / map.Image.Height;

                    RectangleGeometry r = new RectangleGeometry(new Rect(0, 0, 100, 100));
                    Pen             p   = new Pen(new SolidColorBrush(map.GridColor), 1);
                    GeometryDrawing gd  = new GeometryDrawing(null, p, r);
                    DrawingBrush    db  = new DrawingBrush(gd);
                    db.TileMode = TileMode.Tile;
                    db.Viewport = new Rect(xStart, yStart, xSize, ySize);


                    MapGridCanvas.Background = db;
                    FogOfWar.InvalidateVisual();
                }
                else
                {
                    MapGridCanvas.Background = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));

                    FogOfWar.InvalidateVisual();
                }
            }
        }
Exemplo n.º 10
0
    public static void PrepareData()
    {
        BattleLogic instance = Singleton <BattleLogic> .get_instance();

        if (!FogOfWar.enable || !instance.isFighting)
        {
            return;
        }
        SLevelContext curLvelContext = instance.GetCurLvelContext();

        if (curLvelContext == null || curLvelContext.m_horizonEnableMethod != Horizon.EnableMethod.EnableAll)
        {
            return;
        }
        GameFowManager instance2 = Singleton <GameFowManager> .get_instance();

        GameFowCollector collector = instance2.m_collector;

        collector.UpdateFowVisibility(false);
        collector.CollectExplorer(false);
        if (Singleton <FrameSynchr> .get_instance().CurFrameNum % instance2.GPUInterpolateFrameInterval == 0u)
        {
            FogOfWar.CommitToMaterials();
        }
    }
Exemplo n.º 11
0
        private static float DistBetween(LayerTile current, LayerTile neighbor, FogOfWar fog)
        {
            float dist = float.PositiveInfinity;

            if (fog.IsVisible(current) && fog.IsVisible(neighbor))
            {
                if (!Map.map.IsTileOccupied(neighbor.X, neighbor.Y))
                {
                    dist = 1;
                }
            }
            else if (fog.IsVisible(current) && !fog.IsVisible(neighbor))
            {
                dist = 3;
            }
            else if (!fog.IsVisible(current) && fog.IsVisible(neighbor))
            {
                if (!Map.map.IsTileOccupied(neighbor.X, neighbor.Y))
                {
                    dist = 2;
                }
            }
            else
            {
                dist = 5;
            }
            return(dist);
        }
Exemplo n.º 12
0
    public ColliderFogRect(Collider2D c, FogOfWar fow)
    {
        Bounds b = c.bounds;

        position = fow.WorldPositionToFogPosition(b.min);
        size     = fow.WorldPositionToFogPosition(b.max) - position;
    }
Exemplo n.º 13
0
 public void OnDisable()
 {
     if (_Revealer != null)
     {
         FogOfWar.UnRegisterRevealer(_Revealer.sceneReference.GetInstanceID());
     }
 }
Exemplo n.º 14
0
 private void Awake()
 {
     this.fow = GameObject.FindObjectOfType <FogOfWar>();
     if (this.fow == null)
     {
         Debug.LogWarning("No FogOfWar Component could be found!  Is this an error?");
     }
 }
Exemplo n.º 15
0
 // Use this for initialization
 void Start()
 {
     gcRef     = FindObjectOfType <GameControl>();
     playerRef = FindObjectOfType <Player>();
     refFog    = FindObjectOfType <FogOfWar>();
     enemyRef  = FindObjectOfType <Enemy>();
     refMPU    = FindObjectOfType <MenuPopUp>();
 }
    // Use this for initialization
    void Start()
    {
        meshRenderers = new List <MeshRenderer>(GetComponentsInChildren <MeshRenderer>());
        fogOfWar      = FindObjectOfType <FogOfWar>();
        relatedObject = GetComponent <WorldObject>();

        isObserved = false;
    }
Exemplo n.º 17
0
 private void Awake()
 {
     _infoBar        = FindObjectOfType <InfoBar>();
     _playerControls = GameObject.Find("GameManager").GetComponent <PlayerControls>();
     _photonView     = GetComponent <PhotonView>();
     _playerGang     = GetComponent <PlayerGang>();
     _fogOfWar       = FindObjectOfType <FogOfWar>();
 }
        public ArmedForce(HexCell location, Pawn pawn, MovableType type, List <Unit> units) : base(location, pawn, type)
        {
            foreach (Unit unit in units)
            {
                AddUnit(unit);
            }

            FogOfWar.Show(this); // Depends on units being added
        }
Exemplo n.º 19
0
    private void ShowFogOfWar(bool show)
    {
        FogOfWar fogOfWar = GetComponent <FogOfWar>();

        if (fogOfWar)
        {
            fogOfWar.SetEnabled(show ? (_fogOfWarEnabled && _fogOfWarVisible) : false);
        }
    }
Exemplo n.º 20
0
    //여까지명우가넣은거

    private void Start()
    {
        if (FogOfWar.fogAlignment == FogOfWar.FogAlignment.DDDMode)
        {
            previousFaction          = FogOfWar3D.currentlyRevealed;
            rbody                    = gameObject.AddComponent <Rigidbody>();
            rbody.useGravity         = false;
            rbody.isKinematic        = true;
            sphereCollider           = gameObject.AddComponent <SphereCollider>();
            sphereCollider.isTrigger = true;

            if (FogOfWar3D.currentlyRevealed != faction)
            {
                sphereCollider.radius = 0f;
                isInTheSightRange     = false;//명우가넣은거
                Check();
                //Hide();
            }
            else
            {
                sphereCollider.radius = visionRange;
            }

            revealer3D = new Revealer3D(visionRange,
                                        faction,
                                        transform);

            FogOfWar3D.RegisterRevealer(revealer3D);
        }
        else
        {
            revealer = new Revealer(visionRange,
                                    faction,
                                    upVision,
                                    gameObject);

            FogOfWar.RegisterRevealer(revealer);

            if (dynamicBlock)
            {
                FogOfWar.RegisterVisionBlocker(gameObject);
            }

            if (faction == FogOfWar.RevealFaction)
            {
                isInTheSightRange = true;//명우가넣은거
                Check();
                //Show();
            }
            else
            {
                isInTheSightRange = false;//명우가넣은거
                Check();
                //Hide();
            }
        }
    }
Exemplo n.º 21
0
    void Update()
    {
        if (image.enabled)
        {
            foreach (GameObject g in Effects)
            {
#pragma warning disable 618
                g.GetComponent <ParticleSystem>().enableEmission = true;
            }
        }
        else
        {
            foreach (GameObject g in Effects)
            {
                g.GetComponent <ParticleSystem>().enableEmission = false;
#pragma warning restore 618
            }
        }

        if (Hide)
        {
            if (Time.time >= StartTime + TurnOffDelay)
            {
                image.enabled = false;
            }
        }

        _Revealer.visionRange = VisionRange;

        if (Faction != FogOfWar.RevealFaction)
        {
            if (FogOfWar.IsPositionRevealedByFaction(transform.position, FogOfWar.RevealFactionInt))
            {
                if (Hide)
                {
                    Hide = false;
                }
                image.enabled = true;
            }
            else
            {
                if (!Hide)
                {
                    StartTime = Time.time;
                    Hide      = true;
                }
            }
        }
        else
        {
            if (!image.enabled)
            {
                image.enabled = true;
            }
        }
    }
Exemplo n.º 22
0
    public void AnalyzeTerrain()
    {
        if (FogOfWar.ResistanceMapData == null)
        {
            FogOfWar.ResistanceMapData = new Color[LevelWidth * LevelHeight];

            for (int i = 0; i < FogOfWar.ResistanceMapData.Length; i++)
            {
                FogOfWar.ResistanceMapData[i] = new Color(0f, 0f, 0f, 1f);
            }

            Debug.Log("ResistanceMapData was not initialized!");
        }

        if (FogOfWar.ResistanceMapData.Length != 0)
        {
            if (ResitenceMapPath != "")
            {
                SetResistanceMap(ResitenceMapPath);
                InitializeMaps();
            }
        }
        else
        {
            Debug.Log("[UFoW] No Data!");
        }

        int collums = 0;

        for (float x = Origin.x; x < LevelWidth * PatchScale + Origin.x; x += PatchScale)
        {
            int rows = 0;
            for (float z = Origin.z; z < LevelHeight * PatchScale + Origin.z; z += PatchScale)
            {
                Ray ray = new Ray();
                ray.origin    = new Vector3(x + 0.5f, StartEndHeight.y + 0.1f + Origin.y, z + 0.5f);
                ray.direction = Vector3.down;
                RaycastHit rayHit     = new RaycastHit();
                int        coordinate = (int)rows * LevelWidth + (int)collums;
                if (Physics.Raycast(ray, out rayHit, Mathf.Infinity))
                {
                    FogOfWar.ResistanceMapData[coordinate].g = FogOfWar.Remap(rayHit.point.y, StartEndHeight.x + Origin.y, StartEndHeight.y + Origin.y, 0f, 1f);
                }
                else
                {
                    FogOfWar.ResistanceMapData[coordinate].g = 0f;
                }
                rows++;
            }
            collums++;
        }

#if UNITY_EDITOR
        SetWhiteTextureAsFog();
#endif
    }
Exemplo n.º 23
0
 private void Awake()
 {
     NavAgent        = GetComponent <PolyNavAgent>();
     Player          = GameObject.FindGameObjectWithTag("Player");
     Main_Camera     = GameObject.FindGameObjectWithTag("MainCamera");
     Anim            = GetComponent <NormalEnemyAnim>();
     playerLayer     = LayerMask.NameToLayer("Player");
     lightController = Main_Camera.GetComponent <FogOfWar>();
     GetComponent <NormalEnemyAnim>().enabled = true;
 }
Exemplo n.º 24
0
 //Construct a new state and set the level and all the needed variables
 public PlayingState()
 {
     _mouseState = Mouse.GetState();
     level       = new Level();
     _hud        = new PlayingHud(level, _selectedEntities, this);
     level.init("lvl2.txt", "lvlentities.txt");
     fog = new FogOfWar(level);
     level.setFog(fog);
     _customCursor = new CustomCursor(level);
 }
Exemplo n.º 25
0
    public static void EndLevel()
    {
        FogOfWar.DisableShaderFogFunction();
        FogOfWar.enable = false;
        Singleton <GameFowManager> .get_instance().UninitSurface();

        FogOfWar.Clear();
        FogOfWar._bitmapData    = null;
        FogOfWar.RenderFrameNum = 0u;
    }
Exemplo n.º 26
0
    void Update()
    {
        if (FogOfWar.fogAlignment == FogOfWar.FogAlignment.Horizontal || FogOfWar.fogAlignment == FogOfWar.FogAlignment.Vertical)
        {
            if (revealer == null)
            {
                return;
            }

            revealer.visionRange = visionRange;

            if (faction != FogOfWar.RevealFaction)
            {
                if (FogOfWar.IsPositionRevealedByFaction(transform.position, FogOfWar.RevealFactionInt))
                {
                    isInTheSightRange = true;//명우가넣은거
                    Check();
                    //Show();
                }
                else
                {
                    isInTheSightRange = false;//명우가넣은거
                    Check();
                    //Hide();
                }
            }
            else
            {
                isInTheSightRange = true;//명우가넣은거
                Check();
                //Show();
            }
        }
        else
        {
            if (previousFaction != FogOfWar3D.currentlyRevealed)
            {
                previousFaction = FogOfWar3D.currentlyRevealed;
                if (faction != FogOfWar3D.currentlyRevealed)
                {
                    sphereCollider.radius = 0f;
                    isInTheSightRange     = false;//명우가넣은거
                    Check();
                    //Hide();
                }
                else
                {
                    sphereCollider.radius = visionRange;
                    isInTheSightRange     = true;//명우가넣은거
                    Check();
                    //Show();
                }
            }
        }
    }
Exemplo n.º 27
0
 private void GenerateFogOfWar()
 {
     if (Main.Instance.gameState != GameState.MainMenu)
     {
         FogOfWar fogOfWar = GetComponent <FogOfWar>();
         if (fogOfWar)
         {
             fogOfWar.GenerateTexture();
         }
     }
 }
Exemplo n.º 28
0
 void Update()
 {
     if (FogOfWar.IsVisible(map_manager.world_to_grid(transform.position)))
     {
         EnableRendering();
     }
     else
     {
         DisableRendering();
     }
 }
Exemplo n.º 29
0
    void Awake()
    {
        thisRenderer = GetComponentsInChildren<Renderer>();
        if(!fogOfWar) {
            fogOfWar = GameObject.FindGameObjectWithTag(vars.fogofwar_tag).GetComponent<FogOfWar>();
        }

        for(int i = 0; i < thisRenderer.Length; i++) {
            thisRenderer[i].enabled = false;
        }
    }
Exemplo n.º 30
0
 private void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(this.gameObject);
     }
     else
     {
         instance = this;
     }
 }
 void Update()
 {
     if (FogOfWar.IsSemiVisible(grid_pos))
     {
         EnableRendering();
     }
     else
     {
         DisableRendering();
     }
 }
Exemplo n.º 32
0
    bool hasLOS(FogOfWar fow, int x0, int y0, int x1, int y1, float y, float h)
    {
        int nodeCount = fow.NodeCount;
        float[] fogHeight = fow.HeightData;

        int dx = Mathf.Abs(x1 - x0);
        int dy = Mathf.Abs(y1 - y0);
        int sx = x0 < x1 ? 1 : -1;
        int sy = y0 < y1 ? 1 : -1;
        int err = dx - dy;

        while (true)
        {
            if (fogHeight != null && !(fogHeight[(x0 * nodeCount) + y0] - y < h))
            {
                return false;
            }

            if (x0 == x1 && y0 == y1)
            {
                return true;
            }

            int e2 = 2 * err;

            if (e2 > -dy)
            {
                err = err - dy;
                x0 = x0 + sx;
            }

            if (e2 < dx)
            {
                err = err + dx;
                y0 = y0 + sy;
            }
        }
    }
Exemplo n.º 33
0
    protected void Start()
    {
        ConfigureVisionSettings();

        GameObject fogOfWar = GameObject.Find("FogOfWar");
        if(fogOfWar != null) {
            fogOfWarScript = fogOfWar.GetComponent<FogOfWar>();
        }

        fogLayerMask = 1 << LayerMask.NameToLayer("FogOfWar");
        LOSLayerMask = 1 << LayerMask.NameToLayer("Terrain");

        circleStep = ((2*Mathf.PI) / visionRange) - 0.0001f;

        if(RevealsFog && fogOfWarScript != null) {
            IsHiddenByFog = false;
            CalculateRevealPoints();
        }
    }
Exemplo n.º 34
0
 public void SetAllFOW(FogOfWar f, CollisionGrid cg)
 {
     int i = f == FogOfWar.Nothing ? HEAT_NONE : (f == FogOfWar.Passive ? HEAT_PASSIVE : HEAT_PASSIVE + 1);
     for(int y = 0; y < cg.numCells.Y; y++) {
         for(int x = 0; x < cg.numCells.X; x++) {
             heat[x, y] = i;
             cg.SetFogOfWar(x, y, teamIndex, f);
         }
     }
 }
Exemplo n.º 35
0
 public override bool HasLineOfSight(FogOfWar fow, int fromRow, int fromCol, int toRow, int toCol, float yPos, float maxHeight)
 {
     return hasLOS(fow, fromRow, fromCol, toRow, toCol, yPos, maxHeight);
 }
Exemplo n.º 36
0
 public DevCommandFOW(FogOfWar f)
     : base(DevCommandType.FOW)
 {
     fow = f;
 }
Exemplo n.º 37
0
 private void OnFOWChange(int x, int y, int p, FogOfWar f)
 {
     if(p != teamIndex) return;
     switch(f) {
         case FogOfWar.Active:
             Map.SetFOW(x, y, 1f);
             break;
         case FogOfWar.Passive:
             Map.SetFOW(x, y, 0.5f);
             break;
         case FogOfWar.Nothing:
             Map.SetFOW(x, y, 0f);
             break;
     }
 }
Exemplo n.º 38
0
    /// <summary>
    /// Initialises the game mode manager
    /// </summary>  
    void Start()
    {
        if(!Utilities.IsOpenLeveL(Utilities.GetLoadedLevel()))
        {
            m_networkedState = GameState.STAGE_1;
            m_state = GameState.STAGE_1;

            m_countdownTimer = FindObjectOfType<GUITimer>();
            if (m_countdownTimer == null)
            {
                Debug.LogError("Could not find GUI Count down timer");
            }
        }

        m_islandList = GameObject.FindObjectsOfType<IslandDiscoveryTrigger>();
        if(m_islandList.Length == 0)
        {
            Debug.LogError("Could not find any islands");
        }

        m_fogOfWar = FindObjectOfType<FogOfWar>();
        if(m_fogOfWar == null)
        {
            Debug.LogError("Could not find Fog of war");
        }

        m_stage1CountdownFinish = () =>
        {
            SwitchToState(GameState.STAGE_2);
            m_stateInitiatedByNetwork = false;
        };

        m_stage2CountdownFinish = () =>
        {
            GameOverScript.Get().SetLevelComplete();
        };
    }
Exemplo n.º 39
0
 void Start()
 {
     fow = FindObjectOfType(typeof(FogOfWar)) as FogOfWar;
 }
 public abstract bool HasLineOfSight(FogOfWar fow, int fromRow, int fromCol, int toRow, int toCol, float yPos, float maxHeight);