コード例 #1
0
        public static bool CanEncounter(SpaceTile spaceTile)
        {
            if (EncounterActive || lastEncounter == spaceTile || spaceTile.Encounter == false)
            {
                return(false);
            }

            // Clear last encounter
            lastEncounter = null;

            return(true);
        }
コード例 #2
0
 public static void Start(SpaceTile spaceTile)
 {
     if (spaceTile == null)
     {
         // Do Nothing
     }
     else if (CanEncounter(spaceTile))
     {
         EncounterActive = true;
         lastEncounter   = spaceTile;
     }
 }
コード例 #3
0
        public static bool CanEncounter( SpaceTile spaceTile)
        {
            if (EncounterActive || lastEncounter == spaceTile || spaceTile.Encounter == false)
            {
                return false;
            }

            // Clear last encounter
            lastEncounter = null;

            return true;
        }
コード例 #4
0
        public EarthTile(Vector2 worldLocation)
        {
            TextureLink textureLink = TextureManager.Textures[TextureNames.Earth1];

            BaseSprite = new Sprite(worldLocation,
                                    textureLink.SpriteSheet,
                                    textureLink.SourceRectangle,
                                    Vector2.Zero);

            BaseSprite.AnimateWhenStopped = true;
            BaseSprite.CollisionRadius    = EncounterRange;

            Encounter        = false;
            LongRangeScanned = true;

            tester = new HelpfulScanners(worldLocation);
        }
コード例 #5
0
ファイル: EarthTile.cs プロジェクト: MrPhil/Ludum-Dare-19
        public EarthTile(Vector2 worldLocation)
        {
            TextureLink textureLink = TextureManager.Textures[TextureNames.Earth1];

            BaseSprite = new Sprite(worldLocation,
                textureLink.SpriteSheet,
                textureLink.SourceRectangle,
                Vector2.Zero);

            BaseSprite.AnimateWhenStopped = true;
            BaseSprite.CollisionRadius = EncounterRange;

            Encounter = false;
            LongRangeScanned = true;

            tester = new HelpfulScanners(worldLocation);
        }
コード例 #6
0
        public static void Update(GameTime gameTime)
        {
            HandleInput(gameTime);
            BaseSprite.Update(gameTime);
            ClampToWorld();

            // Reveal unexplored tiles (widest scan)
            List <SpaceTile> near = TileMap.GetSpaceTilesInView();

            SpaceTile encounter = null;

            foreach (SpaceTile spaceTile in near)
            {
                if (spaceTile.BaseSprite.IsCircleColliding(Player.BaseSprite.WorldCenter, Player.LongRange))
                {
                    spaceTile.LongRangeScan();
                }

                if (EncounterManager.EncounterActive)
                {
                    // Do Nothing
                }
                else
                {
                    if (spaceTile.BaseSprite.IsCircleColliding(BaseSprite.WorldCenter, EncounterRange))
                    {
                        if (encounter == null)
                        {
                            encounter = spaceTile;
                        }
                        else
                        {
                            if (Vector2.Distance(spaceTile.BaseSprite.WorldCenter, Player.BaseSprite.WorldCenter) >
                                Vector2.Distance(encounter.BaseSprite.WorldCenter, Player.BaseSprite.WorldCenter))
                            {
                                encounter = spaceTile;
                            }
                        }
                    }
                }
            }

            EncounterManager.Start(encounter);
        }
コード例 #7
0
ファイル: TileMap.cs プロジェクト: MrPhil/Ludum-Dare-19
        public static void GenerateRandomMap()
        {
            for (int x = 0; x < MapWidth; x++)
                for (int y = 0; y < MapHeight; y++)
                {
                    //mapSquares[x, y] = floorTile;

                    //if ((x == 0) || (y == 0) ||
                    //    (x == MapWidth - 1) || (y == MapHeight - 1))
                    //{
                    //    mapSquares[x, y] = wallTile;
                    //    continue;
                    //}

                    //if ((x == 1) || (y == 1) ||
                    //    (x == MapWidth - 2) || (y == MapHeight - 2))
                    //{
                    //    continue;
                    //}

                    int roll = Random.Next(0, 100);
                    int unknownTileIndex = Random.Next(UnknownTileStart, UnknownTileEnd + 1);
                    if (roll < 10)
                    {
                        // Star
                        // Is there a star too close?
                        bool empty = true;
                        for (int i = x - StarTileBuffer; i < x + StarTileBuffer; i++)
                            for (int k = y - StarTileBuffer; k < y + StarTileBuffer; k++)
                            {
                                if (i < 0 || k < 0 ||
                                    i >= MapWidth || k >= MapHeight ||
                                    mapSquares[i, k] == null)
                                {
                                    // Do nothing
                                }
                                else if (mapSquares[i, k].IsStar)
                                {
                                    empty = false;
                                    break;
                                }
                            }

                        if (empty)
                        {
                            Vector2 position = new Vector2(SquareWorldRectangle(x, y).X,
                                    SquareWorldRectangle(x, y).Y);
                            roll = Random.Next(1, 5);
                            switch( roll )
                            {
                                case 1:
                                    mapSquares[x,y] = new HelpfulScanners(position);
                                    break;
                                case 2:
                                    mapSquares[x, y] = new KilledWorldTile(position);
                                    break;
                                case 3:
                                    mapSquares[x, y] = new ScaredWorldTile(position);
                                    break;
                                case 4:
                                    mapSquares[x, y] = new EmptyStar(position);
                                    break;
                                default:
                                    mapSquares[x, y] = new StarTile(position);
                                    break;
                            }
                        }
                        else
                        {
                            // Empty Space
                            mapSquares[x, y] = new SpaceTile(new Vector2(SquareWorldRectangle(x, y).X,
                            SquareWorldRectangle(x, y).Y));
                        }
                    }
                    else
                    {
                        // Empty Space
                        mapSquares[x, y] = new SpaceTile(new Vector2(SquareWorldRectangle(x, y).X,
                            SquareWorldRectangle(x, y).Y));
                    }
                }

            // Find star near starting point
            // and replace with Earth
            Vector2 playerStart = GetSquareAtPixel(Player.BaseSprite.WorldLocation);
            bool stop = false;
            for (int x = (int)playerStart.X - StarTileBuffer; x < playerStart.X + StarTileBuffer; x++)
            {
                if (stop)
                {
                    break;
                }
                for (int y = (int)playerStart.Y - StarTileBuffer; y < playerStart.Y + StarTileBuffer; y++)
                {
                    if (mapSquares[x, y].IsStar)
                    {
                        mapSquares[x, y] = new EarthTile(new Vector2( SquareWorldRectangle(x, y).X, SquareWorldRectangle(x,y ).Y));
                        stop = true;
                        break;
                    }
                }
            }
        }
コード例 #8
0
 public static void Start(SpaceTile spaceTile)
 {
     if( spaceTile == null )
     {
          // Do Nothing
     }
     else if(CanEncounter(spaceTile))
     {
         EncounterActive = true;
         lastEncounter = spaceTile;
     }
 }
コード例 #9
0
        static public void GenerateRandomMap()
        {
            for (int x = 0; x < MapWidth; x++)
            {
                for (int y = 0; y < MapHeight; y++)
                {
                    //mapSquares[x, y] = floorTile;

                    //if ((x == 0) || (y == 0) ||
                    //    (x == MapWidth - 1) || (y == MapHeight - 1))
                    //{
                    //    mapSquares[x, y] = wallTile;
                    //    continue;
                    //}

                    //if ((x == 1) || (y == 1) ||
                    //    (x == MapWidth - 2) || (y == MapHeight - 2))
                    //{
                    //    continue;
                    //}

                    int roll             = Random.Next(0, 100);
                    int unknownTileIndex = Random.Next(UnknownTileStart, UnknownTileEnd + 1);
                    if (roll < 10)
                    {
                        // Star
                        // Is there a star too close?
                        bool empty = true;
                        for (int i = x - StarTileBuffer; i < x + StarTileBuffer; i++)
                        {
                            for (int k = y - StarTileBuffer; k < y + StarTileBuffer; k++)
                            {
                                if (i < 0 || k < 0 ||
                                    i >= MapWidth || k >= MapHeight ||
                                    mapSquares[i, k] == null)
                                {
                                    // Do nothing
                                }
                                else if (mapSquares[i, k].IsStar)
                                {
                                    empty = false;
                                    break;
                                }
                            }
                        }

                        if (empty)
                        {
                            Vector2 position = new Vector2(SquareWorldRectangle(x, y).X,
                                                           SquareWorldRectangle(x, y).Y);
                            roll = Random.Next(1, 5);
                            switch (roll)
                            {
                            case 1:
                                mapSquares[x, y] = new HelpfulScanners(position);
                                break;

                            case 2:
                                mapSquares[x, y] = new KilledWorldTile(position);
                                break;

                            case 3:
                                mapSquares[x, y] = new ScaredWorldTile(position);
                                break;

                            case 4:
                                mapSquares[x, y] = new EmptyStar(position);
                                break;

                            default:
                                mapSquares[x, y] = new StarTile(position);
                                break;
                            }
                        }
                        else
                        {
                            // Empty Space
                            mapSquares[x, y] = new SpaceTile(new Vector2(SquareWorldRectangle(x, y).X,
                                                                         SquareWorldRectangle(x, y).Y));
                        }
                    }
                    else
                    {
                        // Empty Space
                        mapSquares[x, y] = new SpaceTile(new Vector2(SquareWorldRectangle(x, y).X,
                                                                     SquareWorldRectangle(x, y).Y));
                    }
                }
            }

            // Find star near starting point
            // and replace with Earth
            Vector2 playerStart = GetSquareAtPixel(Player.BaseSprite.WorldLocation);
            bool    stop        = false;

            for (int x = (int)playerStart.X - StarTileBuffer; x < playerStart.X + StarTileBuffer; x++)
            {
                if (stop)
                {
                    break;
                }
                for (int y = (int)playerStart.Y - StarTileBuffer; y < playerStart.Y + StarTileBuffer; y++)
                {
                    if (mapSquares[x, y].IsStar)
                    {
                        mapSquares[x, y] = new EarthTile(new Vector2(SquareWorldRectangle(x, y).X, SquareWorldRectangle(x, y).Y));
                        stop             = true;
                        break;
                    }
                }
            }
        }