Ejemplo n.º 1
0
        /// <summary>
        /// Handles all game updating.
        /// </summary>
        public static void Update()
        {
            if (OutOfTime())
            {
                return;
            }
            if (GamePaused())
            {
                return;
            }
            if (PlayerLeveledUp())
            {
                return;
            }
            if (PlayerDied())
            {
                return;
            }

            Dungeon.Update();
            AwardHandler.Update();
            GetAwards();
            NextLevel();
            PerformCombat();

            m_levelTimer.Update();
            m_healthBar.UpdateValues((int)Dungeon.MainPlayer.MaxMana, (int)Dungeon.MainPlayer.HealthMana);
            m_attackBar.UpdateValues((int)Dungeon.MainPlayer.MaxMana, (int)Dungeon.MainPlayer.AttackMana);
            m_healthBar.Update();
            m_attackBar.Update();
            m_scoring.Update();
            m_statBox.GenerateStats(Dungeon.MainPlayer);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Moves the player in the dungeon using
        ///	the input class, dungeon class, and
        ///	the user's given input.
        /// </summary>
        private static void UpdatePlayerMovement()
        {
            Input.GetInput();

            switch (Input.CurrentDirection)
            {
            case Input.Direction.North:
                if (CanMove(MainPlayer, -1, 0))
                {
                    AudioManager.NewPlayerWalk();
                    AwardHandler.NewStep();
                    MoveEntity(MainPlayer, -1, 0);
                    if (Grid[MainPlayer.Y][MainPlayer.X].Door != null)
                    {
                        Grid[MainPlayer.Y][MainPlayer.X].Door.OpenDoor();
                    }
                }
                break;

            case Input.Direction.South:
                if (CanMove(MainPlayer, 1, 0))
                {
                    AudioManager.NewPlayerWalk();
                    AwardHandler.NewStep();
                    MoveEntity(MainPlayer, 1, 0);
                    if (Grid[MainPlayer.Y][MainPlayer.X].Door != null)
                    {
                        Grid[MainPlayer.Y][MainPlayer.X].Door.OpenDoor();
                    }
                }
                break;

            case Input.Direction.East:
                if (CanMove(MainPlayer, 0, 1))
                {
                    AudioManager.NewPlayerWalk();
                    AwardHandler.NewStep();
                    MoveEntity(MainPlayer, 0, 1);
                    if (Grid[MainPlayer.Y][MainPlayer.X].Door != null)
                    {
                        Grid[MainPlayer.Y][MainPlayer.X].Door.OpenDoor();
                    }
                }
                break;

            case Input.Direction.West:
                if (CanMove(MainPlayer, 0, -1))
                {
                    AudioManager.NewPlayerWalk();
                    AwardHandler.NewStep();
                    MoveEntity(MainPlayer, 0, -1);
                    if (Grid[MainPlayer.Y][MainPlayer.X].Door != null)
                    {
                        Grid[MainPlayer.Y][MainPlayer.X].Door.OpenDoor();
                    }
                }
                break;
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Kills a monster and takes away its data
 ///	from the dungeon and World.
 /// </summary>
 private void KillMonster()
 {
     // Add xp to the player
     m_player.Xp += m_target.Xp;
     m_monsters.Remove(m_target);
     Dungeon.KillEntity(m_target);
     AwardHandler.NewKill();
 }
Ejemplo n.º 4
0
        // ======================================
        // =========== Main Methods =============
        // ======================================

        #region World Methods

        /// <summary>
        /// Initializes internal data.
        /// </summary>
        public static void Init()
        {
            Dungeon.Init();
            AwardHandler.Init();
            m_combat             = new Combat();
            m_statBox            = new StatBox();
            m_levelTimer         = new Timer(120 * 60);
            m_healthBar          = new ProgressBar("Health Mana");
            m_attackBar          = new ProgressBar("Attack Mana");
            m_scoring            = new Scoring();
            m_healthBar.Position = new Vector2(10, 10);
            m_attackBar.Position = new Vector2(10, 40);
            m_healthBar.Init((int)Dungeon.MainPlayer.MaxMana, (int)Dungeon.MainPlayer.HealthMana);
            m_attackBar.Init((int)Dungeon.MainPlayer.MaxMana, (int)Dungeon.MainPlayer.AttackMana);
            m_combat.PerformCombat(Dungeon.MainPlayer, Dungeon.Monsters);
            m_levelTimer.PerformAction();
            m_statBox.GenerateStats(Dungeon.MainPlayer);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Determines if a player is currently
        ///	regenerating health or mana.
        /// </summary>
        public void PlayerRegen()
        {
            switch (Input.PlayerState)
            {
            case Input.EPlayerState.Healing:
                if (m_player.CanHeal())
                {
                    m_player.RegenerateHealth();
                }
                break;

            case Input.EPlayerState.Charging:
                m_player.RegenerateMana();
                AwardHandler.NewRegen();
                break;
            }

            Input.PlayerState = Input.EPlayerState.None;
        }
Ejemplo n.º 6
0
    void InstantiateGridAwards()
    {
        closedCount = 0;
        miniCount   = 0;
        minorCount  = 0;
        majorCount  = 0;
        grandCount  = 0;
        for (int i = 0; i < GridLayoutManager.gridLayoutManager.rowCount; i++)
        {
            for (int j = 0; j < GridLayoutManager.gridLayoutManager.columnCount; j++)
            {
                Transform tartetTransform = GameConstants.gameConstants.awardClosedPregfab;
                Debug.Log("testing for key " + (i + "" + j));
                Debug.Log("grid state has " + gridState.Count + " elements");
                switch (gridState[(i + "" + j)])
                {
                case jackpotState.closed:
                    tartetTransform = GameConstants.gameConstants.awardClosedPregfab;
                    closedCount++;
                    break;

                case jackpotState.Mini:
                    tartetTransform = GameConstants.gameConstants.awardMiniPrefab;
                    miniCount++;
                    break;

                case jackpotState.Minor:
                    tartetTransform = GameConstants.gameConstants.awardMinorPrefab;
                    minorCount++;
                    break;

                case jackpotState.Major:
                    tartetTransform = GameConstants.gameConstants.awardMajorPrefab;
                    majorCount++;
                    break;

                case jackpotState.Grand:
                    tartetTransform = GameConstants.gameConstants.awardGrandPrefab;
                    grandCount++;
                    break;

                default:
                    tartetTransform = GameConstants.gameConstants.awardClosedPregfab;
                    closedCount++;
                    Debug.Log("unable to find the key : " + (i + "" + j));

                    break;
                }

                //create a new closed award
                GameObject newAward = Instantiate(
                    tartetTransform.gameObject,
                    GridLayoutManager.gridLayoutManager.transform);

                RectTransform newRectTransform = newAward.GetComponent <RectTransform>();
                RectTransform gridPosTransform = GridLayoutManager.gridLayoutManager.getGridElement(i, j).GetComponent <RectTransform>();
                newRectTransform.anchorMin        = gridPosTransform.anchorMin;
                newRectTransform.anchorMax        = gridPosTransform.anchorMax;
                newRectTransform.anchoredPosition = gridPosTransform.anchoredPosition;
                newRectTransform.sizeDelta        = gridPosTransform.sizeDelta;
                createdObjects.Add(newAward);

                if (!newAward.activeSelf)
                {
                    newAward.SetActive(true);
                }
                AwardHandler newAwardHandler = newRectTransform.GetComponent <AwardHandler>();
                if (newAwardHandler != null)
                {
                    newRectTransform.GetComponent <AwardHandler>().rowVal    = i;
                    newRectTransform.GetComponent <AwardHandler>().columnVal = j;
                }
            }
        }
    }