Exemplo n.º 1
0
    ///////////////////////////////////////////////////////////////////////////

    /// <summary>
    /// Creates new vision shape.
    /// </summary>
    /// <param name="fow"></param>
    /// <returns></returns>
    FogShape CreateShape(FogManager fow)
    {
        if (ShapeType == FogShapeType.Circle)
        {
            FogCircle shape = new FogCircle();
            FillShape(fow, shape);
            shape.InnerRadius = InnerRadius;
            shape.Angle       = Angle;
            return(shape);
        }
        else if (ShapeType == FogShapeType.Texture)
        {
            if (Texture == null)
            {
                return(null);
            }

            FogShapeTexture shape = new FogShapeTexture();
            FillShape(fow, shape);
            shape.Texture         = Texture;
            shape.RotateToForward = RotateToForward;
            return(shape);
        }
        return(null);
    }
Exemplo n.º 2
0
        public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            foreach (var sprite in MapSprites)
            {
                sprite.Draw(gameTime, spriteBatch);
            }

            foreach (var sprite in EnemySprites)
            {
                sprite.Draw(gameTime, spriteBatch);
            }

            FogManager.Draw(gameTime, spriteBatch);

            foreach (var sprite in Somethings)
            {
                Rectangle mapRectangle = sprite.Components.GetComponent <MapComponent>().MapRectangle;

                if (IsInRange(_player.Position, mapRectangle))
                {
                    sprite.Draw(gameTime, spriteBatch);
                }
            }

            //foreach (var sprite in NPCSprites)
            //{
            //  if (IsInRange(_player.Position, sprite.Position + new Vector2(20, 20)))
            //    sprite.Draw(gameTime, spriteBatch);
            //}
        }
Exemplo n.º 3
0
 void OnGUI()
 {
     if (actif)
     {
         GUI.Label(new Rect(Screen.width * 0.02f, Screen.height * 0.02f, Screen.width * 0.5f, Screen.height * 0.1f), "Actions Restantes: " + speed +
                   ", Vie: " + vie + "/" + vieMaximale + ", Attaque: " + attaque);
     }
     if (vie <= 0)
     {
         float decalageGauche = (Screen.width - Screen.width * 0.333f) / 2;
         GUI.Label(new Rect(decalageGauche - Screen.width * 0.25f, Screen.height * 0.25f, Screen.width * 2f, Screen.height * 0.4f),
                   "<color=white><size=30>Vous avez été tué par " + getKillerName() + ".</size></color>");
         if (GUI.Button(new Rect(decalageGauche, Screen.height * 0.45f, Screen.width * 0.3f, Screen.height * 0.1f), "Rejouer"))
         {
             TileManager.getInstance().resetTiles();
             EnemyManager.getInstance().restartEnemies();
             FogManager.getInstance().restartFog();
             Application.LoadLevel("Main");
         }
         if (GUI.Button(new Rect(Screen.width * 0.333f, Screen.height * 0.65f, Screen.width * 0.3f, Screen.height * 0.1f), "Quitter"))
         {
             Application.Quit();
         }
     }
 }
Exemplo n.º 4
0
    ////////////////////////////////////////////////////////////////////////////////

    /// <summary>
    /// // Snaps a world point to a fog pixel. It returns the position
    /// </summary>
    /// <param name="fow"></param>
    /// <param name="worldpos"></param>
    /// <param name="offset"></param>
    /// <param name="resolution"></param>
    /// <param name="size"></param>
    /// <returns></returns>
    public static Vector2 SnapWorldPositionToNearestFogPixel(FogManager fow, Vector2 worldpos, Vector2 offset, Vector2_1 resolution, float size)
    {
        Vector2 fogpos = WorldToFog(worldpos, fow.MapOffset, fow.MapResolution, fow.MapSize);

        fogpos = SnapToNearestFogPixel(fogpos);
        return(FogToWorld(fogpos, fow.MapOffset, fow.MapResolution, fow.MapSize));
    }
Exemplo n.º 5
0
 private void Construct(SignalBus signalBus, EnemySpawner enemySpawner, FogManager fogManager, PowerupFactory powerupFactory, GameplaySettings gameplaySettings)
 {
     SignalBus         = signalBus;
     _enemySpawner     = enemySpawner;
     _fogManager       = fogManager;
     _powerupFactory   = powerupFactory;
     _gameplaySettings = gameplaySettings;
 }
Exemplo n.º 6
0
 public static FogManager getInstance()
 {
     if (Instance == null)
     {
         Instance = new FogManager();
     }
     return(Instance);
 }
Exemplo n.º 7
0
 private void Construct(SignalBus signalBus, Player player, FogManager fogManager, MonoBehaviourUtil monoBehaviourUtil, GameplaySettings gameplaySettings, EnemySpawner enemySpawner)
 {
     _signalBus         = signalBus;
     _player            = player;
     _fogManager        = fogManager;
     _monoBehaviourUtil = monoBehaviourUtil;
     _gameplaySettings  = gameplaySettings;
     _enemySpawner      = enemySpawner;
 }
Exemplo n.º 8
0
    //                       FUNCTIONS
    /////////////////////////////////////////////////////////////////////////////////////

    // Use this for initialization
    void Start()
    {
        _FogManager = GetComponent <FogManager>();
        if (_FogManager.FogTexture != null)
        {
            _Texture          = new Texture2D(_FogManager.FogTexture.width, _FogManager.FogTexture.height);
            _Texture.wrapMode = TextureWrapMode.Clamp;
        }
    }
Exemplo n.º 9
0
        public virtual void LoadContent(ContentManager content, GraphicsDevice graphics)
        {
            Loaded = true;

            var fogTexture = new Texture2D(graphics, Map.TileWidth, Map.TileHeight);

            Helpers.SetTexture(fogTexture, new Color(33, 33, 33));

            FogManager        = new FogManager(fogTexture, _gameModel);
            MapSpritesManager = new MapSpritesManager(_gameModel.ContentManger);
        }
Exemplo n.º 10
0
    ///////////////////////////////////////////////////////////

    /// <summary>
    /// Sets fog map paramets.
    /// </summary>
    /// <param name="fogMan"></param>
    public void Set(FogManager fogMan)
    {
        Resolution    = fogMan.MapResolution;
        Size          = fogMan.MapSize;
        Offset        = fogMan.MapOffset;
        PixelSize     = Resolution.x / Size;
        PixelCount    = Resolution.x * Resolution.y;
        Plane         = fogMan.Plane;
        FilterMode    = fogMan.FilterMode;
        MultiThreaded = fogMan.MultiThreaded;
    }
Exemplo n.º 11
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
         return;
     }
 }
Exemplo n.º 12
0
    ///////////////////////////////////////////////////////////////////////////

    /// <summary>
    /// Returns fog of war line of sight shape.
    /// </summary>
    /// <param name="fow"></param>
    /// <param name="plane"></param>
    /// <returns></returns>
    public FogShape GetShape(FogManager fow, FogOfWarPlane plane)
    {
        FogShape shape = CreateShape(fow);

        if (shape == null)
        {
            return(null);
        }

        shape.LineOfSight  = CalculateLineOfSight(shape.EyePosition, plane);
        shape.VisibleCells = null;
        return(shape);
    }
Exemplo n.º 13
0
        private string bgmName;         //BGM名

        public StageManager(GameDevice gameDevice)
        {
            this.gameDevice = gameDevice;
            renderer        = gameDevice.Renderer;
            fogManager      = renderer.FogManager;

            limitTime = new Timer(5 * 60);
            limitTime.Initialize();
            floor     = 1;
            bossRange = 5;
            stageSize = 20;

            farFog = FAREST_FOG;
        }
Exemplo n.º 14
0
 void OnGUI()
 {
     if (GUI.Button(new Rect(Screen.width * 0.35f, Screen.height * 0.65f, Screen.width * 0.3f, Screen.height * 0.1f), "Rejouer"))
     {
         TileManager.getInstance().resetTiles();
         EnemyManager.getInstance().restartEnemies();
         FogManager.getInstance().restartFog();
         Application.LoadLevel("Main");
     }
     if (GUI.Button(new Rect(Screen.width * 0.35f, Screen.height * 0.85f, Screen.width * 0.3f, Screen.height * 0.1f), "Quitter"))
     {
         Application.Quit();
     }
 }
Exemplo n.º 15
0
    // Use this for initialization
    void Start()
    {
        tileManager  = TileManager.getInstance();
        enemyManager = EnemyManager.getInstance();
        turnManager  = TurnManager.getInstance();
        fogManager   = FogManager.getInstance();

        adjustBackground();
        generateTiles();
        generateFog();

        generateZombies();
        generateEnnemis();
        generatePowerUps();
    }
Exemplo n.º 16
0
    ///////////////////////////////////////////////////////////////////////////

    void FillShape(FogManager fow, FogShape shape)
    {
        if (AntiFlicker)
        {
            // snap to nearest fog pixel
            shape.EyePosition = FogConversion.SnapWorldPositionToNearestFogPixel(fow, FogConversion.WorldToFogPlane(_Transform.position, fow.Plane), fow.MapOffset, fow.MapResolution, fow.MapSize);
            shape.EyePosition = FogConversion.FogPlaneToWorld(shape.EyePosition.x, shape.EyePosition.y, _Transform.position.y, fow.Plane);
        }
        else
        {
            shape.EyePosition = _Transform.position;
        }
        shape.Forward = FogConversion.TransformFogPlaneForward(_Transform, fow.Plane);
        shape.Offset  = Offset;
        shape.Radius  = Radius;
    }
Exemplo n.º 17
0
    void Awake()
    {
        //Dependancies
        PlayerObject = GameObject.FindWithTag("Player");
        //SpawnLocation = GameObject.FindWithTag("Spawn").transform.position;

        PlayerController = PlayerObject.GetComponent <PlayerController>();
        CamController    = Camera.main.GetComponent <CameraController>();

        FogController = gameObject.GetComponent <FogManager>();

        PlayerAnimator  = PlayerObject.GetComponent <Animator>();
        PlayerRigidBody = PlayerObject.GetComponent <Rigidbody2D>();
        PlayerCollider  = PlayerObject.GetComponent <CapsuleCollider2D>();

        //Component Assignment Checks
        //if (PlatformsLayer.value.ToString() == "Nothing" || PickableLayer.value.ToString() == "Nothing") { Debug.Log("[DEPENDANCY ERROR]LayerMasks are missing!"); return; }
        if (PlayerObject == null)
        {
            Debug.Log("[DEPENDANCY ERROR] An Object with the tag (Player), hasn't been found!"); return;
        }
        //if (SpawnLocation == null) { Debug.Log("[DEPENDANCY ERROR] An Object with the tag (Spawn), hasn't been found!"); return; }
        if (PlayerController == null)
        {
            Debug.Log("[DEPENDANCY ERROR] A Script with the name (Controller), hasn't been found!"); return;
        }


        if (PlayerAnimator == null)
        {
            Debug.Log("[DEPENDANCY ERROR] A Component with the name  (PlayerAnimator), hasn't been found!"); return;
        }
        //if (PlayerAudio == null) { Debug.Log("[DEPENDANCY ERROR] A Component with the name  (PlayerAudio), hasn't been found!"); return; }
        if (PlayerRigidBody == null)
        {
            Debug.Log("[DEPENDANCY ERROR] A Component with the name  (PlayerRigidBody), hasn't been found!"); return;
        }
        if (PlayerCollider == null)
        {
            Debug.Log("[DEPENDANCY ERROR] A Component with the name  (PlayerCollider), hasn't been found!"); return;
        }

        DependanciesLoaded = true;

        Debug.Log("<color=blue>[Dependancies for this Scene has been SUCCESSFULLY LOADED!]</color>");
    }
Exemplo n.º 18
0
    public void updateEnemy(int index)
    {
        EnemyScript enemy = lesEnemies[index];

        if (lesEnemies[index] != null)
        {
            if (!FogManager.getInstance().isFog(enemy.getX(), enemy.getY()))
            {
                lesEnemies[index].actif = true;
                lesEnemies[index].StartActions();
            }
            else
            {
                TurnManager.getInstance().nextEnemy();
            }
        }
        else
        {
            TurnManager.getInstance().nextEnemy();
        }
    }
Exemplo n.º 19
0
    //             FUNCTIONS
    ///////////////////////////////////////////////////////////

    /// Constructor
    public FogMap(FogManager fogMan)
    {
        Set(fogMan);
    }
Exemplo n.º 20
0
 void OnDestroy()
 {
     instance = null;
 }
Exemplo n.º 21
0
    // Update is called once per frame
    void Update()
    {
        if (actif)
        {
            base.Update();

            if ((sex == "F" && Input.GetKeyDown(KeyCode.RightArrow)) || (sex == "M" && Input.GetKeyDown(KeyCode.D)))
            {
                if (checkNearby(1, 0))
                {
                    if (side == -1)
                    {
                        side = 1;
                    }
                    transform.localScale = new Vector3(4 * side, 4, 0);
                    MoveRight();
                    FogManager.getInstance().unFog(getX(), getY());
                }
            }


            if ((sex == "F" && Input.GetKeyDown(KeyCode.LeftArrow)) || (sex == "M" && Input.GetKeyDown(KeyCode.A)))
            {
                if (checkNearby(-1, 0))
                {
                    if (side == 1)
                    {
                        side = -1;
                    }
                    transform.localScale = new Vector3(4 * side, 4, 1);
                    MoveLeft();
                    FogManager.getInstance().unFog(getX(), getY());
                }
            }

            if ((sex == "F" && Input.GetKeyDown(KeyCode.UpArrow)) || (sex == "M" && Input.GetKeyDown(KeyCode.W)))
            {
                if (checkNearby(0, 1))
                {
                    transform.localScale = new Vector3(4 * side, 4, 1);
                    MoveForward();
                    FogManager.getInstance().unFog(getX(), getY());
                }
            }

            if ((sex == "F" && Input.GetKeyDown(KeyCode.DownArrow)) || (sex == "M" && Input.GetKeyDown(KeyCode.S)))
            {
                if (checkNearby(0, -1))
                {
                    transform.localScale = new Vector3(4 * side, 4, 1);
                    MoveBackward();
                    FogManager.getInstance().unFog(getX(), getY());
                }
            }

            if (vie <= 0)
            {
                actif = false;
                SoundScript.Instance.MakePlayerDeathSound();
            }


            if (attackCount > 0)
            {
                attackCount--;
            }
        }

        anim.SetFloat("vitesse", movementUnit);
        anim.SetInteger("attackCount", attackCount);
        anim.SetInteger("life", vie);
    }
Exemplo n.º 22
0
 void Start()
 {
     Instance = this;
     ApplySettings(CurrentSettings);
 }
Exemplo n.º 23
0
 private void Start()
 {
     _fm = FindObjectOfType <FogManager>();
 }
Exemplo n.º 24
0
 // Use this for initialization
 void Start()
 {
     _FogManager = FogManager.GetFogManager();
 }
Exemplo n.º 25
0
        public override void LoadContent(ContentManager content, GraphicsDevice graphics)
        {
            base.LoadContent(content, graphics);

            var bushTexture       = content.Load <Texture2D>("Roaming/Bush");
            var building01Texture = content.Load <Texture2D>("Roaming/Buildings/Building_02");
            var grassTexture      = content.Load <Texture2D>("Roaming/Tiles/Grass");

            var fogTexture = new Texture2D(graphics, Map.TileWidth, Map.TileHeight);

            Helpers.SetTexture(fogTexture, new Color(33, 33, 33));

            var treeTexture  = content.Load <Texture2D>("Roaming/Tree");
            var enemyTexture = content.Load <Texture2D>("Roaming/Enemy");
            var amount       = _gameModel.ScreenWidth / treeTexture.Width;

            MapSprites = new List <MapSprite>();

            for (int y = 0; y < _gameModel.ScreenHeight / Map.TileHeight; y++)
            {
                for (int x = 0; x < _gameModel.ScreenWidth / Map.TileWidth; x++)
                {
                    MapSprites.Add(MapSpritesManager.GetGrass(new Vector2(x * Map.TileWidth, y * Map.TileHeight)));
                }
            }

            for (int y = 0; y < 3; y++)
            {
                for (int i = 0; i < amount; i++)
                {
                    var position = new Vector2(i * treeTexture.Width, y * 40);

                    MapSprites.Add(MapSpritesManager.GetTree(position));
                }
            }

            var newX = _gameModel.ScreenWidth - treeTexture.Width;

            for (int y = 3; y < 10; y++)
            {
                var position = new Vector2(newX, y * Map.TileWidth);

                MapSprites.Add(MapSpritesManager.GetTree(position));
            }

            for (int y = 3; y < 16; y++)
            {
                var position = new Vector2(0, y * Map.TileWidth);

                MapSprites.Add(MapSpritesManager.GetTree(position));
            }

            for (int x = 0; x < (_gameModel.ScreenWidth / treeTexture.Width); x++)
            {
                var position = new Vector2(x * treeTexture.Width, (_gameModel.ScreenHeight - treeTexture.Height));

                MapSprites.Add(MapSpritesManager.GetTree(position));
            }

            foreach (var sprite in MapSprites)
            {
                FogManager.AddItem(sprite);
            }
        }
Exemplo n.º 26
0
        public override void LoadContent(ContentManager content, GraphicsDevice graphics)
        {
            base.LoadContent(content, graphics);

            var bushTexture       = content.Load <Texture2D>("Roaming/Bush");
            var building01Texture = content.Load <Texture2D>("Roaming/Buildings/Building_02");
            var treeTexture       = content.Load <Texture2D>("Roaming/Tree");
            var grassTexture      = content.Load <Texture2D>("Roaming/Tiles/Grass");

            var fogTexture = new Texture2D(graphics, Map.TileWidth, Map.TileHeight);

            Helpers.SetTexture(fogTexture, new Color(33, 33, 33));

            var buildingPosition = new Vector2(200, 160);

            MapSprites = new List <MapSprite>();

            for (int y = 0; y < _gameModel.ScreenHeight / Map.TileHeight; y++)
            {
                for (int x = 0; x < _gameModel.ScreenWidth / Map.TileWidth; x++)
                {
                    MapSprites.Add(MapSpritesManager.GetGrass(new Vector2(x * Map.TileWidth, y * Map.TileHeight)));
                }
            }

            //MapSprites.Add(new MapSprite(building01Texture, buildingPosition, Color.Blue)
            //{
            //  CollisionRectangle = new Rectangle((int)buildingPosition.X, (int)buildingPosition.Y + (Map.TileHeight * 2), building01Texture.Width, building01Texture.Height - (Map.TileHeight * 2)),
            //});
            MapSprites.Add(MapSpritesManager.GetTree(new Vector2(200, 360)));
            MapSprites.Add(MapSpritesManager.GetTree(new Vector2(360, 360)));

            var amount = _gameModel.ScreenWidth / treeTexture.Width;

            for (int y = -1; y < 3; y++)
            {
                for (int i = 0; i < amount; i++)
                {
                    var position = new Vector2(i * treeTexture.Width, y * 40);

                    MapSprites.Add(MapSpritesManager.GetTree(position));
                }
            }

            for (int y = 3; y < 10; y++)
            {
                var position = new Vector2(0, y * Map.TileHeight);

                MapSprites.Add(MapSpritesManager.GetTree(position));
            }

            var newX = _gameModel.ScreenWidth - treeTexture.Width;

            for (int y = 3; y < 16; y++)
            {
                var position = new Vector2(newX, y * Map.TileHeight);

                MapSprites.Add(MapSpritesManager.GetTree(position));
            }

            for (int x = 0; x < (_gameModel.ScreenWidth / treeTexture.Width); x++)
            {
                var position = new Vector2(x * treeTexture.Width, (_gameModel.ScreenHeight - treeTexture.Height));

                MapSprites.Add(MapSpritesManager.GetTree(position));
            }

            foreach (var sprite in MapSprites)
            {
                FogManager.AddItem(sprite);
            }

            Somethings.Add(new Entities.Roaming.Animal(
                               content.Load <Texture2D>("Roaming/Animals/Pig"),
                               content.Load <SpriteFont>("Fonts/Font"),
                               _map)
            {
                Position = new Vector2(400, 400),
            });

            var building = new Entities.Roaming.Building(building01Texture, _map)
            {
                Position = buildingPosition,
            };

            Somethings.Add(building);

            Somethings.Add(new Entities.Roaming.Enemy(
                               content.Load <Texture2D>("Actor/Enemy1/EnemyBody"),
                               content.Load <Texture2D>("Actor/Enemy1/EnemyTail"),
                               _map)
            {
                Position = new Vector2(320, 480),
            });

            EnemySprites.Add(MapSpritesManager.GetEnemy(new Vector2(360, 440)));
        }