예제 #1
0
파일: Executor.cs 프로젝트: iooc/cfms
        /// <summary>
        /// 递归加载池道子集
        /// </summary>
        /// <param name="set">池道根节点</param>
        /// <param name="item">池道根元素</param>
        internal static void LoadSubLaneSet(LaneSet set, XElement item, Process process)
        {
            // 道结构
            var lanes = item.Elements("lane");

            foreach (var laneElem in lanes)
            {
                var lane = new Lane
                {
                    Id   = laneElem.Attribute("id").Value,
                    Name = laneElem.Attribute("name")?.Value
                };
                var refElems = laneElem.Elements("flowNodeRef");
                foreach (var elem in refElems)
                {
                    var @ref = process.FirstOrDefault(a => a.Id == elem.Value);
                    if (@ref != null)
                    {
                        lane.Add(@ref as FlowNode);
                    }
                }
                // 子集池道集合
                var sublaneSet = laneElem.Elements("childLaneSet");
                foreach (var subset in sublaneSet)
                {
                    var childLaneSet = new ChildLaneSet
                    {
                        Id = subset.Attribute("id").Value
                    };
                    LoadSubLaneSet(childLaneSet, subset, process);
                    lane.Add(childLaneSet);
                }
                set.Add(lane);
            }
        }
예제 #2
0
    /// <summary>
    /// Gets the new lane set.
    /// </summary>
    private void GetNewLaneSet()
    {
        // Determine the new lane set type
        LaneSet     prevLaneSet     = m_currentLaneSet;
        LaneSetType prevLaneSetType = prevLaneSet.Type;
        LaneSetType newLaneSetType  = prevLaneSetType;

        if (prevLaneSetType == LaneSetType.Grass)
        {
            // Non-grass lane set
            newLaneSetType = (LaneSetType)Random.Range((int)LaneSetType.Road, (int)LaneSetType.River + 1);
        }
        else
        {
            if (Random.value <= GetCurrentGrassSetProb())
            {
                // Grass lane set
                newLaneSetType = LaneSetType.Grass;
            }
            else
            {
                // Get a random lane set, except the one used previously
                while (newLaneSetType == prevLaneSetType)
                {
                    newLaneSetType = (LaneSetType)Random.Range((int)LaneSetType.REGULAR_START + 1,
                                                               (int)LaneSetType.REGULAR_END);
                }
            }
        }

        switch (newLaneSetType)
        {
        default:
        case LaneSetType.Grass:
            m_currentLaneSet = new GrassLaneSet(this, m_mapAssetPool,
                                                m_highestRowCoord, OnNewLaneCreated);
            break;

        case LaneSetType.Road:
            m_currentLaneSet = new RoadLaneSet(this, m_mapAssetPool,
                                               m_highestRowCoord, OnNewLaneCreated);
            break;

        case LaneSetType.Railroad:
            m_currentLaneSet = new RailroadLaneSet(this, m_mapAssetPool,
                                                   m_highestRowCoord, OnNewLaneCreated);
            break;

        case LaneSetType.River:
            m_currentLaneSet = new RiverLaneSet(this, m_mapAssetPool,
                                                m_highestRowCoord, OnNewLaneCreated);
            break;
        }
        m_currentLaneSet.SetPrevPassableTileArray(prevLaneSet.GetPrevPassableTileArray());
        m_currentLaneSet.SetPrevLaneDirection(prevLaneSet.GetPrevLaneDirection());
    }
예제 #3
0
        public GameState(Game1 game, GraphicsDevice graphicsDevice, ContentManager content) : base(game, graphicsDevice, content)
        {
            round      = 0;
            playerWins = 0;
            enemyWins  = 0;
            var        backgroundTexture = _content.Load <Texture2D>("Menu Backgrounds/Stone Brick Background");
            Background background        = new Background(backgroundTexture);

            var uiFont = _content.Load <SpriteFont>("Fonts/Font");

            player = new PlayerSouth(game);
            player.LoadContent(content);
            player.Initialize(180, 300);

            player2 = new PlayerNorth(game);
            player2.LoadContent(content);
            player2.Initialize(180, 300);

            var uiTexture = _content.Load <Texture2D>("Menu Backgrounds/ThirteenthBellUI_NoBackground");

            userInterface = new UserInterface(uiTexture, uiFont)
            {
                playerStackText = "Test Text", //Hopefully we'll be able to plug in the different player stats for these
                playerLifeText  = Convert.ToString(player.life),
                enemyStackText  = "Test Text",
                enemyLifeText   = Convert.ToString(player2.life),
                roundText       = round,
                playerText      = playerWins,
                enemyText       = enemyWins,
            };

            LaneSet laneSet = new LaneSet(_content, 0, 0, 0);

            stack      = new Stack(_content, 30, 0);
            enemyStack = new Stack(_content, 30, 1);

            playerHand = new PlayableCards(5, stack, 0, player, 0);
            enemyHand  = new PlayableCards(5, enemyStack, 1, player2, 1);

            _components = new List <Component>
            {
                background,
                userInterface,
                laneSet,
                stack,
                enemyStack,
                playerHand,
                enemyHand
            };
        }
예제 #4
0
    /// <summary>
    /// Starts creating the map.
    /// </summary>
    private void StartCreateMap()
    {
        // Deactivate previously used lanes
        foreach (Lane lane in m_activeLaneList)
        {
            lane.Deactivate();
        }
        m_activeLaneList.Clear();

        // Initialize variables
        m_currentLaneSet  = null;
        m_lowestRowCoord  = m_startRowCoord;
        m_highestRowCoord = m_startRowCoord;

        // Create the starting set
        m_currentLaneSet = new BeginningLaneSet(this, m_mapAssetPool, m_highestRowCoord, OnNewLaneCreated);
        m_currentLaneSet.CreateLanes(m_activeLaneCount - m_highestRowCoord + m_startRowCoord);

        // Fill up the screen with random sets
        FillUpMap(m_activeLaneCount - m_highestRowCoord + m_lowestRowCoord);
    }
예제 #5
0
        public RoundState(Game1 game, GraphicsDevice graphicsDevice, ContentManager content, int roundNumber, int pWins, int eWins, int wI, bool p) : base(game, graphicsDevice, content)
        {
            round        = roundNumber;
            winIndicator = wI;

            var buttonTexture = _content.Load <Texture2D>("Controls/Play Game");
            var buttonFont    = _content.Load <SpriteFont>("Fonts/Font");
            var otherFont     = _content.Load <SpriteFont>("Fonts/LargerFont");

            ri = new RoundIntro(buttonTexture, buttonFont)
            {
                Position = new Vector2(488, 300),
                Text     = "Round " + round + " starts on the 13th Bell \n" + "                        "
            };

            //Console.WriteLine("Round: " + round);
            playerWins = pWins;
            //Console.WriteLine("Player Wins: " + playerWins);
            enemyWins = eWins;
            //Console.WriteLine("Enemy Wins: " + enemyWins);
            List <Texture2D> uiBackgrounds = new List <Texture2D>();

            var    backgroundTexture  = _content.Load <Texture2D>("Menu Backgrounds/5"); uiBackgrounds.Add(backgroundTexture);
            var    backgroundTexture2 = _content.Load <Texture2D>("Menu Backgrounds/6"); uiBackgrounds.Add(backgroundTexture2);
            var    backgroundTexture3 = _content.Load <Texture2D>("Menu Backgrounds/4"); uiBackgrounds.Add(backgroundTexture3);
            Random r = new Random();

            Background background = new Background(uiBackgrounds.ElementAt(r.Next(uiBackgrounds.Count)));

            var uiFont = _content.Load <SpriteFont>("Fonts/Font");

            player = new PlayerSouth(game);
            player.LoadContent(content);
            player.Initialize(180, 300);

            player2 = new PlayerNorth(game);
            player2.LoadContent(content);
            player2.Initialize(180, 300);


            var uiTexture = _content.Load <Texture2D>("Menu Backgrounds/ThirteenthBellUI_NoBackground");

            particleTexture = _content.Load <Texture2D>("Particle");


            userInterface = new UserInterface(uiTexture, otherFont)
            {
                playerStackText = "",
                playerLifeText  = Convert.ToString(player.life),
                enemyStackText  = "",
                enemyLifeText   = Convert.ToString(player2.life),
                roundText       = round,
                playerText      = playerWins,
                enemyText       = enemyWins,
            };

            LaneSet laneSet = new LaneSet(_content, 0, 0, 0);

            stack      = new Stack(_content, 30, 0);
            enemyStack = new Stack(_content, 30, 1);

            playerHand = new PlayableCards(5, stack, 0, player, 0);
            enemyHand  = new PlayableCards(5, enemyStack, 1, player2, 1);

            _components = new List <Component>
            {
                background,
                userInterface,
                laneSet,
                stack,
                enemyStack,
                playerHand,
                enemyHand,
                ri,
            };

            Random random = new Random();

            //Load Rain Particle----------------------------------------------------------------
            rain = new ParticleSystem(graphicsDevice, 1000, particleTexture);
            rain.SpawnPerFrame = 2;
            rain.SpawnParticle = (ref Particle particle) =>
            {
                // MouseState mouse = Mouse.GetState();
                particle.Position = new Vector2(random.Next(0, GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width), 0);
                particle.Velocity = new Vector2(
                    MathHelper.Lerp(0, 1, (float)random.NextDouble()),   // X between -50 and 50
                    MathHelper.Lerp(0, 1042, (float)random.NextDouble()) // Y between 0 and 100
                    );
                particle.Acceleration = 0.1f * new Vector2(0, (float)-random.NextDouble());
                particle.Color        = Color.Aqua;
                particle.Scale        = 1f;
                particle.Life         = 1.0f;
            };
            // Set the UpdateParticle method
            rain.UpdateParticle = (float deltaT, ref Particle particle) =>
            {
                particle.Velocity += deltaT * particle.Acceleration;
                particle.Position += deltaT * particle.Velocity;
                particle.Scale    -= deltaT;
                particle.Life     -= deltaT;
            };

            playerHand.SetFalse();
            enemyHand.SetFalse();
        }