コード例 #1
0
ファイル: Adventurer_Draw.cs プロジェクト: Kalasen/Adventurer
        static void Draw_Tiles()
        {
            for (int y = 0; y < Level.GRIDH; y++)
            {
                for (int x = 0; x < Level.GRIDW; x++)
                {
                    int      imageIndex = -1;                           //Open floor image
                    Color    imageColor = Color.White;
                    Tile     thisTile   = CurrentLevel.tileArray[x, y]; //Shorthand for this tile
                    Creature player     = CurrentLevel.creatures[0];    //Shorthand for the player creature

                    if (CurrentLevel.levelType == "forest")
                    {
                        imageColor = Color.LightGreen; //Grassy forest floor
                    }

                    if (thisTile.lastSeenImage > 0)          //If we've seen it
                    {
                        imageIndex = thisTile.lastSeenImage; //Draw the remembered tile
                        imageColor = Color.DimGray;          //But washed out
                    }

                    bool LOS = ((CurrentLevel.LineOfSight(player.pos, new Point2D(x, y))) || iCanSeeForever);

                    if (LOS && player.blind <= 0) //If in line of sight and not blind
                    {
                        imageIndex = 46;          //Open floor tile
                        if (CurrentLevel.tileArray[x, y].isWall)
                        {
                            imageIndex = 219; //Wall image
                            imageColor = Color.Tan;
                        }

                        if (CurrentLevel.tileArray[x, y].fixtureLibrary.Count > 0)
                        {
                            int  topIndex    = CurrentLevel.tileArray[x, y].fixtureLibrary.Count - 1;
                            bool visibleTrap = true;

                            if (CurrentLevel.tileArray[x, y].fixtureLibrary[topIndex] is Trap)
                            {
                                Trap t = (Trap)CurrentLevel.tileArray[x, y].fixtureLibrary[topIndex];
                                if (t.visible)
                                {
                                    visibleTrap = true;
                                }
                                else
                                {
                                    visibleTrap = false;
                                }
                            }

                            if (visibleTrap)
                            {
                                imageIndex = CurrentLevel.tileArray[x, y].fixtureLibrary[topIndex].imageIndex;
                                imageColor = CurrentLevel.tileArray[x, y].fixtureLibrary[topIndex].color;
                            }
                            //else
                            //{
                            //    imageIndex = 0; //Open floor image
                            //    imageColor = Color.White;
                            //}
                        }
                    }

                    if (CurrentLevel.tileArray[x, y].itemList.Count > 0 &&                        //If there's an item here
                        (CurrentLevel.creatures[0].detectItem > 0 || (LOS && player.blind <= 0))) //If detecting items or can see them
                    {
                        int topIndex = CurrentLevel.tileArray[x, y].itemList.Count - 1;
                        if (CurrentLevel.tileArray[x, y].itemList[topIndex] != null)
                        {
                            imageIndex = CurrentLevel.tileArray[x, y].itemList[topIndex].itemImage; //Top item image
                            imageColor = CurrentLevel.tileArray[x, y].itemList[topIndex].color;
                        }
                    }

                    foreach (Creature c in CurrentLevel.creatures)
                    {
                        if (c.pos == new Point2D(x, y) && //If there's a creature here
                            ((LOS && player.blind <= 0 && (c.invisibility <= 0 || player.seeInvisible > 0)) ||
                             player.detectMonster > 0))   //And we can see or detect it
                        {
                            imageIndex = c.creatureImage;
                            imageColor = c.color;
                        }
                    }

                    if (imageIndex >= 0 && imageIndex < 256)                     //If existent
                    {
                        CurrentLevel.tileArray[x, y].lastSeenImage = imageIndex; //Remember image
                        DrawImage(imageIndex, new Point2D(x * TILEWIDTH, y * TILEHEIGHT),
                                  imageColor);                                   //Draw this tile's stuff
                    }

                    if (player.pos == new Point2D(x, y))                    //PC should always be drawn
                    {
                        imageIndex = player.creatureImage;
                        imageColor = player.color;
                        DrawImage(imageIndex, new Point2D(x * TILEWIDTH, y * TILEHEIGHT),
                                  imageColor); //Draw this tile's stuff
                    }
                    //int smellTotal = 0;
                    //foreach (int s in currentLevel.tileArray[x, y].scentMagnitude)
                    //{
                    //    smellTotal += s;
                    //}
                    //DrawText(veraSmall, smellTotal.ToString(), new Vector2(x * TILEWIDTH, y * TILEHEIGHT), Color.Red);
                }
            }
        }
コード例 #2
0
ファイル: Adventurer_Draw.cs プロジェクト: Kalasen/Adventurer
        static void Draw_GetPos()
        {
            Draw_Main();
            SdlGfx.boxColor(screen, 5, 533, 895, (short)(windowSizeY * 0.992), Color.Black.ToArgb());
            SdlGfx.rectangleColor(screen, 5, 533, 895, (short)(windowSizeY * 0.992), Color.White.ToArgb());

            DrawImage(88, new Point2D(cursorPos.X * TILEWIDTH, cursorPos.Y * TILEHEIGHT), Color.Yellow); //Draw Cursor

            #region Description
            int            m        = 535;
            Queue <string> messages = new Queue <string>();
            Tile           thisTile = CurrentLevel.tileArray[cursorPos.X, cursorPos.Y];

            if (CurrentLevel.LineOfSight(CurrentLevel.creatures[0].pos, cursorPos)) //If it can be seen
            {
                foreach (Creature c in CurrentLevel.creatures)
                {
                    if (c.pos == cursorPos) //If creature is at this position
                    {
                        messages.Enqueue("There is a " + c.name + " here.");
                    }
                }

                if (thisTile.itemList.Count > 0)
                {
                    messages.Enqueue("There is a " + thisTile.itemList[0].name + " here.");
                }

                if (thisTile.fixtureLibrary.Count > 0)
                {
                    if (thisTile.fixtureLibrary[0] is Trap)
                    {
                        Trap t = (Trap)thisTile.fixtureLibrary[0];
                        if (t.visible)
                        {
                            messages.Enqueue("There is a " + thisTile.fixtureLibrary[0].type + " here.");
                        }
                    }
                    else
                    {
                        messages.Enqueue("There is a " + thisTile.fixtureLibrary[0].type + " here.");
                    }
                }

                if (thisTile.isWall)
                {
                    messages.Enqueue("This is a " + thisTile.material.name + " wall.");
                }
            }
            else
            {
                messages.Enqueue("You cannot see to there at the moment");
            }

            while (messages.Count >= 14)
            {
                messages.Dequeue(); //Don't let there be more than fourteen in the queue
            }

            if (messages.Count <= 0)
            {
                messages.Enqueue("There is nothing noteworthy here.");
            }

            foreach (string message in messages.Reverse())
            {
                m -= 15; //Skip up 15 pixels
                DrawText(veraSmall, message, new Point2D(10, m), Color.White);
            }

            messages.Clear();
            #endregion
        }