Exemple #1
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            UpdateState();
            color = DataConversionLibrary.GetSquareColor(data.enemyType);

            if (IsTargeted())
            {
                MapCreatorGUI.SetTargetedSquare(this);
            }
        }
        public MapCreatorState(Game1 game, string name) :
            base(game, name)
        {
            stringLibrary = new DataConversionLibrary();

            actions     = new List <Action>();
            deadActions = new List <Action>();
            smallFont   = game.Content.Load <SpriteFont>("Fonts/Iceland_12");
            spriteSheet = new Sprite(game.Content.Load <Texture2D>("MapCreator/MapCreatorSpriteSheet"));

            cursorSprite = spriteSheet.GetSubSprite(new Rectangle(99, 35, 16, 16));
        }
        public override string ToString()
        {
            String returnString = base.ToString();

            returnString += DataConversionLibrary.GetDurationStringFromEnum(durationEventType);

            if (enemyType != EnemyType.none)
            {
                returnString += EventEditor.GetSaveString(eventData.eventSettings);
            }

            return(returnString);
        }
        private void CreateDurationEvent(String state, float startTime, float endTime)
        {
            state = Regex.Replace(state, " ", "");

            String enemyData    = state.Substring(0, 1);
            String movementData = state.Substring(1, 2);
            String eventData    = state.Substring(3, 1);

            SortedDictionary <string, int> settings = new SortedDictionary <string, int>();

            MatchCollection matches = Regex.Matches(state, @"([A-Z])(\d+)");

            foreach (Match match in matches)
            {
                String letter      = match.Groups[1].Value;
                String valueString = match.Groups[2].Value;
                int    value       = Convert.ToInt32(valueString);
                settings.Add(letter, value);
            }
            //String enemy = SaveLoadStringLibrary.GetEnemyTypeFromSaveString(enemyData);
            String    enemy      = enemyData;
            EnemyType identifier = DataConversionLibrary.GetEnemyEnumFromString(enemy);
            Movement  movement   = DataConversionLibrary.GetMovementEnumFromString(movementData);

            switch (eventData)
            {
            case "E":
            {
                int density = settings["D"];

                LevelEvent lvEv = new EvenSwarm(Game, player, spriteSheet, this, identifier, 1000 * startTime,
                                                1000 * (endTime - startTime), density);
                SetMovement(lvEv, movement);
                untriggeredEvents.Add(lvEv);
                break;
            }

            case "G":
            {
                int startDensity = settings["S"];
                int peakDensity  = settings["P"];
                int peakTime     = settings["T"];

                LevelEvent lvEv = new GradientSwarm(Game, player, spriteSheet, this, identifier, 1000 * startTime,
                                                    1000 * (endTime - startTime), peakTime, startDensity, peakDensity);
                SetMovement(lvEv, movement);
                untriggeredEvents.Add(lvEv);
                break;
            }
            }
        }
 private void SetEvent(String eventString)
 {
     durationEventType = DataConversionLibrary.GetDurationEnumFromString(eventString);
 }
        private void CreatePointEvent(String state, float pos, float time)
        {
            //To prevent enemies at position 0 from being removed
            if (pos == 0)
            {
                pos = 1;
            }
            //

            String enemyData    = state.Substring(0, 1);
            String movementData = state.Substring(1, 2);
            String eventData    = state.Substring(3, 1);

            SortedDictionary <string, int> settings = new SortedDictionary <string, int>();

            MatchCollection matches = Regex.Matches(state, @"([XYWHD])(\d+)");

            foreach (Match match in matches)
            {
                String letter      = match.Groups[1].Value;
                String valueString = match.Groups[2].Value;
                int    value       = Convert.ToInt32(valueString);
                settings.Add(letter, value);
            }
            //String enemy = SaveLoadStringLibrary.GetEnemyTypeFromSaveString(enemyData);
            String    enemy      = enemyData;
            EnemyType identifier = DataConversionLibrary.GetEnemyEnumFromString(enemy);
            Movement  movement   = DataConversionLibrary.GetMovementEnumFromString(movementData);

            #region switchEventData
            switch (eventData)
            {
            case "0":
            {
                LevelEvent lvEv = new SingleEnemy(Game, player, spriteSheet, this, identifier, time, pos);
                SetMovement(lvEv, movement);
                untriggeredEvents.Add(lvEv);
                break;
            }

            // The horizontal event forces a horizontal movement
            case "h":
            {
                int direction = settings["D"];
                int yPos      = settings["Y"];

                LevelEvent lvEv = new SingleHorizontalEnemy(Game, player, spriteSheet, this, identifier, time, direction, yPos);

                if (direction == 1)
                {
                    SetMovement(lvEv, Movement.RightHorizontal);
                }
                else
                {
                    SetMovement(lvEv, Movement.LeftHorizontal);
                }

                untriggeredEvents.Add(lvEv);
                break;
            }

            case "l":
            {
                int        width    = settings["W"];
                int        xspacing = settings["X"];
                LevelEvent lvEv     = new LineFormation(Game, player, spriteSheet, this, identifier, time, width, xspacing, pos);

                SetMovement(lvEv, movement);

                untriggeredEvents.Add(lvEv);
                break;
            }

            case "s":
            {
                int        width    = settings["W"];
                int        xspacing = settings["X"];
                int        height   = settings["H"];
                int        yspacing = settings["Y"];
                LevelEvent lvEv     = new SquareFormation(Game, player, spriteSheet, this, identifier, time, width, height, xspacing, yspacing, pos);

                SetMovement(lvEv, movement);

                untriggeredEvents.Add(lvEv);
                break;
            }

            case "t":
            {
                int        height   = settings["H"];
                int        xspacing = settings["X"];
                int        yspacing = settings["Y"];
                LevelEvent lvEv     = new VFormation(Game, player, spriteSheet, this, identifier, time, height, xspacing, yspacing, pos);

                SetMovement(lvEv, movement);

                untriggeredEvents.Add(lvEv);
                break;
            }
            }
            #endregion
        }
Exemple #7
0
 private void SetEvent(String eventString)
 {
     pointEventType = DataConversionLibrary.GetPointEnumFromString(eventString);
 }
Exemple #8
0
 public override void Update(GameTime gameTime)
 {
     base.Update(gameTime);
     color = DataConversionLibrary.GetSquareColor(ActiveData.enemyState);
 }
Exemple #9
0
 protected void SetMovement(String movementString)
 {
     movement = DataConversionLibrary.GetMovementEnumFromString(movementString);
 }
Exemple #10
0
 protected void SetEnemy(String enemyString)
 {
     enemyType = DataConversionLibrary.GetEnemyEnumFromString(enemyString);
 }