Exemple #1
0
        //----------------------------------------------------------------------
        // Movement & Checking Functions
        //----------------------------------------------------------------------

        private void _CheckCurrentTile(GameTime gameTime)
        {
            int _totalRow          = m_referenceMapData.GetMapTileHeight();
            int _totalCol          = m_referenceMapData.GetMapTileWidth();
            int tileID_CurrentTIle = m_referenceMapData.GetMapTileData(m_referenceMapData.ConvertToMapIdex(m_playerTilePositionY, m_playerTilePositionX, _totalRow, _totalCol));

            if (tileID_CurrentTIle == (int)TileType.PATH)
            {
                m_onHideTile  = false;
                m_hidingTimer = 0.0f;
            }

            if (tileID_CurrentTIle == (int)TileType.EXIT_SIGN)
            {
                m_onExitTile = true;
            }

            if (tileID_CurrentTIle == (int)TileType.HIDE_TILE)
            {
                m_hidingTimer += (gameTime.ElapsedGameTime.TotalSeconds * 7);
                if (m_hidingTimer <= 5.0f)
                {
                    m_onHideTile = true;
                }
                else
                {
                    m_hidingTimer = 0.0f;
                    m_onHideTile  = false;
                    SetTilePosition((int)m_playerPreviousPositionForHideout.X, (int)m_playerPreviousPositionForHideout.Y);
                }
            }
        }
Exemple #2
0
        //=======================================================
        // Condition Functions
        //=======================================================

        protected bool _PlayerInLineOfSightHorizontalFlag(Vector2 i_playerPosVector)
        {
            int playerX = (int)i_playerPosVector.X;
            int playerY = (int)i_playerPosVector.Y;
            int wizardX = refPosX;
            int wizardY = refPosY;
            int R       = refMap.GetMapTileHeight();
            int C       = refMap.GetMapTileWidth();
            int TileID  = 0;

            //If same Row means different in X, player-wizard Horizontal
            if (wizardY == playerY)
            {
                int _d = playerX - wizardX;
                if (_d > 0) //Player on right side
                {
                    while (_d != 0)
                    {
                        TileID = refMap.GetMapTileData(refMap.ConvertToMapIdex(wizardY, wizardX + 1, R, C));

                        if (TileID == 00)
                        {
                            wizardX++;
                            _d--;
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    return(true);
                }
                else //Player on left side
                {
                    while (_d != 0)
                    {
                        TileID = refMap.GetMapTileData(refMap.ConvertToMapIdex(wizardY, wizardX - 1, R, C));

                        if (TileID == 00)
                        {
                            wizardX--;
                            _d++;
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    return(true);
                }
            }
            return(false);
        }
        protected override void Initialize()
        {
            base.Initialize();
            this.IsMouseVisible = true;

            //Map Related
            enumMapData           = new EnumMapData();
            demoLevelMapData25x25 = new MapData(GameLevel.DEMO25x25);
            demoLevelMapData25x25.InitializeMapData();
            demoMapTileWidth  = demoLevelMapData25x25.GetMapTileWidth();
            demoMapTileHeight = demoLevelMapData25x25.GetMapTileHeight();

            //Camera
            cameraView = new Camera2D();
            cameraView.SetBoundary(0, 0, ((demoMapTileWidth - squaresAcross) * pixelWidthPerTile), ((demoMapTileHeight - squaresDown) * pixelHeightPerTile));

            //Key And Locks
            staticObjectHandler = new StaticObjectHandler(demoLevelMapData25x25);
            key       = staticObjectHandler.GetKeys();
            doorLock  = staticObjectHandler.GetLocks();
            spellItem = staticObjectHandler.GetSpellItems();

            //Player
            player = new Player();
            player.SetMapReference(demoLevelMapData25x25);
            player.SetTilePosition(1, 1);
            player.SetUpLockInformation(doorLock);

            //Wizard
            wizard = new Wizard();
            wizard.SetMapReference(demoLevelMapData25x25);
            wizard.SetTilePosition(12, 4);

            //Minions array
            minions = new Minion[5];
            int[][] minionsInitialPatrolData = new int[5][] {
                new int[] { 4, 1, 5, 6 },
                new int[] { 4, 15, 5, 6 },
                new int[] { 16, 1, 10, 10 },
                new int[] { 20, 15, 4, 5 },
                new int[] { 11, 8, 7, 7 }
            };
            for (int i = 0; i < minions.Length; i++)
            {
                minions[i] = new Minion();
                minions[i].SetMinionId(i);
                minions[i].SetMapReference(demoLevelMapData25x25);
                minions[i].SetPatrolStartPos(minionsInitialPatrolData[i]);
                minions[i].SetTilePosition(minionsInitialPatrolData[i][0], minionsInitialPatrolData[i][1]);
            }

            gameIsOver     = false;
            minutesPlaying = 0;
            secondsPlaying = 0.0f;

            //Sound
            soundManager           = new SoundManager(this.Content);
            playGameBGMOnlyOnce    = true;
            playGameOverOnlyOnce   = true;
            playButtonOnlyOnce     = true;
            playPickUpOnlyOnce     = true;
            playUnlockDoorOnlyOnce = new bool[] { true, true, true, true };
            playerPickUpSomething  = false;
            footStepTimer          = 0.0f;
        }