コード例 #1
0
ファイル: Knight.cs プロジェクト: jtan189/Armalia
 public Knight(AnimatedSprite sprite, Vector2 position, int hitPoints, int manaPoints,
     int expLevel, int strength, int defense, Vector2 speed, List<Vector2> patrolTargets, MainCharacter mainCharacter,
     GameplayScreen gameplayScreen)
     : base(sprite, position, hitPoints, manaPoints, expLevel, strength, defense, speed,
     patrolTargets, mainCharacter, gameplayScreen)
 {
 }
コード例 #2
0
ファイル: GameLevel.cs プロジェクト: jtan189/Armalia
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="name">Name of the level.</param>
 /// <param name="levelMap">The map object to instantiate the level with.</param>
 /// <param name="bgMusic">Background music for the level.</param>
 /// <param name="enemies">Enemies located in the level.</param>
 /// <param name="levelObjects">Objects located in the level.</param>
 /// <param name="playerCharacter">Player's character in the level.</param>
 public GameLevel(string name, Map levelMap, Song bgMusic, MainCharacter playerCharacter, List<EnemyCharacter> enemies, List<LevelObject> levelObjects)
 {
     this.LevelMap = levelMap;
     this.bgMusic = bgMusic;
     this.Enemies = enemies;
     this.name = name;
     this.LevelObjects = levelObjects;
     this.PlayerCharacter = playerCharacter;
 }
コード例 #3
0
ファイル: EnemyCharacter.cs プロジェクト: jtan189/Armalia
        public EnemyCharacter(AnimatedSprite sprite, Vector2 position, int hitPoints, int manaPoints,
            int expLevel, int strength, int defense, Vector2 speed,
            List<Vector2> patrolTargets, MainCharacter mainCharacter, GameplayScreen gameplayScreen)
            : base(sprite, position, hitPoints, manaPoints, expLevel, strength, defense, speed, gameplayScreen)
        {
            this.patrolTargets = patrolTargets;
            this.PlayerCharacter = mainCharacter;

            DirectionStuckIn = MoveDirection.None;
            UnstickAttempts = 0;
            randomMover = new Random();

            currentState = EnemyState.Patrol;
            currentTarget = patrolTargets[0];
        }
コード例 #4
0
ファイル: LevelManager.cs プロジェクト: jtan189/Armalia
        public LevelManager(ArmaliaGame game, MainCharacter playerCharacter, GameplayScreen gameplayScreen)
        {
            this.game = game;
            this.gameplayScreen = gameplayScreen;
            this.mapMaker = new MapMaker(game, this);
            this.playerCharacter = playerCharacter;

            mapFiles = new Dictionary<string, string>();
            songFiles = new Dictionary<string, string>();
            gameLevels = new Dictionary<string, GameLevel>();

            mapFiles.Add("Building1", @"Maps\Building1\Building1");
            mapFiles.Add("Village0", @"Maps\Village0\Village0");
            mapFiles.Add("Forest1", @"Maps\Forest1\Forest1");
            mapFiles.Add("Forest2", @"Maps\Forest2\Forest2");
            mapFiles.Add("Forest3", @"Maps\Forest3\Forest3");
            mapFiles.Add("Cave0", @"Maps\Cave0\Cave0");
            mapFiles.Add("Building2", @"Maps\Building2\Building2");
            mapFiles.Add("Building3", @"Maps\Building3\Building3");
            songFiles.Add("Village0", @"Music\Home");

            LoadLevels();
        }
コード例 #5
0
ファイル: MapMaker.cs プロジェクト: jtan189/Armalia
        public List<EnemyCharacter> GetEnemies(String mapFilename, MainCharacter mainCharacter, GameplayScreen gameplayScreen)
        {
            var mapXML = XElement.Load(game.Content.RootDirectory + "\\" + mapFilename + ".tmx");
            var objectElements = mapXML.Elements("objectgroup").Elements().ToList();

            List<EnemyCharacter> enemies = new List<EnemyCharacter>();
            foreach (var obj in objectElements)
            {
                string type = null;
                if (obj.Attribute("type") != null)
                {
                    type = obj.Attribute("type").Value.ToString().ToLower();
                }
                if (type != null && type.Equals("enemy"))
                {
                    var properties = obj.Elements("properties").Elements().ToList();
                    string name = obj.Attribute("name").Value.ToString().ToLower();

                    // default attributes
                    int hp = 100;
                    int mp = 100;
                    int xp = 0;
                    int strength = 10;
                    int defense = 10;

                    int xcoord = Convert.ToInt32(obj.Attribute("x").Value);
                    int ycoord = Convert.ToInt32(obj.Attribute("y").Value);
                    foreach (var prop in properties)
                    {
                        string propName = prop.Attribute("name").ToString().ToLower();
                        switch (propName)
                        {
                            case "strength":
                                strength = Convert.ToInt32(prop.Attribute("value").Value);
                                break;
                            case "hp":
                                hp = Convert.ToInt32(prop.Attribute("value").Value);
                                break;
                            case "mp":
                                mp = Convert.ToInt32(prop.Attribute("value").Value);
                                break;
                            case "defense":
                                defense = Convert.ToInt32(prop.Attribute("value").Value);
                                break;
                            case "xp":
                                xp = Convert.ToInt32(prop.Attribute("value").Value);
                                break;
                        }
                    }

                    switch (name.ToLower())
                    {
                        case "knight":
                            Texture2D knightTexture = game.Content.Load<Texture2D>(@"Characters\charchip01-2-1");
                            Point knightTextureFrameSize = new Point(32, 32);
                            int knightCollisionOffset = 0;
                            Point knightInitialFrame = new Point(1, 0);
                            Point knightSheetSize = new Point(3, 4);
                            Vector2 knightSpeed = new Vector2(1, 1);
                            Vector2 initialKnightPos = new Vector2(xcoord, ycoord);

                            AnimatedSprite knightSprite = new AnimatedSprite(
                                knightTexture, knightTextureFrameSize, knightCollisionOffset, knightInitialFrame, knightSheetSize);

                            List<Vector2> knightTargets = new List<Vector2>() {
                                new Vector2(xcoord - 100, ycoord), new Vector2(xcoord + 100, ycoord) };

                            EnemyCharacter knightEnemy = new Knight(knightSprite, initialKnightPos, hp, mp, xp,
                                strength, defense, knightSpeed, knightTargets, mainCharacter, gameplayScreen);

                            Texture2D knightSwordTexture = game.Content.Load<Texture2D>(@"Attacks\small_sword");
                            int knightSwordMsPerFrame = 16;
                            float knightSwordScale = 0.4f;
                            Vector2 knightSwordRotationPoint = new Vector2(7, 150);

                            SwordSprite knightSwordSprite = new SwordSprite(knightSwordTexture, knightSwordMsPerFrame, knightSwordScale,
                                knightSwordRotationPoint, knightEnemy);
                            knightEnemy.Sword = knightSwordSprite;

                            enemies.Add(knightEnemy);

                            break;
                    }
                }
            }

            return enemies;
        }
コード例 #6
0
ファイル: LevelObject.cs プロジェクト: jtan189/Armalia
 public bool Collides(MainCharacter mainChar)
 {
     return objectRect.Intersects(mainChar.AsRectangle());
 }
コード例 #7
0
ファイル: Player.cs プロジェクト: jtan189/Armalia
 public Player(MainCharacter character, GameplayScreen gameplayScreen)
 {
     PlayerCharacter = character;
     this.gameplayScreen = gameplayScreen;
 }