예제 #1
0
파일: Opponent.cs 프로젝트: mbg/FSEGame
        /// <summary>
        /// Initialises a new instance of this class.
        /// </summary>
        public Opponent(CharacterAttributes attributes)
        {
            // :: Since the base attributes won't change, we can just
            // :: use the obtained reference for them. However, the current
            // :: attributes may change during battle so we have to initialise
            // :: a new variable for it.
            this.baseAttributes = attributes;
            this.currentAttributes = new CharacterAttributes();

            this.currentAttributes.Health = attributes.Health;
            this.currentAttributes.Strength = attributes.Strength;
            this.currentAttributes.Defence = attributes.Defence;
            this.currentAttributes.Magic = attributes.Magic;

            this.moves = new List<IMove>();
        }
예제 #2
0
 /// <summary>
 /// Initialises a new instance of this class.
 /// </summary>
 public PlayerCharacter(CharacterAttributes attributes)
     : base(attributes)
 {
     this.Name = "Landor";
 }
예제 #3
0
파일: FSEGame.cs 프로젝트: mbg/FSEGame
        /// <summary>
        /// Starts a new game.
        /// </summary>
        public void NewGame()
        {
            // :: Change the game state and make sure that no level
            // :: is loaded so that we have a black background.
            this.state = GameState.Intro;

            this.CurrentLevel.Unload();
            this.mainMenu.Hide();

            // :: Initialise a new player character.
            CharacterAttributes playerAttributes = new CharacterAttributes();
            playerAttributes.Health = 100;
            playerAttributes.Defence = 2;
            playerAttributes.Strength = 15;
            playerAttributes.Magic = 50;

            this.playerCharacter = new PlayerCharacter(playerAttributes);
            this.playerCharacter.Moves.Add(new MeleeAttack());

            // :: Temporarily change the dialogue event handlers so that
            // :: they don't change the game state to Exploring / Cutscene.
            DialogueEventDelegate introEndDelegate = null;

            introEndDelegate = new DialogueEventDelegate(delegate
            {
                this.DialogueManager.OnEnd -= introEndDelegate;
                this.DialogueManager.OnStart += this.dialogueStartDelegate;
                this.DialogueManager.OnEnd += this.dialogueEndDelegate;

                this.LoadLevel(@"Levels\PlayerHouse.xml", "Default", false);
                this.character.Enabled = false;

                FadeScreenEventDelegate fadeEndEvent = null;
                fadeEndEvent = new FadeScreenEventDelegate(delegate
                {
                    this.fadeScreen.Finished -= fadeEndEvent;
                    this.fadeScreen.Enabled = false;
                    this.fadeScreen.Visible = false;

                    this.character.Enabled = true;
                    this.state = GameState.Exploring;
                });

                this.fadeScreen.Finished += fadeEndEvent;
                this.fadeScreen.Visible = true;
                this.fadeScreen.Enabled = true;
                this.fadeScreen.FadeOut(1.0d);

                this.state = GameState.LevelTransition;
            });

            this.DialogueManager.OnStart -= this.dialogueStartDelegate;
            this.DialogueManager.OnEnd -= this.dialogueEndDelegate;
            this.DialogueManager.OnEnd += introEndDelegate;

            this.DialogueManager.PlayDialogue(@"FSEGame\Dialogues\Intro.xml");
        }
예제 #4
0
파일: FSEGame.cs 프로젝트: mbg/FSEGame
        /// <summary>
        /// Loads the game state from the slot with the specified ID.
        /// </summary>
        /// <param name="slot">The ID of the save slot to load the game state from.</param>
        public void LoadGame(Byte slot)
        {
            String path = Path.Combine(
                this.savesFolder, String.Format("Slot{0}.sav", slot));

            using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read))
            using (BinaryReader br = new BinaryReader(fs))
            {
                Byte version = br.ReadByte();

                if (version != 0x01)
                    throw new Exception("!!! Invalid save file");

                String levelFilename = br.ReadString();

                this.CurrentLevel.Load(this.Content, levelFilename);

                this.character.CellPosition = new Vector2(
                    br.ReadSingle(), br.ReadSingle());
                this.character.Orientation = br.ReadSingle();

                // :: Load the player character's attributes.
                CharacterAttributes baseAttributes = new CharacterAttributes();
                CharacterAttributes currentAttributes = new CharacterAttributes();

                baseAttributes.LoadFromBinary(br);
                currentAttributes.LoadFromBinary(br);

                // :: Initialise the player character using the attributes obtained
                // :: previously.
                this.playerCharacter = new PlayerCharacter(baseAttributes);
                this.playerCharacter.CurrentAttributes = currentAttributes;

                // ::
                Int32 moveCount = br.ReadInt32();

                for (Int32 i = 0; i < moveCount; i++)
                {
                    this.playerCharacter.Moves.Add(
                        MoveHelper.CreateFromName(br.ReadString()));
                }

                // :: Load the persistent storage data. The persistent storage
                // :: contains quest status information, etc.
                this.PersistentStorage.Load(br);

                // :: Hide the menues and enable the character controller.
                this.mainMenu.Hide();
                this.loadScreen.Hide();

                this.state = GameState.Exploring;
                this.character.Enabled = true;
            }
        }
예제 #5
0
파일: Battle.cs 프로젝트: mbg/FSEGame
        /// <summary>
        /// Loads an opponent from the data contained in the specified XML element.
        /// </summary>
        /// <param name="element"></param>
        private void LoadOpponent(XmlElement element)
        {
            CharacterAttributes attributes = new CharacterAttributes();
            List<IMove> moves = new List<IMove>();

            foreach (XmlNode childNode in element.ChildNodes)
            {
                if (childNode.NodeType != XmlNodeType.Element)
                    continue;

                XmlElement childElement = (XmlElement)childNode;

                if (childElement.Name.Equals("Attributes"))
                {
                    attributes.LoadFromXML(childElement);
                }
                else if (childElement.Name.Equals("Moves"))
                {
                    foreach (XmlNode moveNode in childElement.ChildNodes)
                    {
                        if (moveNode.NodeType != XmlNodeType.Element)
                            continue;

                        XmlElement moveElement = (XmlElement)moveNode;

                        if (moveElement.Name.Equals("Move"))
                        {
                            moves.Add(MoveHelper.CreateFromName(moveElement.GetAttribute("Type")));
                        }
                    }
                }
            }

            Opponent opponent = new Opponent(attributes);
            opponent.Name = element.GetAttribute("Name");
            opponent.IsBoss = Convert.ToBoolean(element.GetAttribute("IsBoss"));
            opponent.TilesetFilename = element.GetAttribute("Tileset");
            opponent.PositionName = element.GetAttribute("Position");

            foreach (IMove move in moves)
                opponent.Moves.Add(move);

            this.opponents.Enqueue(opponent);
        }