├── DreamStateMachine ├── Icon.ico ├── Game │ ├── Actor │ │ ├── Stance.cs │ │ ├── Animation.cs │ │ ├── DamageInfo.cs │ │ ├── AnimationInfo.cs │ │ ├── Animations │ │ │ ├── Recoil.cs │ │ │ ├── Idle.cs │ │ │ ├── Walk.cs │ │ │ └── Attack.cs │ │ ├── Weapon.cs │ │ ├── ActorController.cs │ │ └── ActorManager.cs │ ├── World │ │ ├── IUseable.cs │ │ ├── EnemyConfig.cs │ │ ├── SpawnFlag.cs │ │ ├── TraceInfo.cs │ │ ├── WorldConfig.cs │ │ ├── Room.cs │ │ ├── Key.cs │ │ ├── Door.cs │ │ ├── WeaponItem.cs │ │ ├── Potion.cs │ │ ├── Prop.cs │ │ └── PropManager.cs │ ├── AI │ │ ├── Behavior.cs │ │ ├── Behaviors │ │ │ ├── Stunned.cs │ │ │ ├── Neutral.cs │ │ │ ├── Alert.cs │ │ │ ├── Pursue.cs │ │ │ ├── Wander.cs │ │ │ └── Aggravated.cs │ │ ├── PathNode.cs │ │ └── AIController.cs │ ├── Input │ │ ├── Command.cs │ │ ├── UseCommand.cs │ │ ├── PunchCommand.cs │ │ ├── GazeCommand.cs │ │ ├── DebugCommand.cs │ │ ├── RotateWeaponCommand.cs │ │ ├── MoveCommand.cs │ │ └── InputHandler.cs │ ├── Events │ │ ├── AttackEventArgs.cs │ │ ├── PickupEventArgs.cs │ │ ├── SpawnEventArgs.cs │ │ └── InputEventArgs.cs │ ├── Rendering │ │ ├── IDrawable.cs │ │ └── Camera.cs │ ├── GUI │ │ ├── MovingLabel.cs │ │ ├── FadingLabel.cs │ │ ├── Label.cs │ │ ├── WorldLabel.cs │ │ ├── Button.cs │ │ ├── HealthBar.cs │ │ ├── Panel.cs │ │ └── UIComponent.cs │ ├── Sound │ │ ├── Sound.cs │ │ └── SoundManager.cs │ └── Physics │ │ └── Items │ │ └── ItemManager.cs ├── Program.cs ├── Libs │ ├── Tree │ │ ├── Tree.cs │ │ ├── NodeList.cs │ │ └── Node.cs │ └── ActionList │ │ ├── Action.cs │ │ └── ActionList.cs ├── Properties │ └── AssemblyInfo.cs └── DreamStateMachine.csproj ├── DSMContentProject ├── DSMContentProcessor │ ├── Steps.mp3 │ ├── block.png │ ├── bone.png │ ├── door.png │ ├── fish.png │ ├── key.png │ ├── sword.png │ ├── DSMLogo.png │ ├── bigDoor.png │ ├── exitBtn.png │ ├── iceBone.png │ ├── icicle.png │ ├── potion.png │ ├── GoodNight.mp3 │ ├── GrassFloor.png │ ├── hellTiles.png │ ├── keyBlade.png │ ├── larryBlade.png │ ├── larryKey.png │ ├── nightSky.png │ ├── sfx │ │ ├── Jump 2.wav │ │ ├── Menu.wav │ │ ├── death.wav │ │ ├── hurt1.wav │ │ ├── pickUp.wav │ │ ├── Explosion 1.wav │ │ ├── Explosion 3.wav │ │ ├── wooshSwing.wav │ │ └── fiery take off.wav │ ├── titlePanel.png │ ├── LumiasGrove.mp3 │ ├── SpriteFont1.xnb │ ├── TempleFloor.png │ ├── TundraFloor.png │ ├── debugSquare.png │ ├── dungeonFloor.png │ ├── splashScreen.png │ ├── whiteSquare.png │ ├── exitGamebutton.png │ ├── golemAnimations.png │ ├── newGameButton.png │ ├── slimeAnimations.png │ ├── CrystallineDreams.mp3 │ ├── creditsBtnFocused.png │ ├── newGameBtnFocused.png │ ├── penguinAnimations.png │ ├── creditsBtnUnfocused.png │ ├── dreamManAnimations.png │ ├── golemAnimationsGreen.png │ ├── golemAnimationsPink.png │ ├── golemAnimationsRed.png │ ├── newGameBtnUnfocused.png │ ├── newGameButtonFocused.png │ ├── skeletonAnimations.png │ ├── tutorialBtnFocused.png │ ├── tutorialBtnUnfocused.png │ ├── skeletonAnimationsBlue.png │ ├── skeletonAnimationsMask.png │ ├── skeletonAnimationsPink.png │ ├── skeletonAnimationsRed.png │ ├── protagonistBodyAnimations.png │ ├── skeletonAnimationsGreen.png │ ├── enemyHealthBarTransparency.png │ ├── playerHealthBarTransparency.png │ ├── StainedGlassAndSpookySkeletons.mp3 │ ├── Music.xml │ ├── Sounds.xml │ ├── Worlds.xml │ ├── Props.xml │ ├── Weapons.xml │ ├── Animations.xml │ └── Actors.xml └── DSMWindowsContent │ └── DSMWindowsContent.csproj ├── .gitignore ├── README.md └── DreamStateMachineProject.sln /DreamStateMachine/Icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DreamStateMachine/Icon.ico -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/Steps.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/Steps.mp3 -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/block.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/block.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/bone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/bone.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/door.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/door.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/fish.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/fish.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/key.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/key.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/sword.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/sword.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/DSMLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/DSMLogo.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/bigDoor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/bigDoor.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/exitBtn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/exitBtn.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/iceBone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/iceBone.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/icicle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/icicle.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/potion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/potion.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/GoodNight.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/GoodNight.mp3 -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/GrassFloor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/GrassFloor.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/hellTiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/hellTiles.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/keyBlade.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/keyBlade.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/larryBlade.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/larryBlade.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/larryKey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/larryKey.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/nightSky.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/nightSky.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/sfx/Jump 2.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/sfx/Jump 2.wav -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/sfx/Menu.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/sfx/Menu.wav -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/sfx/death.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/sfx/death.wav -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/sfx/hurt1.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/sfx/hurt1.wav -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/sfx/pickUp.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/sfx/pickUp.wav -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/titlePanel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/titlePanel.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/LumiasGrove.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/LumiasGrove.mp3 -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/SpriteFont1.xnb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/SpriteFont1.xnb -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/TempleFloor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/TempleFloor.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/TundraFloor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/TundraFloor.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/debugSquare.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/debugSquare.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/dungeonFloor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/dungeonFloor.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/splashScreen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/splashScreen.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/whiteSquare.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/whiteSquare.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/exitGamebutton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/exitGamebutton.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/golemAnimations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/golemAnimations.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/newGameButton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/newGameButton.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/sfx/Explosion 1.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/sfx/Explosion 1.wav -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/sfx/Explosion 3.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/sfx/Explosion 3.wav -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/sfx/wooshSwing.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/sfx/wooshSwing.wav -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/slimeAnimations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/slimeAnimations.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/CrystallineDreams.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/CrystallineDreams.mp3 -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/creditsBtnFocused.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/creditsBtnFocused.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/newGameBtnFocused.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/newGameBtnFocused.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/penguinAnimations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/penguinAnimations.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/creditsBtnUnfocused.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/creditsBtnUnfocused.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/dreamManAnimations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/dreamManAnimations.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/golemAnimationsGreen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/golemAnimationsGreen.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/golemAnimationsPink.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/golemAnimationsPink.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/golemAnimationsRed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/golemAnimationsRed.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/newGameBtnUnfocused.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/newGameBtnUnfocused.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/newGameButtonFocused.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/newGameButtonFocused.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/sfx/fiery take off.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/sfx/fiery take off.wav -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/skeletonAnimations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/skeletonAnimations.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/tutorialBtnFocused.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/tutorialBtnFocused.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/tutorialBtnUnfocused.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/tutorialBtnUnfocused.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/skeletonAnimationsBlue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/skeletonAnimationsBlue.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/skeletonAnimationsMask.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/skeletonAnimationsMask.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/skeletonAnimationsPink.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/skeletonAnimationsPink.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/skeletonAnimationsRed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/skeletonAnimationsRed.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/protagonistBodyAnimations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/protagonistBodyAnimations.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/skeletonAnimationsGreen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/skeletonAnimationsGreen.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/enemyHealthBarTransparency.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/enemyHealthBarTransparency.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/playerHealthBarTransparency.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/playerHealthBarTransparency.png -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/StainedGlassAndSpookySkeletons.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/connorclockwise/DreamStateMachine/HEAD/DSMContentProject/DSMContentProcessor/StainedGlassAndSpookySkeletons.mp3 -------------------------------------------------------------------------------- /DreamStateMachine/Game/Actor/Stance.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework.Graphics; 6 | using Microsoft.Xna.Framework; 7 | 8 | namespace DreamStateMachine 9 | { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/World/IUseable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using DreamStateMachine; 6 | 7 | namespace DreamStateMachine2.game.World 8 | { 9 | interface IUseable 10 | { 11 | void Use(Actor actor); 12 | bool CanUse(Actor actor); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/AI/Behavior.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework; 6 | 7 | namespace DreamStateMachine 8 | { 9 | abstract class Behavior:Action 10 | { 11 | public List path; 12 | public Point nextPathPoint; 13 | }; 14 | } 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | DreamStateMachine/game.cs.orig 2 | DreamStateMachine/obj/ 3 | DreamStateMachine/bin/WindowsGL/Debug/Content/Animations.xml 4 | DreamStateMachine/bin/ 5 | DSMContentProject/DSMWindowsContent/bin/ 6 | DSMContentProject/DSMContentProcessor/obj/ 7 | DSMContentProject/DSMWindowsContent/obj/ 8 | DSMContentProject/DSMWindowsContent/DSMContent.csproj.Windows.cachefile 9 | *.cachefile 10 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/Input/Command.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using DreamStateMachine.Game.GUI; 6 | 7 | namespace DreamStateMachine.Input 8 | { 9 | abstract class Command 10 | { 11 | public abstract void Execute(Actor player); 12 | public abstract void Execute(UIComponent uiComponent); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/Actor/Animation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework; 6 | 7 | namespace DreamStateMachine 8 | { 9 | abstract class Animation:Action 10 | { 11 | public abstract void onEnterFrame(int frame); 12 | public int curFrame; 13 | public int lastFrame; 14 | }; 15 | } 16 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/Events/AttackEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace DreamStateMachine 7 | { 8 | class AttackEventArgs : EventArgs 9 | { 10 | public DamageInfo damageInfo; 11 | 12 | public AttackEventArgs(DamageInfo damageInfo):base() 13 | { 14 | this.damageInfo = damageInfo; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/Rendering/IDrawable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework.Graphics; 6 | using Microsoft.Xna.Framework; 7 | 8 | namespace DreamStateMachine 9 | { 10 | interface IDrawable 11 | { 12 | void draw(SpriteBatch spriteBatch, Rectangle drawSpace, Texture2D debugTex, bool debuging = false); 13 | bool isInDrawSpace(Rectangle drawSpace); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/Events/PickupEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework; 6 | 7 | namespace DreamStateMachine 8 | { 9 | class PickupEventArgs : EventArgs 10 | { 11 | public String itemClassName; 12 | 13 | public PickupEventArgs(String itemClassName) 14 | : base() 15 | { 16 | this.itemClassName = itemClassName; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | DreamStateMachine 2 | ================= 3 | 4 | Open Source roguelike written in Monogame. 5 | 6 | Dependencies: 7 | * One of these IDE's: 8 | * microsoft visual studio 2010 c# express edition 9 | * Xamarin studio 10 | * Monogame templates (https://github.com/mono/MonoGame) 11 | 12 | To run: 13 | * Compile and run the monogame installer according to its readme 14 | * Download project folder to your preferred folder 15 | * Use your preferred IDE to open the project 16 | * Compile and run the code. 17 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/World/EnemyConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace DreamStateMachine2.game.World 7 | { 8 | class EnemyConfig 9 | { 10 | public String enemyClass; 11 | public int difficulty; 12 | 13 | public EnemyConfig(String enemyClass, int enemyDifficulty) 14 | { 15 | this.enemyClass = enemyClass; 16 | this.difficulty = enemyDifficulty; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /DreamStateMachine/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | //I CHANGED A FILE 4 | //WHATCHA GONNA DO ABOUT IT 5 | 6 | namespace DreamStateMachine 7 | { 8 | #if WINDOWS || XBOX 9 | static class Program 10 | { 11 | /// 12 | /// The main entry point for the application. 13 | /// 14 | static void Main(string[] args) 15 | { 16 | using (Game1 game = new Game1()) 17 | { 18 | game.Run(); 19 | } 20 | } 21 | } 22 | #endif 23 | } 24 | 25 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/Events/SpawnEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework; 6 | 7 | namespace DreamStateMachine 8 | { 9 | class SpawnEventArgs : EventArgs 10 | { 11 | public Point spawnTile; 12 | public int spawnType; 13 | 14 | public SpawnEventArgs(Point spawnTile, int spawnType):base() 15 | { 16 | this.spawnTile = spawnTile; 17 | this.spawnType = spawnType; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/Music.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 10 | 11 | 14 | 15 | 18 | 19 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/Input/UseCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using DreamStateMachine.Actions; 6 | 7 | namespace DreamStateMachine.Input 8 | { 9 | class UseCommand: Command 10 | { 11 | public override void Execute(Actor player) 12 | { 13 | player.onUse(); 14 | } 15 | 16 | 17 | public override void Execute(Game.GUI.UIComponent uiComponent) 18 | { 19 | throw new NotImplementedException(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/Actor/DamageInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework; 6 | 7 | namespace DreamStateMachine 8 | { 9 | class DamageInfo 10 | { 11 | public Actor attacker; 12 | public int damage; 13 | public List attackRects; 14 | 15 | public DamageInfo(Actor a, int d, List aR) 16 | { 17 | attacker = a; 18 | damage = d; 19 | attackRects = aR; 20 | } 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/World/SpawnFlag.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework; 6 | 7 | namespace DreamStateMachine 8 | { 9 | class SpawnFlag 10 | { 11 | public String className; 12 | public Point tilePosition; 13 | public int spawnType; 14 | public bool hasKey; 15 | 16 | public SpawnFlag(String cN, Point point, int type){ 17 | className = cN; 18 | tilePosition = point; 19 | spawnType = type; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/Input/PunchCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using DreamStateMachine.Actions; 6 | using Microsoft.Xna.Framework; 7 | 8 | namespace DreamStateMachine.Input 9 | { 10 | class PunchCommand: Command 11 | { 12 | public override void Execute(Actor player) 13 | { 14 | player.Light_Attack(); 15 | } 16 | 17 | public override void Execute(Game.GUI.UIComponent uiComponent) 18 | { 19 | throw new NotImplementedException(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /DreamStateMachine/Libs/Tree/Tree.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace DreamStateMachine 7 | { 8 | class Tree 9 | { 10 | NodeList nodes; 11 | 12 | public Tree(){ 13 | nodes = new NodeList(); 14 | } 15 | public Tree(Node rootNode) 16 | { 17 | nodes = new NodeList(); 18 | nodes[0] = rootNode; 19 | } 20 | 21 | public void setRoot(Node rootNode) 22 | { 23 | nodes.Add(rootNode); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /DreamStateMachine/Libs/ActionList/Action.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace DreamStateMachine 7 | { 8 | abstract class Action 9 | { 10 | public abstract void update( float dt ); 11 | public abstract void onStart(); 12 | public abstract void onEnd(); 13 | public bool isFinished = false; 14 | public bool isStarted = false; 15 | public bool isBlocking = false; 16 | public uint lanes; 17 | public float startTime; 18 | public float elapsed; 19 | public float duration; 20 | 21 | public ActionList ownerList; 22 | }; 23 | } 24 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/World/TraceInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework; 6 | 7 | namespace DreamStateMachine 8 | { 9 | class TraceInfo 10 | { 11 | public Point hitPos; 12 | public bool hitWorld; 13 | public bool hitActor; 14 | 15 | public TraceInfo(bool hw, bool ha, Point hp) 16 | { 17 | hitWorld = hw; 18 | hitActor = ha; 19 | hitPos = hp; 20 | } 21 | 22 | public TraceInfo(bool hw, bool ha) 23 | { 24 | hitWorld = hw; 25 | hitActor = ha; 26 | } 27 | 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/Events/InputEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework; 6 | 7 | namespace DreamStateMachine 8 | { 9 | class InputEventArgs : EventArgs 10 | { 11 | public String inputType; 12 | public Vector2 vectorControl; 13 | 14 | public InputEventArgs(String inputType): base() 15 | { 16 | this.inputType = inputType; 17 | } 18 | 19 | public InputEventArgs(String inputType, Vector2 vectorControl) 20 | : base() 21 | { 22 | this.inputType = inputType; 23 | this.vectorControl = vectorControl; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/Actor/AnimationInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework; 6 | 7 | namespace DreamStateMachine 8 | { 9 | public struct FrameInfo 10 | { 11 | public int attackDamage; 12 | public List attackPoints; 13 | public Point gripPoint; 14 | public String stance; 15 | public float rotation; 16 | } 17 | 18 | public struct AnimationInfo 19 | { 20 | public FrameInfo[] frames; 21 | public String name; 22 | public String type; 23 | public int frameCount; 24 | public int fps; 25 | public int texColumn; 26 | public int texRow; 27 | }; 28 | } 29 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/Input/GazeCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework; 6 | 7 | namespace DreamStateMachine.Input 8 | { 9 | class GazeCommand: Command 10 | { 11 | Vector2 gazeVec; 12 | public GazeCommand(Vector2 gazeVec) 13 | { 14 | this.gazeVec = gazeVec; 15 | } 16 | 17 | public override void Execute(Actor player) 18 | { 19 | gazeVec.Normalize(); 20 | player.setGaze(gazeVec); 21 | } 22 | 23 | 24 | public override void Execute(Game.GUI.UIComponent uiComponent) 25 | { 26 | throw new NotImplementedException(); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/GUI/MovingLabel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework.Graphics; 6 | using Microsoft.Xna.Framework; 7 | using DreamStateMachine.Game.GUI; 8 | 9 | namespace DreamStateMachine 10 | { 11 | class MovingLabel: Label 12 | { 13 | 14 | public Vector2 velocity; 15 | 16 | public MovingLabel(SpriteFont spriteFont, String contents):base(spriteFont, contents) 17 | { 18 | velocity = new Vector2(0, 0); 19 | } 20 | 21 | public override void update(float dt) 22 | { 23 | this.dimensions.X += (int)velocity.X; 24 | this.dimensions.Y += (int)velocity.Y; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /DreamStateMachine/Libs/Tree/NodeList.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Collections.ObjectModel; 6 | 7 | namespace DreamStateMachine 8 | { 9 | public class NodeList : Collection> 10 | { 11 | public NodeList() : base() { } 12 | 13 | public NodeList(int initialSize) 14 | { 15 | for (int i = 0; i < initialSize; i++) 16 | base.Items.Add(default(Node)); 17 | } 18 | 19 | public Node FindByValue(T value) 20 | { 21 | foreach (Node node in Items) 22 | if (node.Value.Equals(value)) 23 | return node; 24 | 25 | return null; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/Input/DebugCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using DreamStateMachine.Actions; 6 | using Microsoft.Xna.Framework; 7 | 8 | namespace DreamStateMachine.Input 9 | { 10 | class DebugCommand: Command 11 | { 12 | public override void Execute(Actor player) 13 | { 14 | player.onPickup("bone"); 15 | //List attackRect = new List(); 16 | //attackRect.Add(player.hitBox); 17 | //player.onHurt(new DamageInfo(player, 100, attackRect)); 18 | //player.kill(); 19 | } 20 | 21 | public override void Execute(Game.GUI.UIComponent uiComponent) 22 | { 23 | throw new NotImplementedException(); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/Input/RotateWeaponCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using DreamStateMachine.Actions; 6 | using Microsoft.Xna.Framework; 7 | 8 | namespace DreamStateMachine.Input 9 | { 10 | class RotateWeaponCommand: Command 11 | { 12 | public override void Execute(Actor player) 13 | { 14 | //player.onPickup("bone"); 15 | //List attackRect = new List(); 16 | //attackRect.Add(player.hitBox); 17 | //player.onHurt(new DamageInfo(player, 100, attackRect)); 18 | player.rotateWeapon(); 19 | } 20 | 21 | public override void Execute(Game.GUI.UIComponent uiComponent) 22 | { 23 | throw new NotImplementedException(); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/GUI/FadingLabel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework.Graphics; 6 | using Microsoft.Xna.Framework; 7 | using DreamStateMachine.Game.GUI; 8 | 9 | namespace DreamStateMachine 10 | { 11 | class FadingLabel: WorldLabel 12 | { 13 | public float timeToFade; 14 | public float curTime; 15 | 16 | public FadingLabel(SpriteFont spriteFont, String contents):base(spriteFont, contents) 17 | { 18 | timeToFade = 2f; 19 | curTime = 0; 20 | } 21 | 22 | public override void update(float dt) 23 | { 24 | curTime += dt; 25 | if (timeToFade > curTime) 26 | { 27 | this.color.A = (byte)(255* (1 - (curTime / timeToFade))); 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/AI/Behaviors/Stunned.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework; 6 | using DreamStateMachine.Behaviors; 7 | 8 | namespace DreamStateMachine.Actions 9 | { 10 | class Stunned:Behavior 11 | { 12 | Actor owner; 13 | 14 | public Stunned(ActionList ownerList, Actor owner) 15 | { 16 | this.ownerList = ownerList; 17 | this.owner = owner; 18 | duration = 3/12f; 19 | isBlocking = true; 20 | } 21 | 22 | override public void onStart() 23 | { 24 | //owner.animationList.endAll(); 25 | } 26 | 27 | override public void onEnd() 28 | { 29 | ownerList.remove(this); 30 | } 31 | 32 | override public void update(float dt) 33 | { 34 | elapsed += dt; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/Sounds.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 11 | 12 | 13 | 16 | 17 | 18 | 21 | 22 | 23 | 26 | 27 | 30 | 31 | 34 | 35 | 38 | 39 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/World/WorldConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework.Graphics; 6 | using Microsoft.Xna.Framework; 7 | using Microsoft.Xna.Framework.Content; 8 | using System.Xml.Linq; 9 | using DreamStateMachine2.game.World; 10 | 11 | namespace DreamStateMachine 12 | { 13 | class WorldConfig 14 | { 15 | public String worldName; 16 | public List enemyConfigs; 17 | public Texture2D texture; 18 | public int width; 19 | public int height; 20 | public int tileSize; 21 | public String music; 22 | 23 | //Constructor 24 | public WorldConfig(String worldName, List enemyConfigs, Texture2D worldTexture, int worldWidth, int worldHeight, int tileSize) 25 | { 26 | this.worldName = worldName; 27 | this.enemyConfigs = enemyConfigs; 28 | this.texture = worldTexture; 29 | this.width = worldWidth; 30 | this.height = worldHeight; 31 | this.tileSize = tileSize; 32 | } 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /DreamStateMachine/Libs/Tree/Node.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace DreamStateMachine 7 | { 8 | public class Node 9 | { 10 | // Private member-variables 11 | private T data; 12 | private NodeList children = null; 13 | 14 | public Node() { 15 | children = new NodeList(); 16 | } 17 | 18 | public Node(T data){ 19 | this.data = data; 20 | children = new NodeList(); 21 | } 22 | 23 | public Node(T data, NodeList children) 24 | { 25 | this.data = data; 26 | this.children = children; 27 | } 28 | 29 | public T Value 30 | { 31 | get 32 | { 33 | return data; 34 | } 35 | set 36 | { 37 | data = value; 38 | } 39 | } 40 | 41 | public NodeList Children 42 | { 43 | get 44 | { 45 | return children; 46 | } 47 | set 48 | { 49 | children = value; 50 | } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/World/Room.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework; 6 | 7 | namespace DreamStateMachine 8 | { 9 | class Room 10 | { 11 | public List spawns; 12 | public List children; 13 | public Point hallEntrance; 14 | public Point roomCenter; 15 | public Rectangle dimensions; 16 | public bool startRoom; 17 | public bool isLeaf; 18 | public bool isOptional; 19 | public Room parent; 20 | public int depth; 21 | //public List enemyList; 22 | 23 | public Room(Rectangle rect) 24 | { 25 | dimensions = rect; 26 | spawns = new List(); 27 | children = new List(); 28 | } 29 | 30 | public Room(Rectangle rect, bool start) 31 | { 32 | dimensions = rect; 33 | startRoom = start; 34 | } 35 | 36 | //public int[] getDimensions() 37 | //{ 38 | // int[] dimensions = new int[4]; 39 | // dimensions[0] = rectangle.X; 40 | // dimensions[1] = rectangle.Y; 41 | // dimensions[2] = rectangle.Width; 42 | // dimensions[3] = rectangle.Height; 43 | // return dimensions; 44 | //} 45 | 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/AI/Behaviors/Neutral.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework; 6 | using DreamStateMachine.Behaviors; 7 | 8 | namespace DreamStateMachine.Actions 9 | { 10 | class Neutral:Behavior 11 | { 12 | Actor owner; 13 | float nextWander; 14 | Random random; 15 | World world; 16 | 17 | public Neutral(ActionList ownerList, Actor owner) 18 | { 19 | this.ownerList = ownerList; 20 | this.owner = owner; 21 | elapsed = 0; 22 | duration = -1; 23 | world = owner.world; 24 | random = new Random(); 25 | } 26 | 27 | override public void onStart() 28 | { 29 | //owner.setBodyAnimationFrame(0, 0); 30 | nextWander = random.Next(4, 9); 31 | } 32 | 33 | override public void onEnd() 34 | { 35 | 36 | } 37 | 38 | override public void update(float dt) 39 | { 40 | elapsed += dt; 41 | if (elapsed > nextWander) 42 | { 43 | elapsed = 0; 44 | nextWander = random.Next(4, 9); 45 | Wander wander = new Wander(ownerList, owner); 46 | if (!ownerList.has(wander)) 47 | { 48 | ownerList.pushFront(wander); 49 | } 50 | } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /DreamStateMachine/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("DreamStateMachine2")] 9 | [assembly: AssemblyProduct("DreamStateMachine2")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyCompany("Microsoft")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("190bfc0c-920f-4bcd-9988-653b4b1eb309")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/Actor/Animations/Recoil.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework; 6 | using DreamStateMachine.Behaviors; 7 | 8 | namespace DreamStateMachine.Actions 9 | { 10 | class Recoil:Action 11 | { 12 | //actorManager actorManager; 13 | Actor owner; 14 | Color originalColor; 15 | //double dotProduct; 16 | 17 | public Recoil(ActionList ownerList, Actor owner) 18 | { 19 | this.ownerList = ownerList; 20 | this.owner = owner; 21 | duration = 2/12F; 22 | originalColor = new Color(owner.color.ToVector3()); 23 | isBlocking = true; 24 | } 25 | 26 | override public void onStart() 27 | { 28 | elapsed = 0; 29 | owner.color = Color.Crimson; 30 | } 31 | 32 | override public void onEnd() 33 | { 34 | owner.color = originalColor; 35 | ownerList.remove(this); 36 | } 37 | 38 | override public void update(float dt) 39 | { 40 | elapsed += dt; 41 | //owner.color.R = (byte)(originalColor.R - ((elapsed / duration) * (originalColor.R - owner.color.R))); 42 | //owner.color.G = (byte)(originalColor.G - ((elapsed / duration) * (originalColor.G - owner.color.G))); 43 | //owner.color.B = (byte)(originalColor.B - ((elapsed / duration) * (originalColor.B - owner.color.B))); 44 | //owner.color.A = (byte)(originalColor.A - ((elapsed / duration) * (originalColor.A - owner.color.A))); 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /DreamStateMachine/Game/AI/PathNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework; 6 | 7 | namespace DreamStateMachine 8 | { 9 | class PathNode : IEquatable 10 | { 11 | public PathNode parent; 12 | public Point point; 13 | public int movementCost; 14 | private int heuristicCost; 15 | public int totalCost; 16 | 17 | public PathNode(PathNode par, Point p, Point target, int g) 18 | { 19 | parent = par; 20 | point = p; 21 | movementCost = g; 22 | heuristicCost = 10 * (Math.Abs(target.X - point.X) + Math.Abs(target.Y - point.Y)); 23 | totalCost = movementCost + heuristicCost; 24 | } 25 | 26 | public override int GetHashCode() 27 | { 28 | return base.GetHashCode(); 29 | } 30 | 31 | public override string ToString() 32 | { 33 | return base.ToString(); 34 | } 35 | 36 | public override bool Equals(object obj) 37 | { 38 | if (!(obj is PathNode)) 39 | return false; 40 | else 41 | { 42 | PathNode tempPathNode = (PathNode)obj; 43 | return tempPathNode.point.X == point.X && tempPathNode.point.Y == point.Y; 44 | } 45 | } 46 | 47 | public bool Equals(PathNode node) 48 | { 49 | PathNode tempPathNode = (PathNode)node; 50 | return tempPathNode.point.X == point.X && tempPathNode.point.Y == point.Y; 51 | } 52 | 53 | 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/World/Key.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework.Graphics; 6 | using Microsoft.Xna.Framework; 7 | using DreamStateMachine.Actions; 8 | using DreamStateMachine2.game.World; 9 | 10 | 11 | namespace DreamStateMachine 12 | { 13 | class Key : Prop, IUseable 14 | { 15 | public Key(Texture2D tex, int width, int height, int texWidth, int texHeight):base(tex, width, height, texWidth, texHeight) 16 | { 17 | //Actor.Use += new EventHandler(Actor_Use); 18 | } 19 | 20 | public override Object Clone() 21 | { 22 | Key KeyCopy = new Key(texture, hitBox.Width, hitBox.Height, body.Width, body.Height); 23 | 24 | KeyCopy.className = className; 25 | KeyCopy.texture = texture; 26 | KeyCopy.color = color; 27 | 28 | return KeyCopy; 29 | } 30 | 31 | public void Use(Actor actor) 32 | { 33 | SoundManager.Instance.playSound("pickup"); 34 | actor.hasKey = true; 35 | onRemove(); 36 | } 37 | 38 | public bool CanUse(Actor actor) 39 | { 40 | if (actor.health > 0) 41 | { 42 | int reach = actor.reach; 43 | Vector2 sightVector = actor.sightVector; 44 | Point usePoint = new Point(); 45 | usePoint.X = (int)(actor.hitBox.Center.X + (int)(sightVector.X * reach)); 46 | usePoint.Y = (int)(actor.hitBox.Center.Y + (int)(sightVector.Y * reach)); 47 | 48 | if (body.Intersects(actor.body)) 49 | { 50 | return true; 51 | } 52 | } 53 | return false; 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/AI/Behaviors/Alert.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework; 6 | using DreamStateMachine.Behaviors; 7 | 8 | namespace DreamStateMachine.Actions 9 | { 10 | class Alert:Behavior 11 | { 12 | Actor owner; 13 | Actor target; 14 | World world; 15 | 16 | public Alert(ActionList ownerList, Actor owner, Actor target) 17 | { 18 | this.ownerList = ownerList; 19 | this.owner = owner; 20 | world = owner.world; 21 | this.target = target; 22 | elapsed = 0; 23 | duration = -1; 24 | } 25 | 26 | //dummy constructor 27 | public Alert(ActionList ownerList, Actor owner) 28 | { 29 | } 30 | 31 | override public void onStart() 32 | { 33 | 34 | } 35 | 36 | override public void onEnd() 37 | { 38 | //ownerList.remove(this); 39 | } 40 | 41 | override public void update(float dt) 42 | { 43 | if (owner.world.isInSight(owner, target.hitBox.Center)) 44 | { 45 | ownerList.endAll(); 46 | //Follow follow = new Follow(enemy.behaviorList, enemy, protagonist); 47 | //if (!enemy.behaviorList.has(follow)) 48 | // enemy.behaviorList.pushFront(follow); 49 | Aggravated aggravated = new Aggravated(ownerList, owner, target); 50 | if (!ownerList.has(aggravated)) 51 | ownerList.pushFront(aggravated); 52 | //Follow follow = new Follow(ownerList, owner, target, world); 53 | //if (!owner.behaviorList.has(follow)) 54 | // owner.behaviorList.pushFront(follow); 55 | //onEnd(); 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/Worlds.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 12 | 13 | 15 | 16 | 18 | 19 | 20 | 27 | 29 | 30 | 32 | 33 | 35 | 36 | 38 | 39 | 40 | 47 | 49 | 50 | 52 | 53 | 55 | 56 | 57 | 58 | 65 | 67 | 68 | 70 | 71 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/World/Door.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework.Graphics; 6 | using Microsoft.Xna.Framework; 7 | //using MonoGame.Framework; 8 | using DreamStateMachine.Actions; 9 | using DreamStateMachine2.game.World; 10 | 11 | 12 | namespace DreamStateMachine 13 | { 14 | class Door : Prop, IUseable 15 | { 16 | 17 | public Door(Texture2D tex, int width, int height, int texWidth, int texHeight):base(tex, width, height, texWidth, texHeight) 18 | { 19 | //Actor.Use += new EventHandler(Actor_Use); 20 | } 21 | 22 | public override Object Clone() 23 | { 24 | Door DoorCopy = new Door(texture, hitBox.Width, hitBox.Height, body.Width, body.Height); 25 | 26 | DoorCopy.className = className; 27 | DoorCopy.texture = texture; 28 | DoorCopy.color = color; 29 | 30 | return DoorCopy; 31 | } 32 | 33 | public void setAnimationFrame(int x, int y) 34 | { 35 | curAnimFrame.X = x; 36 | curAnimFrame.Y = y; 37 | } 38 | 39 | public void Use(Actor actor) 40 | { 41 | actor.hasKey = false; 42 | onRemove(); 43 | } 44 | 45 | public bool CanUse(Actor actor) 46 | { 47 | if (actor.health > 0 && actor.hasKey) 48 | { 49 | int reach = actor.reach; 50 | Vector2 sightVector = actor.sightVector; 51 | Point usePoint = new Point(); 52 | usePoint.X = (int)(actor.hitBox.Center.X + (int)(sightVector.X * reach)); 53 | usePoint.Y = (int)(actor.hitBox.Center.Y + (int)(sightVector.Y * reach)); 54 | if (body.Contains(usePoint)) 55 | { 56 | return true; 57 | } 58 | } 59 | return false; 60 | } 61 | 62 | 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/GUI/Label.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework.Graphics; 6 | using Microsoft.Xna.Framework; 7 | using DreamStateMachine.Game.GUI; 8 | 9 | namespace DreamStateMachine 10 | { 11 | class Label: UIComponent 12 | { 13 | 14 | public SpriteFont spriteFont; 15 | public String contents; 16 | public Vector2 pos; 17 | public Color color; 18 | 19 | public Label(SpriteFont spriteFont, String contents):base() 20 | { 21 | this.spriteFont = spriteFont; 22 | this.contents = contents; 23 | color = Color.White; 24 | pos = new Vector2(0, 0); 25 | } 26 | 27 | public override void draw(SpriteBatch spriteBatch, Rectangle drawSpace, Texture2D debugTex, bool debugging = false) 28 | { 29 | pos.X = dimensions.X; 30 | pos.Y = dimensions.Y; 31 | spriteBatch.DrawString(spriteFont, contents, pos, color); 32 | } 33 | 34 | public override void giveFocus() 35 | { 36 | throw new NotImplementedException(); 37 | } 38 | 39 | public override void takeFocus() 40 | { 41 | throw new NotImplementedException(); 42 | } 43 | 44 | public override bool isInDrawSpace(Rectangle drawSpace) 45 | { 46 | return dimensions.Intersects(drawSpace); 47 | } 48 | 49 | public override void setPos(int x, int y) 50 | { 51 | pos.X = (float)x - spriteFont.MeasureString(contents).X / 2; 52 | pos.Y = (float)y - spriteFont.MeasureString(contents).Y / 2; ; 53 | } 54 | 55 | public override void setPos(Point point) 56 | { 57 | pos.X = ((float)point.X); 58 | pos.Y = ((float)point.Y); 59 | } 60 | 61 | public override UIComponent findFocusedChild() 62 | { 63 | throw new NotImplementedException(); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/GUI/WorldLabel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework.Graphics; 6 | using Microsoft.Xna.Framework; 7 | using DreamStateMachine.Game.GUI; 8 | 9 | namespace DreamStateMachine 10 | { 11 | class WorldLabel: Label 12 | { 13 | 14 | Vector2 normalizedPos; 15 | 16 | public WorldLabel(SpriteFont spriteFont, String contents):base(spriteFont, contents) 17 | { 18 | dimensions.Width = (int)spriteFont.MeasureString(contents).X; 19 | dimensions.Height = (int)spriteFont.MeasureString(contents).Y; 20 | normalizedPos = new Vector2(); 21 | } 22 | 23 | public override void draw(SpriteBatch spriteBatch, Rectangle drawSpace, Texture2D debugTex, bool debugging = false) 24 | { 25 | if (dimensions.Intersects(drawSpace)) 26 | { 27 | normalizedPos.X = dimensions.X - drawSpace.X; 28 | normalizedPos.Y = dimensions.Y - drawSpace.Y; 29 | spriteBatch.DrawString(base.spriteFont, base.contents, normalizedPos, color); 30 | } 31 | 32 | } 33 | 34 | public override void giveFocus() 35 | { 36 | throw new NotImplementedException(); 37 | } 38 | 39 | public override void takeFocus() 40 | { 41 | throw new NotImplementedException(); 42 | } 43 | 44 | public override bool isInDrawSpace(Rectangle drawSpace) 45 | { 46 | return dimensions.Intersects(drawSpace); 47 | } 48 | 49 | public override void setPos(int x, int y) 50 | { 51 | pos.X = (float)x; 52 | pos.Y = (float)y; 53 | } 54 | 55 | public override void setPos(Point point) 56 | { 57 | pos.X = ((float)point.X); 58 | pos.Y = ((float)point.Y); 59 | } 60 | 61 | public override UIComponent findFocusedChild() 62 | { 63 | throw new NotImplementedException(); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/World/WeaponItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework.Graphics; 6 | using Microsoft.Xna.Framework; 7 | using DreamStateMachine.Actions; 8 | using DreamStateMachine2.game.World; 9 | 10 | 11 | namespace DreamStateMachine 12 | { 13 | class WeaponItem:Prop, IUseable 14 | { 15 | public WeaponItem(Texture2D tex, String className, int width, int height, int offsetX, int offsetY, int texWidth, int texHeight):base(tex, width, height, texWidth, texHeight) 16 | { 17 | body.X = offsetX; 18 | body.Y = offsetY; 19 | body.Width = texWidth; 20 | body.Height = texHeight; 21 | this.className = className; 22 | //Actor.Use += new EventHandler(Actor_Use); 23 | setAnimationFrame(1, 0); 24 | } 25 | 26 | public override Object Clone() 27 | { 28 | WeaponItem WeaponCopy = new WeaponItem(texture, className, hitBox.Width, hitBox.Height, body.X, body.Y, body.Width, body.Height); 29 | WeaponCopy.color = color; 30 | 31 | return WeaponCopy; 32 | } 33 | 34 | public void Use(Actor actor) 35 | { 36 | if (actor.activeWeapon != null) 37 | { 38 | actor.onDrop(actor.activeWeapon.name); 39 | } 40 | actor.onPickup(className); 41 | SoundManager.Instance.playSound("pickup"); 42 | actor.pickUpCoolDown = .25f; 43 | onRemove(); 44 | } 45 | 46 | public bool CanUse(Actor actor) 47 | { 48 | if (actor.health > 0 && actor.pickUpCoolDown <= 0) 49 | { 50 | 51 | int reach = actor.reach; 52 | Vector2 sightVector = actor.sightVector; 53 | Rectangle usePoint = new Rectangle(0, 0, 20, 20); 54 | usePoint.X = (int)(actor.hitBox.Center.X + (int)(sightVector.X * reach)) - usePoint.Width / 2; 55 | usePoint.Y = (int)(actor.hitBox.Center.Y + (int)(sightVector.Y * reach)) - usePoint.Height / 2; 56 | 57 | if (body.Intersects(actor.body)) 58 | { 59 | return true; 60 | } 61 | } 62 | return false; 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/GUI/Button.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework.Graphics; 6 | using Microsoft.Xna.Framework; 7 | using DreamStateMachine.Game.GUI; 8 | 9 | namespace DreamStateMachine 10 | { 11 | class Button: UIComponent 12 | { 13 | private Panel basePanel; 14 | private Color originalPanelColor; 15 | 16 | public Button(Texture2D tex):base() 17 | { 18 | dimensions = new Rectangle(0, 0, 0, 0); 19 | basePanel = new Panel(tex, Color.Gray); 20 | originalPanelColor = new Color(basePanel.color, 255); 21 | basePanel.dimensions = dimensions; 22 | children = new List(); 23 | canHaveFocus = true; 24 | } 25 | 26 | public override void draw(SpriteBatch spriteBatch, Rectangle drawSpace, Texture2D debugTex, bool debugging = false) 27 | { 28 | spriteBatch.Draw(basePanel.tex, dimensions, basePanel.color); 29 | foreach (UIComponent uiChild in children) 30 | { 31 | if (uiChild.dimensions.Intersects(dimensions)) 32 | { 33 | uiChild.draw(spriteBatch, drawSpace, debugTex, debugging); 34 | } 35 | } 36 | 37 | } 38 | 39 | public override void giveFocus() 40 | { 41 | 42 | basePanel.color.R = 255; 43 | basePanel.color.G = 255; 44 | basePanel.color.B = 255; 45 | hasFocus = true; 46 | } 47 | 48 | public override void takeFocus() 49 | { 50 | //basePanel.color = new Color(originalPanelColor, 255); 51 | basePanel.color.R = originalPanelColor.R; 52 | basePanel.color.G = originalPanelColor.G; 53 | basePanel.color.B = originalPanelColor.B; 54 | hasFocus = false; 55 | } 56 | 57 | public override bool isInDrawSpace(Rectangle drawSpace) 58 | { 59 | return dimensions.Intersects(drawSpace); 60 | } 61 | 62 | public override void setPos(int x, int y) 63 | { 64 | dimensions.X = x; 65 | dimensions.Y = y; 66 | } 67 | 68 | public override void setPos(Point pos) 69 | { 70 | dimensions.X = pos.X; 71 | dimensions.Y = pos.Y; 72 | } 73 | 74 | public override UIComponent findFocusedChild() 75 | { 76 | throw new NotImplementedException(); 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/Props.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | 17 | 18 | 19 | 26 | 27 | 28 | 34 | 35 | 36 | 44 | 45 | 46 | 54 | 55 | 56 | 64 | 65 | 66 | 74 | 75 | 76 | 84 | 85 | 86 | 94 | 95 | 96 | 104 | 105 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/World/Potion.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework.Graphics; 6 | using Microsoft.Xna.Framework; 7 | //using MonoGame.Framework; 8 | using DreamStateMachine.Actions; 9 | using DreamStateMachine2.game.World; 10 | 11 | 12 | namespace DreamStateMachine 13 | { 14 | class Potion : Prop, IUseable 15 | { 16 | 17 | public int restore; 18 | 19 | public Potion(Texture2D tex, int width, int height, int texWidth, int texHeight, int restore):base(tex, width, height, texWidth, texHeight) 20 | { 21 | //Actor.Use += new EventHandler(Actor_Use); 22 | this.restore = restore; 23 | } 24 | 25 | public override Object Clone() 26 | { 27 | Potion PotionCopy = new Potion(texture, hitBox.Width, hitBox.Height, body.Width, body.Height, restore); 28 | 29 | PotionCopy.className = className; 30 | PotionCopy.texture = texture; 31 | PotionCopy.color = color; 32 | 33 | return PotionCopy; 34 | } 35 | 36 | public void Use(Actor actor) 37 | { 38 | if (actor.health > 0) 39 | { 40 | int reach = actor.reach; 41 | Vector2 sightVector = actor.sightVector; 42 | Point usePoint = new Point(); 43 | usePoint.X = (int)(actor.hitBox.Center.X + (int)(sightVector.X * reach)); 44 | usePoint.Y = (int)(actor.hitBox.Center.Y + (int)(sightVector.Y * reach)); 45 | if (body.Contains(usePoint)) 46 | { 47 | if (actor.health + restore <= actor.maxHealth) 48 | actor.health += restore; 49 | SoundManager.Instance.playSound("pickup"); 50 | onRemove(); 51 | } 52 | } 53 | } 54 | 55 | public bool CanUse(Actor actor) 56 | { 57 | if (actor.health > 0) 58 | { 59 | int reach = actor.reach; 60 | Vector2 sightVector = actor.sightVector; 61 | Point usePoint = new Point(); 62 | usePoint.X = (int)(actor.hitBox.Center.X + (int)(sightVector.X * reach)); 63 | usePoint.Y = (int)(actor.hitBox.Center.Y + (int)(sightVector.Y * reach)); 64 | 65 | if (body.Intersects(actor.body)) 66 | { 67 | return true; 68 | } 69 | } 70 | return false; 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/Sound/Sound.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework; 6 | using DreamStateMachine.Actions; 7 | using Microsoft.Xna.Framework.Audio; 8 | using Microsoft.Xna.Framework.Content; 9 | using System.Xml.Linq; 10 | 11 | namespace DreamStateMachine 12 | { 13 | class Sound 14 | { 15 | public SoundEffectInstance effect; 16 | float curFadeTime; 17 | float endFadeTime; 18 | bool isFadingIn = false; 19 | bool isFadingOut = false; 20 | 21 | public Sound(SoundEffect effect) 22 | { 23 | curFadeTime = 0; 24 | this.effect = effect.CreateInstance(); 25 | } 26 | 27 | public void playSound() 28 | { 29 | effect.Play(); 30 | } 31 | 32 | public void playLoopedSound() 33 | { 34 | effect.IsLooped = true; 35 | effect.Play(); 36 | } 37 | 38 | public void stopSound() 39 | { 40 | effect.Stop(); 41 | } 42 | 43 | public void fadeInSound(float fadeTime) 44 | { 45 | this.playLoopedSound(); 46 | curFadeTime = 0; 47 | endFadeTime = fadeTime; 48 | isFadingIn = true; 49 | effect.Volume = 0; 50 | } 51 | 52 | public void fadeOutSound(float fadeTime) 53 | { 54 | curFadeTime = 0; 55 | endFadeTime = fadeTime; 56 | isFadingOut = true; 57 | effect.Volume = 1; 58 | } 59 | 60 | public void update(float dt) 61 | { 62 | if (isFadingIn) 63 | { 64 | curFadeTime += dt; 65 | if (curFadeTime >= endFadeTime) 66 | { 67 | effect.Volume = 1.0f; 68 | isFadingIn = false; 69 | curFadeTime = 0; 70 | } 71 | else 72 | { 73 | effect.Volume = (curFadeTime / endFadeTime); 74 | } 75 | } 76 | else if (isFadingOut) 77 | { 78 | curFadeTime += dt; 79 | if (curFadeTime >= endFadeTime) 80 | { 81 | effect.Volume = 0.0f; 82 | isFadingOut = false; 83 | curFadeTime = 0; 84 | } 85 | else 86 | { 87 | effect.Volume = ((endFadeTime - curFadeTime) / endFadeTime); 88 | } 89 | } 90 | } 91 | 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/Actor/Animations/Idle.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework; 6 | using DreamStateMachine.Behaviors; 7 | 8 | namespace DreamStateMachine.Actions 9 | { 10 | class Idle:Animation 11 | { 12 | AnimationInfo animationInfo; 13 | Actor owner; 14 | FrameInfo frameInfo; 15 | 16 | public Idle(ActionList ownerList, Actor owner) 17 | { 18 | this.ownerList = ownerList; 19 | this.owner = owner; 20 | setAnimationInfo(); 21 | duration = -1; 22 | curFrame = 0; 23 | lastFrame = -1; 24 | } 25 | 26 | //dummy constructor 27 | public Idle() 28 | { 29 | } 30 | 31 | private void setAnimationInfo() 32 | { 33 | if (owner.activeWeapon != null) 34 | { 35 | animationInfo = owner.animations[owner.activeWeapon.animations["holding_weapon_idle"]]; 36 | } 37 | else 38 | { 39 | animationInfo = owner.animations["unarmed_idle"]; 40 | } 41 | } 42 | 43 | public override void onEnterFrame(int frame) 44 | { 45 | setAnimationInfo(); 46 | owner.setAnimationFrame(frame, animationInfo.texRow); 47 | if (frame < animationInfo.frames.Length) 48 | { 49 | frameInfo = animationInfo.frames[frame]; 50 | if (owner.activeWeapon != null) 51 | { 52 | owner.gripPoint = frameInfo.gripPoint; 53 | owner.activeWeapon.setStance(frameInfo.stance); 54 | owner.activeWeapon.frameRotation = frameInfo.rotation; 55 | } 56 | } 57 | } 58 | 59 | override public void onStart() 60 | { 61 | elapsed = 0; 62 | } 63 | 64 | override public void onEnd() 65 | { 66 | 67 | } 68 | 69 | override public void update(float dt) 70 | { 71 | elapsed += dt; 72 | curFrame = (int)(elapsed * animationInfo.fps); 73 | if (curFrame >= animationInfo.frameCount) 74 | { 75 | curFrame = 0; 76 | elapsed = 0; 77 | onEnterFrame(curFrame); 78 | 79 | 80 | } 81 | if (curFrame != lastFrame) 82 | { 83 | onEnterFrame(curFrame); 84 | lastFrame = curFrame; 85 | } 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/Input/MoveCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework; 6 | using DreamStateMachine.Game.GUI; 7 | 8 | 9 | namespace DreamStateMachine.Input 10 | { 11 | class MoveCommand: Command 12 | { 13 | Vector2 movement; 14 | public MoveCommand(Vector2 movement) 15 | { 16 | this.movement = movement; 17 | } 18 | public override void Execute(Actor player) 19 | { 20 | if (!player.lockedMovement && movement.Length() > .1f) 21 | { 22 | movement.Normalize(); 23 | player.movementIntent = movement * 0.7f; 24 | player.isWalking = true; 25 | } 26 | else 27 | { 28 | player.movementIntent.X = 0; 29 | player.movementIntent.Y = 0; 30 | player.isWalking = false; 31 | } 32 | } 33 | public override void Execute(UIComponent uiComponent) 34 | { 35 | 36 | if (uiComponent.children.Count > 0) 37 | { 38 | int curChildIndex = 0; 39 | UIComponent curChild = uiComponent.children[curChildIndex]; 40 | while (!curChild.hasFocus && curChildIndex < uiComponent.children.Count - 1) 41 | { 42 | curChildIndex++; 43 | curChild = uiComponent.children[curChildIndex]; 44 | } 45 | 46 | if (curChild.hasFocus) 47 | { 48 | movement.Normalize(); 49 | if (movement.Y > 0) 50 | { 51 | if (curChildIndex == 0) 52 | { 53 | curChildIndex = uiComponent.children.Count - 1; 54 | } 55 | else 56 | curChildIndex--; 57 | } 58 | else if (movement.Y < 0) 59 | { 60 | if (curChildIndex == uiComponent.children.Count - 1) 61 | { 62 | curChildIndex = 0; 63 | } 64 | else 65 | curChildIndex++; 66 | } 67 | uiComponent.children[curChildIndex].giveFocus(); 68 | } 69 | else 70 | { 71 | uiComponent.children[0].giveFocus(); 72 | } 73 | 74 | } 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/AI/Behaviors/Pursue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework; 6 | using DreamStateMachine.Behaviors; 7 | 8 | namespace DreamStateMachine.Actions 9 | { 10 | class Pursue:Behavior 11 | { 12 | ActionList ownerList; 13 | Actor owner; 14 | Actor target; 15 | Rectangle pathTileRectangle; 16 | 17 | public Pursue(ActionList ownerList, Actor owner, Actor toFollow) 18 | { 19 | this.ownerList = ownerList; 20 | this.owner = owner; 21 | target = toFollow; 22 | nextPathPoint = new Point(0,0); 23 | elapsed = 0; 24 | duration = -1; 25 | isBlocking = true; 26 | pathTileRectangle = new Rectangle(0, 0, owner.world.tileSize / 4, owner.world.tileSize / 4); 27 | } 28 | 29 | override public void onStart() 30 | { 31 | path = owner.world.findPath(owner.hitBox.Center, target.hitBox.Center); 32 | if (path.Count > 0) 33 | nextPathPoint = path[0]; 34 | else 35 | onEnd(); 36 | } 37 | 38 | override public void onEnd() 39 | { 40 | ownerList.remove(this); 41 | } 42 | 43 | override public void update(float dt) 44 | { 45 | //traceInfo = owner.world.traceWorld(owner.hitBox.Center, target.hitBox.Center); 46 | 47 | 48 | pathTileRectangle.X = nextPathPoint.X - pathTileRectangle.Width / 2; 49 | pathTileRectangle.Y = nextPathPoint.Y - pathTileRectangle.Height / 2; 50 | if (owner.hitBox.Intersects(pathTileRectangle)) 51 | { 52 | if (owner.world.isInSight(owner, target.hitBox.Center)) 53 | { 54 | onEnd(); 55 | } 56 | if (path.Count > 0) 57 | { 58 | nextPathPoint = path.ElementAt(0); 59 | path.RemoveAt(0); 60 | } 61 | else 62 | { 63 | onEnd(); 64 | } 65 | } 66 | else 67 | { 68 | Vector2 movement = new Vector2(nextPathPoint.X - owner.hitBox.Center.X, nextPathPoint.Y - owner.hitBox.Center.Y); 69 | movement.Normalize(); 70 | movement *= owner.maxSpeed; 71 | owner.velocity.X = movement.X; 72 | owner.velocity.Y = movement.Y; 73 | owner.isWalking = true; 74 | owner.setGaze(nextPathPoint); 75 | } 76 | 77 | 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/GUI/HealthBar.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework.Graphics; 6 | using Microsoft.Xna.Framework; 7 | using DreamStateMachine.Game.GUI; 8 | 9 | namespace DreamStateMachine 10 | { 11 | class HealthBar: UIComponent 12 | { 13 | Actor actor; 14 | Rectangle bar; 15 | Rectangle barDimensions; 16 | Texture2D barTexture; 17 | int barWidth = 50; 18 | int barHeight = 15; 19 | int displaceX = 0; 20 | int displaceY = -30; 21 | 22 | public HealthBar(Actor actor, Texture2D barTex):base() 23 | { 24 | this.actor = actor; 25 | bar = new Rectangle(0, 0, barTex.Width, barTex.Height); 26 | barDimensions = new Rectangle(0, 0, barWidth, barHeight); 27 | dimensions = new Rectangle(0, 0, barWidth, barHeight); 28 | barTexture = barTex; 29 | } 30 | 31 | public override void draw(SpriteBatch spriteBatch, Rectangle drawSpace, Texture2D debugTex, bool debugging = false) 32 | { 33 | float healthPercentage = (float)((float)actor.health / actor.maxHealth); 34 | dimensions.X = actor.hitBox.Center.X - (dimensions.Width / 2) - drawSpace.X + displaceX; 35 | dimensions.Y = actor.hitBox.Center.Y - (dimensions.Height / 2) - drawSpace.Y + displaceY; 36 | // 37 | bar.Width = (int)(barTexture.Width * healthPercentage); 38 | barDimensions.X = dimensions.X; 39 | barDimensions.Y = dimensions.Y; 40 | barDimensions.Width = (int)(barWidth * healthPercentage); 41 | //barDimensions.Height = barHeight; 42 | 43 | //bar.Height = dimensions.Height; 44 | spriteBatch.Draw(barTexture, dimensions, Color.Black); 45 | //spriteBatch.Draw(barTexture, bar, Color.White); 46 | spriteBatch.Draw(barTexture, barDimensions, bar, Color.White); 47 | } 48 | public override void giveFocus() 49 | { 50 | throw new NotImplementedException(); 51 | } 52 | 53 | public override void takeFocus() 54 | { 55 | throw new NotImplementedException(); 56 | } 57 | 58 | public override bool isInDrawSpace(Rectangle drawSpace) 59 | { 60 | return bar.Intersects(drawSpace); 61 | } 62 | 63 | public override void setPos(Point pos) 64 | { 65 | } 66 | 67 | public override void setPos(int x, int y) 68 | { 69 | } 70 | 71 | public override UIComponent findFocusedChild() 72 | { 73 | throw new NotImplementedException(); 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/AI/Behaviors/Wander.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework; 6 | using DreamStateMachine.Behaviors; 7 | 8 | namespace DreamStateMachine.Actions 9 | { 10 | class Wander:Behavior 11 | { 12 | Actor owner; 13 | List searchPath; 14 | Random random; 15 | Rectangle pathTileRectangle; 16 | 17 | 18 | 19 | public Wander(ActionList ownerList, Actor owner) 20 | { 21 | this.ownerList = ownerList; 22 | this.owner = owner; 23 | elapsed = 0; 24 | duration = -1; 25 | searchPath = new List(); 26 | nextPathPoint = new Point(0, 0); 27 | isBlocking = true; 28 | random = new Random(); 29 | pathTileRectangle = new Rectangle(0, 0, owner.world.tileSize / 4, owner.world.tileSize / 4); 30 | } 31 | 32 | override public void onStart() 33 | { 34 | Point randomPos; 35 | randomPos = new Point(owner.hitBox.Center.X + random.Next(-200, 200), owner.hitBox.Center.Y + random.Next(-200, 200)); 36 | 37 | while (!owner.world.isInBounds(randomPos)) 38 | { 39 | randomPos = new Point(owner.hitBox.Center.X + random.Next(-120, 120), owner.hitBox.Center.Y + random.Next(-120, 120)); 40 | } 41 | 42 | path = owner.world.findPath(owner.hitBox.Center, randomPos); 43 | 44 | if (path.Count > 0) 45 | nextPathPoint = path[0]; 46 | else 47 | onEnd(); 48 | } 49 | 50 | override public void onEnd() 51 | { 52 | ownerList.remove(this); 53 | owner.isWalking = false; 54 | } 55 | 56 | override public void update(float dt) 57 | { 58 | //ownerTilePos = new Point(owner.hitBox.Center.X / world.tileSize, owner.hitBox.Center.Y / world.tileSize); 59 | pathTileRectangle.X = nextPathPoint.X - pathTileRectangle.Width / 2; 60 | pathTileRectangle.Y = nextPathPoint.Y - pathTileRectangle.Height / 2; 61 | if (owner.hitBox.Intersects(pathTileRectangle)) 62 | { 63 | if (path.Count > 0) 64 | { 65 | nextPathPoint = path.ElementAt(0); 66 | path.RemoveAt(0); 67 | } 68 | else 69 | { 70 | onEnd(); 71 | } 72 | } 73 | else 74 | { 75 | Vector2 movement = new Vector2(nextPathPoint.X - owner.hitBox.Center.X, nextPathPoint.Y - owner.hitBox.Center.Y); 76 | movement.Normalize(); 77 | movement *= owner.maxSpeed / 2; 78 | owner.velocity.X = movement.X; 79 | owner.velocity.Y = movement.Y; 80 | owner.isWalking = true; 81 | owner.setGaze(nextPathPoint); 82 | } 83 | 84 | 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /DSMContentProject/DSMWindowsContent/DSMWindowsContent.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {313BB489-E187-4B9D-8926-8E14B4B02B20} 6 | {6D335F3A-9D43-41b4-9D22-F6F17C4BE596};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 7 | Windows 8 | x86 9 | Library 10 | Properties 11 | ContentBuilder 12 | IgnoreMe 13 | v4.0 14 | Client 15 | v4.0 16 | bin\$(Configuration) 17 | Windows 18 | HiDef 19 | a353d086-5978-46ef-b085-ca79674b4f6c 20 | Library 21 | x86 22 | false 23 | 24 | 25 | Windows 26 | 27 | 28 | Windows8 29 | 30 | 31 | Android 32 | 33 | 34 | iOS 35 | 36 | 37 | OSX 38 | 39 | 40 | Linux 41 | 42 | 43 | PSM 44 | 45 | 46 | 47 | 48 | 49 | 50 | DSMContentProcessor %28Content%29 51 | Content 52 | {2037DFA6-4065-498F-B91B-9C4C29D433A4} 53 | 54 | 55 | 56 | 57 | 65 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/Sound/SoundManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework; 6 | using DreamStateMachine.Actions; 7 | using Microsoft.Xna.Framework.Audio; 8 | using Microsoft.Xna.Framework.Content; 9 | using System.Xml.Linq; 10 | using Microsoft.Xna.Framework.Media; 11 | 12 | namespace DreamStateMachine 13 | { 14 | public sealed class SoundManager 15 | { 16 | private static volatile SoundManager instance; 17 | private static object syncRoot = new object(); 18 | static Dictionary soundPrototypes; 19 | static Dictionary songPrototypes; 20 | private Song curSong; 21 | private SongCollection songCollection; 22 | 23 | private SoundManager() 24 | { 25 | MediaPlayer.IsRepeating = false; 26 | songCollection = new SongCollection(); 27 | } 28 | 29 | public static SoundManager Instance 30 | { 31 | get 32 | { 33 | if (instance == null) 34 | { 35 | lock (syncRoot) 36 | { 37 | if (instance == null) 38 | instance = new SoundManager(); 39 | } 40 | } 41 | return instance; 42 | } 43 | } 44 | 45 | public void initSoundConfig(ContentManager content, String soundConfigFile, String musicConfigFile) 46 | { 47 | soundPrototypes = new Dictionary(); 48 | songPrototypes = new Dictionary(); 49 | XDocument soundDoc = XDocument.Load(soundConfigFile); 50 | List sounds = soundDoc.Element("Sounds").Elements("Sound").ToList(); 51 | XDocument musicDoc = XDocument.Load(musicConfigFile); 52 | List songs = musicDoc.Element("Songs").Elements("Song").ToList(); 53 | String soundClass; 54 | SoundEffect effect; 55 | foreach (XElement sound in sounds) 56 | { 57 | soundClass = sound.Attribute("className").Value; 58 | effect = content.Load(sound.Attribute("filePath").Value); 59 | soundPrototypes[soundClass] = new Sound(effect); 60 | } 61 | } 62 | 63 | public void playSound(String soundClass) 64 | { 65 | soundPrototypes[soundClass].playSound(); 66 | } 67 | 68 | public void playSong(String songName) 69 | { 70 | soundPrototypes[songName].playLoopedSound(); 71 | } 72 | 73 | public void crossFadeSongs(String firstSong, String secondSong) 74 | { 75 | soundPrototypes[firstSong].fadeOutSound(2); 76 | soundPrototypes[secondSong].fadeInSound(5); 77 | } 78 | 79 | public void stopSong(String songName) 80 | { 81 | soundPrototypes[songName].stopSound(); 82 | } 83 | 84 | public void stopAllSounds() 85 | { 86 | foreach (KeyValuePair entry in soundPrototypes) 87 | { 88 | entry.Value.stopSound(); 89 | } 90 | } 91 | 92 | public void update(float dt) 93 | { 94 | foreach(KeyValuePair soundPrototype in soundPrototypes) 95 | { 96 | soundPrototype.Value.update(dt); 97 | } 98 | } 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/Actor/Animations/Walk.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework; 6 | using DreamStateMachine.Behaviors; 7 | 8 | namespace DreamStateMachine.Actions 9 | { 10 | class Walk:Animation 11 | { 12 | AnimationInfo animationInfo; 13 | Actor owner; 14 | Vector2 walkDirection; 15 | FrameInfo frameInfo; 16 | double dotProduct; 17 | 18 | public Walk(ActionList ownerList, Actor owner) 19 | { 20 | this.ownerList = ownerList; 21 | this.owner = owner; 22 | setAnimationInfo(); 23 | isBlocking = true; 24 | duration = ((float)animationInfo.frameCount) / animationInfo.fps; 25 | curFrame = 0; 26 | lastFrame = -1; 27 | } 28 | 29 | //dummy constructor 30 | public Walk() 31 | { 32 | } 33 | 34 | private void setAnimationInfo() 35 | { 36 | if (owner.activeWeapon != null) 37 | { 38 | animationInfo = owner.animations[owner.activeWeapon.animations["holding_weapon_walk"]]; 39 | } 40 | else 41 | { 42 | animationInfo = owner.animations["unarmed_walk"]; 43 | } 44 | } 45 | 46 | public override void onEnterFrame(int frame) 47 | { 48 | setAnimationInfo(); 49 | owner.setAnimationFrame(frame, animationInfo.texRow); 50 | if (frame < animationInfo.frames.Length) 51 | { 52 | frameInfo = animationInfo.frames[frame]; 53 | if (owner.activeWeapon != null) 54 | { 55 | owner.gripPoint = frameInfo.gripPoint; 56 | owner.activeWeapon.setStance(frameInfo.stance); 57 | owner.activeWeapon.frameRotation = frameInfo.rotation; 58 | } 59 | } 60 | } 61 | 62 | override public void onStart() 63 | { 64 | elapsed = 0; 65 | } 66 | 67 | override public void onEnd() 68 | { 69 | if (owner.isWalking) 70 | elapsed = 0; 71 | else 72 | ownerList.remove(this); 73 | 74 | //owner.setAnimationFrame(0, animationInfo.texRow); 75 | 76 | 77 | } 78 | 79 | override public void update(float dt) 80 | { 81 | 82 | if (owner.isWalking){ 83 | 84 | curFrame = (int)(elapsed * animationInfo.fps); 85 | if (curFrame >= animationInfo.frameCount) 86 | curFrame = 0; 87 | 88 | if (curFrame != lastFrame) 89 | { 90 | onEnterFrame(curFrame); 91 | lastFrame = curFrame; 92 | } 93 | 94 | walkDirection.X = owner.velocity.X; 95 | walkDirection.Y = owner.velocity.Y; 96 | walkDirection.Normalize(); 97 | dotProduct = Vector2.Dot(walkDirection, owner.sightVector); 98 | 99 | if (dotProduct > .5) 100 | { 101 | elapsed += dt; 102 | } 103 | else if (dotProduct < -.5) 104 | { 105 | elapsed -= dt; 106 | if (elapsed <= 0) 107 | { 108 | elapsed = (duration - .0001f); 109 | } 110 | } 111 | }else{ 112 | this.onEnd(); 113 | } 114 | } 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/Actor/Weapon.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework.Graphics; 6 | using Microsoft.Xna.Framework; 7 | 8 | namespace DreamStateMachine 9 | { 10 | struct Stance 11 | { 12 | public String name; 13 | public Vector2 gripPoint; 14 | public Rectangle drawBox; 15 | } 16 | 17 | 18 | class Weapon: ICloneable, IDrawable 19 | { 20 | public Dictionary animations; 21 | public Dictionary stances; 22 | public String name; 23 | public Stance curStance; 24 | public Texture2D tex; 25 | public Rectangle dimensions; 26 | public int damage; 27 | public float frameRotation; 28 | public float rotation; 29 | 30 | public Weapon(String name, Texture2D tex,int damage, Dictionary animations, Dictionary stances) 31 | { 32 | this.stances = stances; 33 | this.damage = damage; 34 | this.animations = animations; 35 | this.name = name; 36 | this.tex = tex; 37 | dimensions = new Rectangle(); 38 | } 39 | 40 | public Object Clone(){ 41 | Weapon clonedWeapon = new Weapon(name, tex, damage, animations, stances); 42 | return clonedWeapon; 43 | } 44 | 45 | public bool isInDrawSpace(Rectangle drawSpace) 46 | { 47 | return drawSpace.Intersects(dimensions); 48 | } 49 | 50 | public void calcWeaponPos(Actor owner) 51 | { 52 | Vector2 gripVector = new Vector2(owner.gripPoint.X - owner.body.Width / 2, 53 | -((owner.body.Height - owner.gripPoint.Y) - owner.body.Height / 2)); 54 | Point rotatedGrip = new Point(); 55 | rotatedGrip.X = (int)(gripVector.X * Math.Cos(owner.bodyRotation)) - (int)(gripVector.Y * Math.Sin(owner.bodyRotation)); 56 | rotatedGrip.Y = (int)(gripVector.X * Math.Sin(owner.bodyRotation)) + (int)(gripVector.Y * Math.Cos(owner.bodyRotation)); 57 | 58 | owner.activeWeapon.dimensions.X = owner.body.Center.X + rotatedGrip.X; 59 | owner.activeWeapon.dimensions.Y = owner.body.Center.Y + rotatedGrip.Y; 60 | owner.activeWeapon.rotation = owner.bodyRotation + owner.activeWeapon.frameRotation; 61 | } 62 | 63 | public void draw(SpriteBatch spriteBatch, Rectangle drawSpace, Texture2D debugTex, bool debugging = false) 64 | { 65 | 66 | if (drawSpace.Intersects(dimensions)) 67 | { 68 | Rectangle normalizedRect = new Rectangle(dimensions.X - drawSpace.X, 69 | dimensions.Y - drawSpace.Y, 70 | dimensions.Width, 71 | dimensions.Height); 72 | 73 | spriteBatch.Draw(tex, 74 | normalizedRect, 75 | curStance.drawBox, 76 | Color.White, 77 | rotation, 78 | curStance.gripPoint, 79 | SpriteEffects.None, 80 | 0); 81 | } 82 | } 83 | 84 | public void setStance(String name) 85 | { 86 | if (stances.ContainsKey(name)) 87 | { 88 | dimensions.Width = stances[name].drawBox.Width; 89 | dimensions.Height = stances[name].drawBox.Height; 90 | curStance = stances[name]; 91 | } 92 | } 93 | 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/GUI/Panel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework.Graphics; 6 | using Microsoft.Xna.Framework; 7 | using DreamStateMachine.Game.GUI; 8 | 9 | namespace DreamStateMachine 10 | { 11 | class Panel: UIComponent 12 | { 13 | public Color color; 14 | public Texture2D tex; 15 | 16 | public Panel(Texture2D tex, Color color):base() 17 | { 18 | this.color = color; 19 | this.tex = tex; 20 | dimensions = new Rectangle(0, 0, 0, 0); 21 | children = new List(); 22 | onClick = click; 23 | } 24 | 25 | public void addChild(UIComponent child){ 26 | child.dimensions.X += dimensions.X; 27 | child.dimensions.Y += dimensions.Y; 28 | child.parent = this; 29 | children.Add(child); 30 | } 31 | 32 | private void click() 33 | { 34 | } 35 | 36 | public void center() 37 | { 38 | if (parent != null) 39 | { 40 | dimensions.X = parent.dimensions.Width / 2 - dimensions.Width / 2; 41 | dimensions.X = parent.dimensions.Height / 2 - dimensions.Height / 2; 42 | } 43 | } 44 | 45 | public void centerHorizontally() 46 | { 47 | if(parent != null){ 48 | dimensions.X = parent.dimensions.Width / 2 - dimensions.Width / 2; 49 | } 50 | } 51 | 52 | public void centerVertically() 53 | { 54 | if (parent != null) 55 | { 56 | dimensions.X = parent.dimensions.Height / 2 - dimensions.Height / 2; 57 | } 58 | } 59 | 60 | public override void draw(SpriteBatch spriteBatch, Rectangle drawSpace, Texture2D debugTex, bool debugging = false) 61 | { 62 | spriteBatch.Draw(tex, dimensions, color); 63 | foreach (UIComponent uiChild in children) 64 | { 65 | if (uiChild.dimensions.Intersects(dimensions)) 66 | { 67 | uiChild.draw(spriteBatch, drawSpace, debugTex, debugging); 68 | } 69 | } 70 | } 71 | 72 | public override UIComponent findFocusedChild() 73 | { 74 | foreach(UIComponent child in children){ 75 | if (child.hasFocus) 76 | return child; 77 | } 78 | return null; 79 | } 80 | 81 | public override void giveFocus() 82 | { 83 | } 84 | 85 | public override void takeFocus() 86 | { 87 | } 88 | 89 | public override void setPos(Point pos) 90 | { 91 | Point offset = new Point(pos.X - dimensions.X, pos.Y - dimensions.Y); 92 | dimensions.X = pos.X; 93 | dimensions.Y = pos.Y; 94 | 95 | foreach(UIComponent child in children){ 96 | child.setPos(child.dimensions.X + offset.X, child.dimensions.Y + offset.Y); 97 | } 98 | } 99 | 100 | public override void setPos(int x, int y) 101 | { 102 | Point offset = new Point(x - dimensions.X, y - dimensions.Y); 103 | dimensions.X = x; 104 | dimensions.Y = y; 105 | 106 | foreach (UIComponent child in children) 107 | { 108 | child.setPos(child.dimensions.X + offset.X, child.dimensions.Y + offset.Y); 109 | } 110 | } 111 | 112 | public override bool isInDrawSpace(Rectangle drawSpace) 113 | { 114 | return dimensions.Intersects(drawSpace); 115 | } 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/AI/Behaviors/Aggravated.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework; 6 | using DreamStateMachine.Behaviors; 7 | 8 | namespace DreamStateMachine.Actions 9 | { 10 | class Aggravated:Behavior 11 | { 12 | Actor owner; 13 | Actor target; 14 | Point attackPos; 15 | Vector2 attackVector; 16 | Vector2 movement; 17 | float attackCoolDown; 18 | float pursueCountDown; 19 | TraceInfo traceInfo; 20 | 21 | public Aggravated(ActionList ownerList, Actor owner, Actor toFollow) 22 | { 23 | this.ownerList = ownerList; 24 | this.owner = owner; 25 | target = toFollow; 26 | 27 | nextPathPoint = new Point(0,0); 28 | elapsed = 0; 29 | duration = -1; 30 | attackCoolDown = 0; 31 | pursueCountDown = (2.5f); 32 | isBlocking = true; 33 | } 34 | 35 | //dummy constructor 36 | public Aggravated(Action ownerList, Actor owner) 37 | { 38 | } 39 | 40 | override public void onStart() 41 | { 42 | } 43 | 44 | override public void onEnd() 45 | { 46 | ownerList.remove(this); 47 | } 48 | 49 | override public void update(float dt) 50 | { 51 | if (pursueCountDown >= 0) 52 | { 53 | pursueCountDown -= dt; 54 | 55 | attackVector = new Vector2(owner.hitBox.Center.X - target.hitBox.Center.X, owner.hitBox.Center.Y - target.hitBox.Center.Y); 56 | attackVector.Normalize(); 57 | attackVector *= owner.reach; 58 | attackVector.X += target.hitBox.Center.X; 59 | attackVector.Y += target.hitBox.Center.Y; 60 | double distance = Math.Sqrt(Math.Pow(attackVector.X - owner.hitBox.Center.X, 2) + Math.Pow(attackVector.Y - owner.hitBox.Center.Y, 2)); 61 | if (distance > owner.reach) 62 | { 63 | attackPos = new Point((int)attackVector.X, (int)attackVector.Y); 64 | movement = new Vector2((float)(attackPos.X - owner.hitBox.Center.X), (float)(attackPos.Y - owner.hitBox.Center.Y)); 65 | movement.Normalize(); 66 | movement *= owner.maxSpeed; 67 | owner.velocity.X = movement.X; 68 | owner.velocity.Y = movement.Y; 69 | owner.isWalking = true; 70 | owner.setGaze(attackPos); 71 | } 72 | else 73 | { 74 | if (attackCoolDown <= 0) 75 | { 76 | owner.setGaze(target.hitBox.Center); 77 | owner.Light_Attack(); 78 | attackCoolDown = (float)(.5f); 79 | } 80 | else 81 | { 82 | attackCoolDown -= dt; 83 | } 84 | } 85 | 86 | } 87 | else 88 | { 89 | elapsed = 0; 90 | traceInfo = owner.world.traceWorld(owner.hitBox.Center, target.hitBox.Center); 91 | if (traceInfo.hitWorld) 92 | { 93 | Pursue pursue = new Pursue(ownerList, owner, target); 94 | ownerList.pushFront(pursue); 95 | //onEnd(); 96 | } 97 | else 98 | pursueCountDown = 2.5f; 99 | } 100 | } 101 | 102 | //void Actor_Hurt(Object sender, AttackEventArgs attackEventArgs) 103 | //{ 104 | // this.onEnd(); 105 | //} 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/Physics/Items/ItemManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework; 6 | using DreamStateMachine.Actions; 7 | using Microsoft.Xna.Framework.Graphics; 8 | using Microsoft.Xna.Framework.Content; 9 | using System.Xml.Linq; 10 | 11 | namespace DreamStateMachine.Behaviors 12 | { 13 | class ItemManager 14 | { 15 | 16 | //Dictionary itemPrototypes; 17 | Dictionary weaponPrototypes; 18 | 19 | public ItemManager() 20 | { 21 | //itemPrototypes = new Dictionary(); 22 | weaponPrototypes = new Dictionary(); 23 | Actor.OnPickUp += new EventHandler(Actor_Pickup_Item); 24 | } 25 | 26 | public void initWeaponConfig(ContentManager content, String weaponConfigFile) 27 | { 28 | XDocument weaponDoc = XDocument.Load(weaponConfigFile); 29 | List weapons = weaponDoc.Element("Weapons").Elements("Weapon").ToList(); 30 | List animations; 31 | List stances; 32 | 33 | Dictionary weaponAnimations; 34 | Dictionary weaponStances; 35 | String weaponName; 36 | Texture2D weaponTex; 37 | String animationName; 38 | String animationType; 39 | int weaponDamage; 40 | String stanceName; 41 | Vector2 gripPoint; 42 | Rectangle drawBox; 43 | 44 | foreach (XElement weapon in weapons) 45 | { 46 | weaponAnimations = new Dictionary(); 47 | weaponStances = new Dictionary(); 48 | 49 | weaponName = weapon.Attribute("name").Value; 50 | weaponTex = content.Load(weapon.Attribute("texture").Value); 51 | weaponDamage = int.Parse(weapon.Attribute("damage").Value); 52 | animations = weapon.Elements("Animation").ToList(); 53 | 54 | foreach(XElement animation in animations){ 55 | animationName = animation.Attribute("name").Value; 56 | animationType = animation.Attribute("type").Value; 57 | weaponAnimations[animationType] = animationName; 58 | } 59 | 60 | stances = weapon.Elements("Stance").ToList(); 61 | 62 | foreach(XElement stance in stances){ 63 | stanceName = stance.Attribute("name").Value; 64 | gripPoint = new Vector2(); 65 | gripPoint.X = float.Parse(stance.Attribute("gripX").Value); 66 | gripPoint.Y = float.Parse(stance.Attribute("gripY").Value); 67 | drawBox = new Rectangle(); 68 | drawBox.X = int.Parse(stance.Attribute("texX").Value); 69 | drawBox.Y = int.Parse(stance.Attribute("texY").Value); 70 | drawBox.Width = int.Parse(stance.Attribute("texWidth").Value); 71 | drawBox.Height = int.Parse(stance.Attribute("texHeight").Value); 72 | weaponStances[stanceName] = new Stance 73 | { 74 | name = stanceName, 75 | gripPoint = gripPoint, 76 | drawBox = drawBox 77 | }; 78 | } 79 | 80 | weaponPrototypes[weaponName] = new Weapon(weaponName, weaponTex, weaponDamage, weaponAnimations, weaponStances); 81 | 82 | } 83 | } 84 | 85 | private void Actor_Pickup_Item(Object sender, PickupEventArgs pickupEventArgs) 86 | { 87 | Actor pickingUpActor = (Actor)sender; 88 | pickingUpActor.giveWeapon((Weapon)weaponPrototypes[pickupEventArgs.itemClassName].Clone()); 89 | } 90 | 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/AI/AIController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework; 6 | using DreamStateMachine.Actions; 7 | using Microsoft.Xna.Framework.Graphics; 8 | using Microsoft.Xna.Framework.Content; 9 | using System.Xml.Linq; 10 | 11 | namespace DreamStateMachine.Behaviors 12 | { 13 | class AIController 14 | { 15 | Dictionary behaviorLists; 16 | public Actor protagonist; 17 | 18 | public AIController() 19 | { 20 | 21 | behaviorLists = new Dictionary(); 22 | 23 | Actor.Spawn += new EventHandler(Actor_Spawn); 24 | Actor.Hurt += new EventHandler(Actor_Hurt); 25 | Actor.Death += new EventHandler(Actor_Death); 26 | 27 | WorldManager.worldChange += new EventHandler(World_Change); 28 | } 29 | 30 | private void Actor_Spawn(object sender, SpawnEventArgs e) 31 | { 32 | Actor spawnedActor = (Actor)sender; 33 | if (spawnedActor.className == "player") 34 | { 35 | protagonist = spawnedActor; 36 | } 37 | else 38 | { 39 | ActionList behaviorList = new ActionList(spawnedActor); 40 | Neutral neutral = new Neutral(behaviorList, spawnedActor); 41 | behaviorList.pushFront(neutral); 42 | Alert alert = new Alert(behaviorList, spawnedActor, protagonist); 43 | behaviorList.pushFront(alert); 44 | behaviorLists[spawnedActor] = behaviorList; 45 | } 46 | //actors.Add(spawnedActor); 47 | } 48 | 49 | private void Actor_Hurt(object sender, AttackEventArgs attackArgs) 50 | { 51 | Actor victim = (Actor) sender; 52 | if (behaviorLists.ContainsKey(victim)) 53 | { 54 | ActionList victimBehaviorList = behaviorLists[victim]; 55 | Aggravated aggravated = new Aggravated(victimBehaviorList, victim, attackArgs.damageInfo.attacker); 56 | Stunned stunned = new Stunned(victimBehaviorList, victim); 57 | if (!victimBehaviorList.has(aggravated) && !victimBehaviorList.has(stunned)) 58 | victimBehaviorList.pushFront(aggravated); 59 | if (!victimBehaviorList.has(stunned)) 60 | victimBehaviorList.pushFront(stunned); 61 | 62 | } 63 | 64 | } 65 | 66 | private void Actor_Death(object sender, EventArgs e) 67 | { 68 | Actor victim = (Actor)sender; 69 | if (behaviorLists.ContainsKey(victim)) 70 | { 71 | behaviorLists.Remove(victim); 72 | } 73 | else if(victim.className == "player") 74 | { 75 | Aggravated aggravated = new Aggravated(null, null); 76 | Alert alert = new Alert(null, null); 77 | foreach(KeyValuePair entry in behaviorLists) 78 | { 79 | if (entry.Value.has(aggravated)) 80 | { 81 | entry.Value.remove(aggravated); 82 | } 83 | if (entry.Value.has(alert)) 84 | { 85 | entry.Value.remove(alert); 86 | } 87 | } 88 | } 89 | } 90 | 91 | public void update(float dt){ 92 | foreach (KeyValuePair entry in behaviorLists) 93 | { 94 | entry.Value.update(dt); 95 | } 96 | } 97 | 98 | private void World_Change(object sender, EventArgs eventsArgs) 99 | { 100 | behaviorLists.Clear(); 101 | } 102 | 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /DreamStateMachine/Libs/ActionList/ActionList.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace DreamStateMachine 7 | { 8 | class ActionList 9 | { 10 | private Actor owner; 11 | private List actions; 12 | private Action curAction; 13 | 14 | public ActionList(Actor o) 15 | { 16 | actions = new List(); 17 | owner = o; 18 | } 19 | 20 | public void endAll() 21 | { 22 | for (int i = 0; i < actions.Count; i++) 23 | { 24 | curAction = actions.ElementAt(i); 25 | curAction.onEnd(); 26 | } 27 | } 28 | 29 | public void update(float dt){ 30 | for (int i = 0; i < actions.Count; i++) 31 | { 32 | curAction = actions.ElementAt(i); 33 | if (!curAction.isStarted) 34 | { 35 | curAction.onStart(); 36 | curAction.isStarted = true; 37 | } 38 | 39 | curAction.update(dt); 40 | 41 | if ((curAction.duration <= curAction.elapsed && curAction.duration != -1) || curAction.isFinished) 42 | curAction.onEnd(); 43 | else if (curAction.isBlocking) 44 | i = actions.Count; 45 | 46 | //Console.WriteLine("Elapsed:" + curAction.elapsed); 47 | //Console.WriteLine("Duration:" + curAction.duration); 48 | 49 | 50 | } 51 | 52 | } 53 | 54 | public void pushFront(Action action){ 55 | //Console.WriteLine("push is getting called"); 56 | //Console.WriteLine(actions.Count); 57 | actions.Insert(0, action); 58 | //Console.WriteLine(actions.Count); 59 | } 60 | 61 | public void pushBack(Action action) 62 | { 63 | actions.Add(action); 64 | } 65 | 66 | public Action remove(Action action) 67 | { 68 | Action toRemove = action; 69 | //actions.Remove(action); 70 | actions.RemoveAll(x => x.GetType() == action.GetType()); 71 | return toRemove; 72 | } 73 | 74 | public bool has(Action action) 75 | { 76 | //Console.WriteLine(action.GetType()); 77 | //Console.WriteLine("Num actions in has:" + actions.Count); 78 | if (actions.Count > 0) 79 | { 80 | for (int i = 0; i < actions.Count; i++) 81 | { 82 | Action curAction = actions.ElementAt(i); 83 | //Console.WriteLine(curAction.GetType()); 84 | if (curAction.GetType().Equals(action.GetType())) 85 | { 86 | //Console.WriteLine("this worked"); 87 | return true; 88 | } 89 | } 90 | return false; 91 | } 92 | else 93 | { 94 | return false; 95 | } 96 | } 97 | 98 | public Action begin() 99 | { 100 | return actions.ElementAtOrDefault(0); 101 | } 102 | 103 | public Action end() 104 | { 105 | return actions.ElementAt(actions.Count - 1); 106 | } 107 | 108 | public bool isEmpty() 109 | { 110 | return actions.Count == 0; 111 | } 112 | 113 | public float timeLeft() 114 | { 115 | Action curAction = this.begin(); 116 | float totalTime = 0; 117 | while (!curAction.isBlocking) 118 | totalTime += (curAction.duration - curAction.elapsed); 119 | 120 | return totalTime; 121 | } 122 | 123 | public int getSize() 124 | { 125 | return actions.Count(); 126 | } 127 | 128 | 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/Actor/ActorController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework; 6 | using DreamStateMachine.Actions; 7 | using Microsoft.Xna.Framework.Graphics; 8 | using Microsoft.Xna.Framework.Content; 9 | using System.Xml.Linq; 10 | 11 | namespace DreamStateMachine.Behaviors 12 | { 13 | class ActorController 14 | { 15 | Dictionary actionLists; 16 | List actors; 17 | Actor curActor; 18 | Walk walk = new Walk(); 19 | 20 | public ActorController() 21 | { 22 | //actorLists = new Dictionary>(); 23 | actionLists = new Dictionary(); 24 | actors = new List(); 25 | 26 | Actor.LightAttack += new EventHandler(Actor_Light_Attack); 27 | Actor.Death += new EventHandler(Actor_Death); 28 | Actor.Hurt += new EventHandler(Actor_Hurt); 29 | Actor.Spawn += new EventHandler(Actor_Spawn); 30 | WorldManager.worldChange += new EventHandler(World_Change); 31 | } 32 | 33 | private void Actor_Light_Attack(Object sender, EventArgs e) 34 | { 35 | Actor inputtingActor = (Actor)sender; 36 | //Punch punch = new Punch(actionLists[inputtingActor], inputtingActor); 37 | Attack attack = new Attack(actionLists[inputtingActor], inputtingActor); 38 | Recoil recoil = new Recoil(actionLists[inputtingActor], inputtingActor); 39 | if (!actionLists[inputtingActor].has(attack) && !actionLists[inputtingActor].has(recoil)) 40 | { 41 | actionLists[inputtingActor].pushFront(attack); 42 | } 43 | } 44 | 45 | private void Actor_Death(Object sender, EventArgs e) 46 | { 47 | SoundManager.Instance.playSound("death"); 48 | actors.Remove((Actor)sender); 49 | } 50 | 51 | private void Actor_Hurt(Object sender, EventArgs e) 52 | { 53 | SoundManager.Instance.playSound("hurt1"); 54 | Actor hurtActor = (Actor)sender; 55 | Recoil recoil = new Recoil(actionLists[hurtActor], hurtActor); 56 | if (!actionLists[hurtActor].has(recoil)) 57 | actionLists[hurtActor].pushFront(recoil); 58 | 59 | } 60 | 61 | private void Actor_Spawn(Object sender, SpawnEventArgs e) 62 | { 63 | Actor spawnedActor = (Actor)sender; 64 | ActionList actionList = new ActionList(spawnedActor); 65 | actionLists[spawnedActor] = actionList; 66 | actors.Add(spawnedActor); 67 | Idle idle = new Idle(actionLists[spawnedActor], spawnedActor); 68 | actionLists[spawnedActor].pushFront(idle); 69 | spawnedActor.id = actors.IndexOf(spawnedActor); 70 | } 71 | 72 | public void handleActorUse(Actor actor, Point usePoint) 73 | { 74 | 75 | } 76 | 77 | public void update(float dt) 78 | { 79 | for (int i = 0; i < actors.Count; i++) 80 | { 81 | curActor = actors.ElementAt(i); 82 | 83 | if ((curActor.velocity.X != 0 || curActor.velocity.Y != 0) && curActor.isWalking && !actionLists[curActor].has(walk)) 84 | { 85 | walk = new Walk(actionLists[curActor], curActor); 86 | if (actionLists[curActor].getSize() == 0 || (actionLists[curActor].getSize() > 0 && !actionLists[curActor].begin().isBlocking)) 87 | actionLists[curActor].pushFront(walk); 88 | } 89 | curActor.update(dt); 90 | actionLists[curActor].update(dt); 91 | } 92 | 93 | 94 | } 95 | 96 | private void World_Change(object sender, EventArgs eventsArgs) 97 | { 98 | WorldManager worldManager = (WorldManager) sender; 99 | World curWorld = worldManager.curWorld; 100 | foreach (Actor actor in actors) 101 | { 102 | actor.remove(); 103 | } 104 | actors.Clear(); 105 | actionLists.Clear(); 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/GUI/UIComponent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework; 6 | using Microsoft.Xna.Framework.Graphics; 7 | 8 | namespace DreamStateMachine.Game.GUI 9 | { 10 | abstract class UIComponent:IDrawable 11 | { 12 | 13 | public static event EventHandler Initialize; 14 | public static event EventHandler Remove; 15 | 16 | public UIComponent parent; 17 | public List children; 18 | public Rectangle dimensions; 19 | public bool hasFocus = false; 20 | public bool canHaveFocus = false; 21 | public abstract void draw(SpriteBatch spriteBatch, Rectangle drawSpace, Texture2D debugTex, bool debugging = false); 22 | public abstract bool isInDrawSpace(Rectangle drawSpace); 23 | public abstract UIComponent findFocusedChild(); 24 | public delegate void clickDelegate(); 25 | public clickDelegate onClick; 26 | public abstract void giveFocus(); 27 | public abstract void takeFocus(); 28 | public abstract void setPos(Point pos); 29 | public abstract void setPos(int x, int y); 30 | 31 | public UIComponent() 32 | { 33 | children = new List(); 34 | } 35 | 36 | public void rotateFocusNext() 37 | { 38 | UIComponent neighbor; 39 | neighbor = findNextNeighbor(); 40 | while (neighbor != null) 41 | { 42 | if (neighbor.canHaveFocus) 43 | { 44 | neighbor.giveFocus(); 45 | neighbor = null; 46 | } 47 | else { 48 | neighbor = findNextNeighbor(); 49 | } 50 | } 51 | } 52 | 53 | public void rotateFocusPrev() 54 | { 55 | UIComponent neighbor; 56 | neighbor = findPrevNeighbor(); 57 | while (neighbor != null) 58 | { 59 | if (neighbor.canHaveFocus) 60 | { 61 | neighbor.giveFocus(); 62 | neighbor = null; 63 | } 64 | else 65 | { 66 | neighbor = findPrevNeighbor(); 67 | } 68 | } 69 | } 70 | 71 | public UIComponent findNextNeighbor() 72 | { 73 | if (parent.children.Count > 0) 74 | { 75 | int curIndex = parent.children.IndexOf(this); 76 | curIndex++; 77 | UIComponent curChild; 78 | if (curIndex == parent.children.Count) 79 | { 80 | curIndex = 0; 81 | curChild = parent.children[curIndex]; 82 | } 83 | else 84 | { 85 | curChild = parent.children[curIndex]; 86 | } 87 | return curChild; 88 | } 89 | return null; 90 | } 91 | 92 | public UIComponent findPrevNeighbor() 93 | { 94 | if (parent.children.Count > 0) 95 | { 96 | int curIndex = parent.children.IndexOf(this); 97 | curIndex--; 98 | UIComponent curChild; 99 | if (curIndex == -1) 100 | { 101 | curIndex = parent.children.Count - 1; 102 | curChild = parent.children[curIndex]; 103 | } 104 | else 105 | { 106 | curChild = parent.children[curIndex]; 107 | } 108 | return curChild; 109 | } 110 | return null; 111 | } 112 | 113 | public void initialize() 114 | { 115 | Initialize(this, EventArgs.Empty); 116 | foreach (UIComponent uiChild in children) 117 | { 118 | uiChild.initialize(); 119 | } 120 | } 121 | 122 | public void remove() 123 | { 124 | Remove(this, EventArgs.Empty); 125 | foreach (UIComponent uiChild in children) 126 | { 127 | uiChild.remove(); 128 | } 129 | } 130 | 131 | public virtual void update(float dt) 132 | { 133 | } 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/Input/InputHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework.Input; 6 | using Microsoft.Xna.Framework; 7 | 8 | namespace DreamStateMachine.Input 9 | { 10 | class InputHandler 11 | { 12 | 13 | public event EventHandler pauseButtonPressed; 14 | 15 | public bool controller = false; 16 | float pauseCoolDown = 0; 17 | KeyboardState keyBoardState; 18 | MouseState mouseState; 19 | GamePadState padState; 20 | Point origin; 21 | 22 | public InputHandler(Point origin) 23 | { 24 | this.origin = origin; 25 | } 26 | 27 | public List handleInput() 28 | { 29 | List c; 30 | if (controller) 31 | c = handleController(); 32 | else 33 | c = handleKeyBoardMouse(); 34 | return c; 35 | } 36 | 37 | private List handleController() 38 | { 39 | List commands = new List(); 40 | padState = GamePad.GetState(Microsoft.Xna.Framework.PlayerIndex.One); 41 | 42 | Vector2 move = new Vector2(); 43 | move.X = 0; 44 | move.Y = 0; 45 | if (padState.ThumbSticks.Left.Length() > .7f) 46 | { 47 | move.X = padState.ThumbSticks.Left.X * .7f; 48 | move.Y = -padState.ThumbSticks.Left.Y * .7f; 49 | } 50 | commands.Add(new MoveCommand(move)); 51 | 52 | 53 | Vector2 gazeDir = new Vector2(); 54 | gazeDir.X = padState.ThumbSticks.Right.X; 55 | gazeDir.Y = -padState.ThumbSticks.Right.Y; 56 | commands.Add(new GazeCommand(gazeDir)); 57 | 58 | if (padState.IsButtonDown(Buttons.RightShoulder)) 59 | commands.Add(new PunchCommand()); 60 | if (padState.IsButtonDown(Buttons.X)) 61 | commands.Add(new UseCommand()); 62 | if (padState.IsButtonDown(Buttons.Y)) 63 | commands.Add(new RotateWeaponCommand()); 64 | if(padState.IsButtonDown(Buttons.Start)) 65 | { 66 | if (pauseCoolDown <= 0) 67 | { 68 | pauseButtonPressed(this, EventArgs.Empty); 69 | pauseCoolDown = .25f; 70 | } 71 | } 72 | 73 | return commands; 74 | } 75 | 76 | private List handleKeyBoardMouse() 77 | { 78 | List commands = new List(); 79 | mouseState = Mouse.GetState(); 80 | keyBoardState = Keyboard.GetState(); 81 | 82 | Vector2 moveDir = new Vector2(); 83 | moveDir.X = 0; 84 | moveDir.Y = 0; 85 | if (keyBoardState.IsKeyDown(Keys.A)) 86 | moveDir.X = -.7f; 87 | if (keyBoardState.IsKeyDown(Keys.D)) 88 | moveDir.X = .7f; 89 | if (keyBoardState.IsKeyDown(Keys.W)) 90 | moveDir.Y = -.7f; 91 | if (keyBoardState.IsKeyDown(Keys.S)) 92 | moveDir.Y = .7f; 93 | 94 | commands.Add(new MoveCommand(moveDir)); 95 | 96 | if (keyBoardState.IsKeyDown(Keys.Space)) 97 | commands.Add(new PunchCommand()); 98 | if (keyBoardState.IsKeyDown(Keys.E)) 99 | { 100 | commands.Add(new UseCommand()); 101 | } 102 | //if (keyBoardState.IsKeyDown(Keys.G)) 103 | //{ 104 | // commands.Add(new DebugCommand()); 105 | //} 106 | if (keyBoardState.IsKeyDown(Keys.Q)) 107 | { 108 | commands.Add(new RotateWeaponCommand()); 109 | } 110 | if (keyBoardState.IsKeyDown(Keys.Escape)) 111 | { 112 | if (pauseCoolDown <= 0) 113 | { 114 | pauseButtonPressed(this, EventArgs.Empty); 115 | pauseCoolDown = .25f; 116 | } 117 | } 118 | 119 | float curMousePosX = mouseState.X; 120 | float curMousePosY = mouseState.Y; 121 | 122 | Vector2 playerDir = new Vector2(curMousePosX - origin.X, curMousePosY - origin.Y); 123 | 124 | commands.Add(new GazeCommand(playerDir)); 125 | 126 | if (mouseState.LeftButton == ButtonState.Pressed) 127 | commands.Add(new PunchCommand()); 128 | 129 | return commands; 130 | } 131 | 132 | public void update(float dt) 133 | { 134 | if (pauseCoolDown > 0) 135 | pauseCoolDown -= dt; 136 | } 137 | 138 | } 139 | } -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/Weapons.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 18 | 19 | 26 | 27 | 28 | 29 | 33 | 34 | 35 | 36 | 37 | 44 | 45 | 52 | 53 | 54 | 55 | 59 | 60 | 61 | 62 | 63 | 70 | 71 | 78 | 79 | 80 | 81 | 85 | 86 | 87 | 88 | 89 | 96 | 97 | 104 | 105 | 106 | 107 | 111 | 112 | 113 | 114 | 115 | 122 | 123 | 130 | 131 | 132 | 133 | 137 | 138 | 139 | 140 | 141 | 148 | 149 | 156 | 157 | 158 | 159 | 163 | 164 | 165 | 166 | 167 | 174 | 175 | 182 | 183 | 184 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/World/Prop.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework.Graphics; 6 | using Microsoft.Xna.Framework; 7 | //using MonoGame.Framework; 8 | using DreamStateMachine.Actions; 9 | 10 | 11 | namespace DreamStateMachine 12 | { 13 | class Prop:ICloneable, IDrawable 14 | { 15 | public static event EventHandler Spawn; 16 | public static event EventHandler Remove; 17 | 18 | 19 | //public Attributes attributes; 20 | public Color color; 21 | public Point curAnimFrame; 22 | public Texture2D texture; 23 | 24 | public Rectangle hitBox; 25 | public Rectangle body; 26 | public String className; 27 | public float rotation; 28 | 29 | public World world; 30 | //public Weapon activeWeapon; 31 | 32 | 33 | public Prop(Texture2D tex, int width, int height, int texWidth, int texHeight) 34 | { 35 | texture = tex; 36 | 37 | color = new Color(255, 255, 255, 255); 38 | 39 | hitBox = new Rectangle(0, 0, width, height); 40 | body = new Rectangle(0, 0, texWidth, texHeight); 41 | 42 | } 43 | 44 | public virtual Object Clone() 45 | { 46 | Prop PropCopy = new Prop(texture, hitBox.Width, hitBox.Height, body.Width, body.Height); 47 | 48 | PropCopy.className = className; 49 | PropCopy.texture = texture; 50 | PropCopy.color = color; 51 | 52 | return PropCopy; 53 | } 54 | 55 | 56 | public void draw(SpriteBatch spriteBatch, Rectangle drawSpace, Texture2D debugTex, bool debugging = false) 57 | { 58 | Rectangle normalizedPosition; 59 | Rectangle sourceRectangle; 60 | Texture2D tex; 61 | tex = this.getTexture(); 62 | normalizedPosition = new Rectangle(this.body.X - drawSpace.X, 63 | this.body.Y - drawSpace.Y, 64 | this.body.Width, 65 | this.body.Height); 66 | 67 | 68 | sourceRectangle = new Rectangle(this.curAnimFrame.X * this.body.Width, 69 | this.curAnimFrame.Y * this.body.Height, 70 | this.body.Width, 71 | this.body.Height); 72 | 73 | spriteBatch.Draw( 74 | tex, 75 | new Vector2(normalizedPosition.X + this.body.Width / 2, normalizedPosition.Y + this.body.Height / 2), 76 | sourceRectangle, 77 | this.color, 78 | this.rotation, 79 | new Vector2(normalizedPosition.Width / 2.0f, normalizedPosition.Height / 2.0f), 80 | 1, 81 | SpriteEffects.None, 82 | 0 83 | ); 84 | } 85 | 86 | public bool isInDrawSpace(Rectangle drawSpace) 87 | { 88 | return this.hitBox.Intersects(drawSpace); 89 | } 90 | 91 | public void onSpawn( Point spawnTile, int spawnType ) 92 | { 93 | SpawnEventArgs spawnEventArgs = new SpawnEventArgs(spawnTile, spawnType); 94 | Spawn(this, spawnEventArgs); 95 | } 96 | 97 | public void onUse() 98 | { 99 | 100 | } 101 | 102 | public void setAnimationFrame(int x, int y) 103 | { 104 | curAnimFrame.X = x; 105 | curAnimFrame.Y = y; 106 | } 107 | 108 | 109 | public void setPos(int x, int y) 110 | { 111 | hitBox.X = x; 112 | hitBox.Y = y; 113 | body.X = hitBox.Center.X - (int)(body.Width / 2.0); 114 | body.Y = hitBox.Center.Y - (int)(body.Height / 2.0); 115 | } 116 | 117 | public void setPos(Point point) 118 | { 119 | hitBox.X = point.X; 120 | hitBox.Y = point.Y; 121 | body.X = hitBox.Center.X - (int)(body.Width / 2.0); 122 | body.Y = hitBox.Center.Y - (int)(body.Height / 2.0); 123 | } 124 | 125 | public Rectangle getHitBox() 126 | { 127 | return hitBox; 128 | } 129 | 130 | public Rectangle getBodyBox() 131 | { 132 | return body; 133 | } 134 | 135 | public Texture2D getTexture() 136 | { 137 | return texture; 138 | } 139 | 140 | public void onRemove() 141 | { 142 | Remove(this, EventArgs.Empty); 143 | } 144 | 145 | virtual public void update(float dt) 146 | { 147 | } 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/Actor/Animations/Attack.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework; 6 | using DreamStateMachine.Behaviors; 7 | 8 | namespace DreamStateMachine.Actions 9 | { 10 | class Attack:Animation 11 | { 12 | ActionList ownerList; 13 | Actor owner; 14 | AnimationInfo animationInfo; 15 | FrameInfo frameInfo; 16 | Point frameIndex; 17 | Rectangle damageRect; 18 | List attackBoxes; 19 | 20 | public Attack(ActionList ownerList, Actor owner) 21 | { 22 | this.ownerList = ownerList; 23 | this.owner = owner; 24 | isBlocking = true; 25 | frameIndex = new Point(0, 0); 26 | damageRect = new Rectangle(0, 0, 0, 0); 27 | attackBoxes = new List(); 28 | setAnimationInfo(); 29 | duration = ((float)animationInfo.frameCount)/ animationInfo.fps; 30 | curFrame = 0; 31 | lastFrame = -1; 32 | 33 | owner.HitActor += Actor_Hit; 34 | } 35 | 36 | private void setAnimationInfo() 37 | { 38 | if (owner.activeWeapon != null && owner.animations.ContainsKey(owner.activeWeapon.animations["light_weapon_attack"])) 39 | { 40 | this.animationInfo = owner.animations[owner.activeWeapon.animations["light_weapon_attack"]]; 41 | } 42 | else if (owner.animations.ContainsKey("unnarmed_light_attack")) 43 | { 44 | this.animationInfo = owner.animations["unnarmed_light_attack"]; 45 | } 46 | } 47 | 48 | override public void onStart() 49 | { 50 | SoundManager.Instance.playSound("woosh"); 51 | } 52 | 53 | override public void onEnd() 54 | { 55 | //owner.setAnimationFrame(3, 0); 56 | ownerList.remove(this); 57 | 58 | } 59 | 60 | public override void onEnterFrame(int frame) 61 | { 62 | //setAnimationInfo(); 63 | frameIndex.X = animationInfo.texColumn + curFrame; 64 | frameIndex.Y = animationInfo.texRow; 65 | owner.setAnimationFrame(frameIndex.X, frameIndex.Y); 66 | frameInfo = animationInfo.frames[frame]; 67 | if (owner.activeWeapon != null) 68 | { 69 | owner.gripPoint = frameInfo.gripPoint; 70 | owner.activeWeapon.setStance(frameInfo.stance); 71 | owner.activeWeapon.frameRotation = frameInfo.rotation; 72 | } 73 | if (frameInfo.attackPoints != null && frameInfo.attackPoints.Count > 0) 74 | { 75 | attackBoxes = new List(); 76 | foreach (Rectangle attackPoint in frameInfo.attackPoints) 77 | { 78 | Point offset = new Point(attackPoint.X, attackPoint.Y); 79 | float s = (float)(Math.Sin(owner.bodyRotation)); 80 | float c = (float)(Math.Cos(owner.bodyRotation)); 81 | Point newOffset = new Point((int)(offset.X * c - offset.Y * s), (int)(offset.X * s + offset.Y * c)); 82 | damageRect = new Rectangle(); 83 | damageRect.Width = attackPoint.Width; 84 | damageRect.Height = attackPoint.Height; 85 | damageRect.X = owner.hitBox.Center.X + newOffset.X - damageRect.Width / 2; 86 | damageRect.Y = owner.hitBox.Center.Y + newOffset.Y - damageRect.Height / 2; 87 | 88 | attackBoxes.Add(damageRect); 89 | } 90 | DamageInfo damageInfo; 91 | if (owner.activeWeapon != null) 92 | { 93 | damageInfo = new DamageInfo(owner, (int)(owner.activeWeapon.damage * owner.damageFactor), this.attackBoxes); 94 | } 95 | else 96 | { 97 | damageInfo = new DamageInfo(owner, (int)(frameInfo.attackDamage * owner.damageFactor), this.attackBoxes); 98 | } 99 | 100 | owner.onAttack(damageInfo); 101 | attackBoxes.Clear(); 102 | } 103 | 104 | } 105 | 106 | override public void update(float dt) 107 | { 108 | elapsed += dt; 109 | curFrame = (int)(elapsed * animationInfo.fps); 110 | if (curFrame < animationInfo.frameCount) 111 | { 112 | if (curFrame != lastFrame) 113 | { 114 | onEnterFrame(curFrame); 115 | lastFrame = curFrame; 116 | } 117 | } 118 | else 119 | { 120 | isFinished = true; 121 | } 122 | } 123 | 124 | private void Actor_Hit(object sender, EventArgs eventArgs) 125 | { 126 | } 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/Rendering/Camera.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework; 6 | using Microsoft.Xna.Framework.Graphics; 7 | using Microsoft.Xna.Framework.Content; 8 | using DreamStateMachine.Game.GUI; 9 | using Microsoft.Xna.Framework.Input; 10 | 11 | namespace DreamStateMachine 12 | { 13 | class Camera 14 | { 15 | 16 | public Rectangle drawSpace; 17 | public Texture2D debugTex; 18 | public List actors; 19 | public List props; 20 | public List gui; 21 | 22 | Actor protagonist; 23 | World curWorld; 24 | SpriteBatch spriteBatch; 25 | bool debug; 26 | 27 | public Camera(SpriteBatch sB, Rectangle dS) 28 | { 29 | spriteBatch = sB; 30 | drawSpace = dS; 31 | actors = new List(); 32 | props = new List(); 33 | gui = new List(); 34 | 35 | debug = false; 36 | 37 | Actor.Spawn += new EventHandler(Actor_Spawn); 38 | Actor.Death += new EventHandler(Actor_Death); 39 | Prop.Remove += new EventHandler(Prop_Remove); 40 | Prop.Spawn += new EventHandler(Prop_Spawn); 41 | UIComponent.Initialize += new EventHandler(UIComponent_Initialize); 42 | UIComponent.Remove += new EventHandler(UIComponent_Remove); 43 | WorldManager.worldChange += new EventHandler(World_Change); 44 | } 45 | 46 | 47 | public void loadDebugTex(ContentManager content) 48 | { 49 | debugTex = content.Load("debugSquare"); 50 | } 51 | 52 | private void Actor_Death(object sender, EventArgs e) 53 | { 54 | Actor deadActor = (Actor)sender; 55 | actors.Remove(deadActor); 56 | } 57 | 58 | private void Actor_Spawn(object sender, EventArgs e) 59 | { 60 | Actor spawnedActor = (Actor)sender; 61 | actors.Add(spawnedActor); 62 | if (spawnedActor.className == "player") 63 | { 64 | protagonist = spawnedActor; 65 | } 66 | } 67 | 68 | private void Prop_Spawn(object sender, EventArgs e) 69 | { 70 | Prop spawnedProp = (Prop)sender; 71 | props.Add(spawnedProp); 72 | } 73 | 74 | private void Prop_Remove(object sender, EventArgs e) 75 | { 76 | Prop toRemove = (Prop)sender; 77 | props.Remove(toRemove); 78 | } 79 | 80 | 81 | 82 | public void ToggleDebug(){ 83 | debug = !debug; 84 | } 85 | 86 | public void drawActors() 87 | { 88 | IDrawable curActor; 89 | 90 | for (int i = 0; i < actors.Count; i++) 91 | { 92 | curActor = actors.ElementAt(i); 93 | if (curActor.isInDrawSpace(drawSpace)) 94 | { 95 | curActor.draw(spriteBatch, drawSpace, debugTex, debug); 96 | } 97 | } 98 | } 99 | 100 | public void drawFloor() 101 | { 102 | curWorld.draw(spriteBatch, drawSpace, debugTex, debug); 103 | } 104 | 105 | public void drawGUI() 106 | { 107 | foreach (IDrawable guiItem in gui) 108 | { 109 | guiItem.draw(spriteBatch, drawSpace, debugTex, debug); 110 | } 111 | } 112 | 113 | public void drawPauseMenu() 114 | { 115 | //pausePanel.draw(spriteBatch, drawSpace, debugTex, false); 116 | //pauseLabel.draw(spriteBatch, drawSpace, debugTex, false); 117 | //pauseButton.draw(spriteBatch, drawSpace, debugTex, false); 118 | } 119 | 120 | public void drawProps() 121 | { 122 | foreach (Prop prop in props) 123 | { 124 | prop.draw(spriteBatch, drawSpace, debugTex, false); 125 | } 126 | } 127 | 128 | public void setDrawSpace(Rectangle rect) 129 | { 130 | drawSpace = rect; 131 | } 132 | 133 | public void setFocus(int x, int y) 134 | { 135 | drawSpace.X = x - (drawSpace.Width / 2); 136 | drawSpace.Y = y - (drawSpace.Height / 2); 137 | } 138 | 139 | public void gameUpdate(float dt) 140 | { 141 | if (drawSpace.Center.X != protagonist.hitBox.Center.X || drawSpace.Center.Y != protagonist.hitBox.Center.Y) 142 | setFocus(protagonist.hitBox.Center.X, protagonist.hitBox.Center.Y); 143 | } 144 | 145 | private void UIComponent_Initialize(Object sender, EventArgs eventArgs) 146 | { 147 | UIComponent component = (UIComponent)sender; 148 | gui.Add(component); 149 | } 150 | 151 | private void UIComponent_Remove(Object sender, EventArgs eventArgs) 152 | { 153 | UIComponent component = (UIComponent)sender; 154 | gui.Remove(component); 155 | } 156 | 157 | private void World_Change(Object sender, EventArgs eventArgs) 158 | { 159 | 160 | WorldManager worldManager = (WorldManager)sender; 161 | curWorld = worldManager.curWorld; 162 | actors.Clear(); 163 | } 164 | } 165 | } 166 | -------------------------------------------------------------------------------- /DreamStateMachine/DreamStateMachine.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | x86 6 | 8.0.30703 7 | 2.0 8 | {F6C16952-7674-4C89-8534-F927DA1A2167} 9 | WinExe 10 | Properties 11 | DreamStateMachine2 12 | DreamStateMachine1 13 | 512 14 | 15 | 16 | x86 17 | true 18 | full 19 | false 20 | bin\Windows\Debug\ 21 | DEBUG;TRACE;WINDOWS 22 | prompt 23 | 4 24 | 25 | 26 | x86 27 | pdbonly 28 | true 29 | bin\Windows\Release\ 30 | TRACE;WINDOWS 31 | prompt 32 | 4 33 | 34 | 35 | Icon.ico 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | ..\..\..\..\..\..\..\Program Files (x86)\MSBuild\..\MonoGame\v3.0\Assemblies\Windows\MonoGame.Framework.dll 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | {313BB489-E187-4B9D-8926-8E14B4B02B20} 127 | DSMWindowsContent 128 | 129 | 130 | 131 | 138 | -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/Animations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12 | 15 | 19 | 20 | 21 | 22 | 23 | 32 | 35 | 39 | 40 | 41 | 42 | 43 | 52 | 55 | 59 | 60 | 61 | 62 | 63 | 73 | 76 | 80 | 81 | 82 | 83 | 84 | 93 | 94 | 95 | 104 | 105 | 106 | 115 | 116 | 117 | 126 | 127 | 128 | 137 | 143 | 144 | 150 | 151 | 157 | 158 | 164 | 165 | 171 | 172 | 178 | 179 | 185 | 186 | 192 | 193 | 199 | 200 | 206 | 207 | 208 | 209 | 218 | 225 | 226 | 233 | 234 | 241 | 245 | 246 | 250 | 251 | 255 | 256 | 257 | 264 | 265 | 272 | 273 | 280 | 281 | 288 | 289 | 296 | 297 | 298 | 299 | 308 | 314 | 315 | 316 | -------------------------------------------------------------------------------- /DSMContentProject/DSMContentProcessor/Actors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 236 | 237 | 238 | 239 | 240 | 241 | 253 | 254 | 255 | 256 | 257 | -------------------------------------------------------------------------------- /DreamStateMachineProject.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual C# Express 2010 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DreamStateMachine", "DreamStateMachine\DreamStateMachine.csproj", "{F6C16952-7674-4C89-8534-F927DA1A2167}" 5 | EndProject 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DSMWindowsContent", "DSMContentProject\DSMWindowsContent\DSMWindowsContent.csproj", "{313BB489-E187-4B9D-8926-8E14B4B02B20}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DSMContentProcessor", "DSMContentProject\DSMContentProcessor\DSMContentProcessor.contentproj", "{2037DFA6-4065-498F-B91B-9C4C29D433A4}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Android|Any CPU = Android|Any CPU 13 | Android|Mixed Platforms = Android|Mixed Platforms 14 | Android|x86 = Android|x86 15 | Debug|Any CPU = Debug|Any CPU 16 | Debug|Mixed Platforms = Debug|Mixed Platforms 17 | Debug|x86 = Debug|x86 18 | iOS|Any CPU = iOS|Any CPU 19 | iOS|Mixed Platforms = iOS|Mixed Platforms 20 | iOS|x86 = iOS|x86 21 | Linux|Any CPU = Linux|Any CPU 22 | Linux|Mixed Platforms = Linux|Mixed Platforms 23 | Linux|x86 = Linux|x86 24 | OSX|Any CPU = OSX|Any CPU 25 | OSX|Mixed Platforms = OSX|Mixed Platforms 26 | OSX|x86 = OSX|x86 27 | PSM|Any CPU = PSM|Any CPU 28 | PSM|Mixed Platforms = PSM|Mixed Platforms 29 | PSM|x86 = PSM|x86 30 | Release|Any CPU = Release|Any CPU 31 | Release|Mixed Platforms = Release|Mixed Platforms 32 | Release|x86 = Release|x86 33 | Windows|Any CPU = Windows|Any CPU 34 | Windows|Mixed Platforms = Windows|Mixed Platforms 35 | Windows|x86 = Windows|x86 36 | Windows8|Any CPU = Windows8|Any CPU 37 | Windows8|Mixed Platforms = Windows8|Mixed Platforms 38 | Windows8|x86 = Windows8|x86 39 | EndGlobalSection 40 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 41 | {F6C16952-7674-4C89-8534-F927DA1A2167}.Android|Any CPU.ActiveCfg = Release|x86 42 | {F6C16952-7674-4C89-8534-F927DA1A2167}.Android|Mixed Platforms.ActiveCfg = Release|x86 43 | {F6C16952-7674-4C89-8534-F927DA1A2167}.Android|Mixed Platforms.Build.0 = Release|x86 44 | {F6C16952-7674-4C89-8534-F927DA1A2167}.Android|x86.ActiveCfg = Release|x86 45 | {F6C16952-7674-4C89-8534-F927DA1A2167}.Android|x86.Build.0 = Release|x86 46 | {F6C16952-7674-4C89-8534-F927DA1A2167}.Debug|Any CPU.ActiveCfg = Debug|x86 47 | {F6C16952-7674-4C89-8534-F927DA1A2167}.Debug|Any CPU.Build.0 = Debug|x86 48 | {F6C16952-7674-4C89-8534-F927DA1A2167}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 49 | {F6C16952-7674-4C89-8534-F927DA1A2167}.Debug|Mixed Platforms.Build.0 = Debug|x86 50 | {F6C16952-7674-4C89-8534-F927DA1A2167}.Debug|x86.ActiveCfg = Debug|x86 51 | {F6C16952-7674-4C89-8534-F927DA1A2167}.Debug|x86.Build.0 = Debug|x86 52 | {F6C16952-7674-4C89-8534-F927DA1A2167}.iOS|Any CPU.ActiveCfg = Release|x86 53 | {F6C16952-7674-4C89-8534-F927DA1A2167}.iOS|Mixed Platforms.ActiveCfg = Release|x86 54 | {F6C16952-7674-4C89-8534-F927DA1A2167}.iOS|Mixed Platforms.Build.0 = Release|x86 55 | {F6C16952-7674-4C89-8534-F927DA1A2167}.iOS|x86.ActiveCfg = Release|x86 56 | {F6C16952-7674-4C89-8534-F927DA1A2167}.iOS|x86.Build.0 = Release|x86 57 | {F6C16952-7674-4C89-8534-F927DA1A2167}.Linux|Any CPU.ActiveCfg = Release|x86 58 | {F6C16952-7674-4C89-8534-F927DA1A2167}.Linux|Mixed Platforms.ActiveCfg = Release|x86 59 | {F6C16952-7674-4C89-8534-F927DA1A2167}.Linux|Mixed Platforms.Build.0 = Release|x86 60 | {F6C16952-7674-4C89-8534-F927DA1A2167}.Linux|x86.ActiveCfg = Release|x86 61 | {F6C16952-7674-4C89-8534-F927DA1A2167}.Linux|x86.Build.0 = Release|x86 62 | {F6C16952-7674-4C89-8534-F927DA1A2167}.OSX|Any CPU.ActiveCfg = Release|x86 63 | {F6C16952-7674-4C89-8534-F927DA1A2167}.OSX|Mixed Platforms.ActiveCfg = Release|x86 64 | {F6C16952-7674-4C89-8534-F927DA1A2167}.OSX|Mixed Platforms.Build.0 = Release|x86 65 | {F6C16952-7674-4C89-8534-F927DA1A2167}.OSX|x86.ActiveCfg = Release|x86 66 | {F6C16952-7674-4C89-8534-F927DA1A2167}.OSX|x86.Build.0 = Release|x86 67 | {F6C16952-7674-4C89-8534-F927DA1A2167}.PSM|Any CPU.ActiveCfg = Release|x86 68 | {F6C16952-7674-4C89-8534-F927DA1A2167}.PSM|Mixed Platforms.ActiveCfg = Release|x86 69 | {F6C16952-7674-4C89-8534-F927DA1A2167}.PSM|Mixed Platforms.Build.0 = Release|x86 70 | {F6C16952-7674-4C89-8534-F927DA1A2167}.PSM|x86.ActiveCfg = Release|x86 71 | {F6C16952-7674-4C89-8534-F927DA1A2167}.PSM|x86.Build.0 = Release|x86 72 | {F6C16952-7674-4C89-8534-F927DA1A2167}.Release|Any CPU.ActiveCfg = Release|x86 73 | {F6C16952-7674-4C89-8534-F927DA1A2167}.Release|Mixed Platforms.ActiveCfg = Release|x86 74 | {F6C16952-7674-4C89-8534-F927DA1A2167}.Release|Mixed Platforms.Build.0 = Release|x86 75 | {F6C16952-7674-4C89-8534-F927DA1A2167}.Release|x86.ActiveCfg = Release|x86 76 | {F6C16952-7674-4C89-8534-F927DA1A2167}.Release|x86.Build.0 = Release|x86 77 | {F6C16952-7674-4C89-8534-F927DA1A2167}.Windows|Any CPU.ActiveCfg = Release|x86 78 | {F6C16952-7674-4C89-8534-F927DA1A2167}.Windows|Mixed Platforms.ActiveCfg = Release|x86 79 | {F6C16952-7674-4C89-8534-F927DA1A2167}.Windows|Mixed Platforms.Build.0 = Release|x86 80 | {F6C16952-7674-4C89-8534-F927DA1A2167}.Windows|x86.ActiveCfg = Release|x86 81 | {F6C16952-7674-4C89-8534-F927DA1A2167}.Windows|x86.Build.0 = Release|x86 82 | {F6C16952-7674-4C89-8534-F927DA1A2167}.Windows8|Any CPU.ActiveCfg = Release|x86 83 | {F6C16952-7674-4C89-8534-F927DA1A2167}.Windows8|Mixed Platforms.ActiveCfg = Release|x86 84 | {F6C16952-7674-4C89-8534-F927DA1A2167}.Windows8|Mixed Platforms.Build.0 = Release|x86 85 | {F6C16952-7674-4C89-8534-F927DA1A2167}.Windows8|x86.ActiveCfg = Release|x86 86 | {F6C16952-7674-4C89-8534-F927DA1A2167}.Windows8|x86.Build.0 = Release|x86 87 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.Android|Any CPU.ActiveCfg = Android|Any CPU 88 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.Android|Any CPU.Build.0 = Android|Any CPU 89 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.Android|Mixed Platforms.ActiveCfg = Android|Any CPU 90 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.Android|Mixed Platforms.Build.0 = Android|Any CPU 91 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.Android|x86.ActiveCfg = Android|Any CPU 92 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.Debug|Any CPU.ActiveCfg = PSM|Any CPU 93 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.Debug|Any CPU.Build.0 = PSM|Any CPU 94 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.Debug|Mixed Platforms.ActiveCfg = PSM|Any CPU 95 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.Debug|Mixed Platforms.Build.0 = PSM|Any CPU 96 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.Debug|x86.ActiveCfg = PSM|Any CPU 97 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.iOS|Any CPU.ActiveCfg = iOS|Any CPU 98 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.iOS|Any CPU.Build.0 = iOS|Any CPU 99 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.iOS|Mixed Platforms.ActiveCfg = iOS|Any CPU 100 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.iOS|Mixed Platforms.Build.0 = iOS|Any CPU 101 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.iOS|x86.ActiveCfg = iOS|Any CPU 102 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.Linux|Any CPU.ActiveCfg = Linux|Any CPU 103 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.Linux|Any CPU.Build.0 = Linux|Any CPU 104 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.Linux|Mixed Platforms.ActiveCfg = Linux|Any CPU 105 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.Linux|Mixed Platforms.Build.0 = Linux|Any CPU 106 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.Linux|x86.ActiveCfg = Linux|Any CPU 107 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.OSX|Any CPU.ActiveCfg = OSX|Any CPU 108 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.OSX|Any CPU.Build.0 = OSX|Any CPU 109 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.OSX|Mixed Platforms.ActiveCfg = OSX|Any CPU 110 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.OSX|Mixed Platforms.Build.0 = OSX|Any CPU 111 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.OSX|x86.ActiveCfg = OSX|Any CPU 112 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.PSM|Any CPU.ActiveCfg = PSM|Any CPU 113 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.PSM|Any CPU.Build.0 = PSM|Any CPU 114 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.PSM|Mixed Platforms.ActiveCfg = PSM|Any CPU 115 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.PSM|Mixed Platforms.Build.0 = PSM|Any CPU 116 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.PSM|x86.ActiveCfg = PSM|Any CPU 117 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.Release|Any CPU.ActiveCfg = PSM|Any CPU 118 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.Release|Any CPU.Build.0 = PSM|Any CPU 119 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.Release|Mixed Platforms.ActiveCfg = PSM|Any CPU 120 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.Release|Mixed Platforms.Build.0 = PSM|Any CPU 121 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.Release|x86.ActiveCfg = PSM|Any CPU 122 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.Windows|Any CPU.ActiveCfg = Windows|Any CPU 123 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.Windows|Any CPU.Build.0 = Windows|Any CPU 124 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.Windows|Mixed Platforms.ActiveCfg = Windows|Any CPU 125 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.Windows|Mixed Platforms.Build.0 = Windows|Any CPU 126 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.Windows|x86.ActiveCfg = Windows|Any CPU 127 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.Windows8|Any CPU.ActiveCfg = Windows8|Any CPU 128 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.Windows8|Any CPU.Build.0 = Windows8|Any CPU 129 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.Windows8|Mixed Platforms.ActiveCfg = Windows8|Any CPU 130 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.Windows8|Mixed Platforms.Build.0 = Windows8|Any CPU 131 | {313BB489-E187-4B9D-8926-8E14B4B02B20}.Windows8|x86.ActiveCfg = Windows8|Any CPU 132 | {2037DFA6-4065-498F-B91B-9C4C29D433A4}.Android|Any CPU.ActiveCfg = Android|Any CPU 133 | {2037DFA6-4065-498F-B91B-9C4C29D433A4}.Android|Mixed Platforms.ActiveCfg = Android|Any CPU 134 | {2037DFA6-4065-498F-B91B-9C4C29D433A4}.Android|x86.ActiveCfg = Android|Any CPU 135 | {2037DFA6-4065-498F-B91B-9C4C29D433A4}.Debug|Any CPU.ActiveCfg = PSM|Any CPU 136 | {2037DFA6-4065-498F-B91B-9C4C29D433A4}.Debug|Mixed Platforms.ActiveCfg = PSM|Any CPU 137 | {2037DFA6-4065-498F-B91B-9C4C29D433A4}.Debug|x86.ActiveCfg = PSM|Any CPU 138 | {2037DFA6-4065-498F-B91B-9C4C29D433A4}.iOS|Any CPU.ActiveCfg = iOS|Any CPU 139 | {2037DFA6-4065-498F-B91B-9C4C29D433A4}.iOS|Mixed Platforms.ActiveCfg = iOS|Any CPU 140 | {2037DFA6-4065-498F-B91B-9C4C29D433A4}.iOS|x86.ActiveCfg = iOS|Any CPU 141 | {2037DFA6-4065-498F-B91B-9C4C29D433A4}.Linux|Any CPU.ActiveCfg = Linux|Any CPU 142 | {2037DFA6-4065-498F-B91B-9C4C29D433A4}.Linux|Mixed Platforms.ActiveCfg = Linux|Any CPU 143 | {2037DFA6-4065-498F-B91B-9C4C29D433A4}.Linux|x86.ActiveCfg = Linux|Any CPU 144 | {2037DFA6-4065-498F-B91B-9C4C29D433A4}.OSX|Any CPU.ActiveCfg = OSX|Any CPU 145 | {2037DFA6-4065-498F-B91B-9C4C29D433A4}.OSX|Mixed Platforms.ActiveCfg = OSX|Any CPU 146 | {2037DFA6-4065-498F-B91B-9C4C29D433A4}.OSX|x86.ActiveCfg = OSX|Any CPU 147 | {2037DFA6-4065-498F-B91B-9C4C29D433A4}.PSM|Any CPU.ActiveCfg = PSM|Any CPU 148 | {2037DFA6-4065-498F-B91B-9C4C29D433A4}.PSM|Mixed Platforms.ActiveCfg = PSM|Any CPU 149 | {2037DFA6-4065-498F-B91B-9C4C29D433A4}.PSM|x86.ActiveCfg = PSM|Any CPU 150 | {2037DFA6-4065-498F-B91B-9C4C29D433A4}.Release|Any CPU.ActiveCfg = PSM|Any CPU 151 | {2037DFA6-4065-498F-B91B-9C4C29D433A4}.Release|Mixed Platforms.ActiveCfg = PSM|Any CPU 152 | {2037DFA6-4065-498F-B91B-9C4C29D433A4}.Release|x86.ActiveCfg = PSM|Any CPU 153 | {2037DFA6-4065-498F-B91B-9C4C29D433A4}.Windows|Any CPU.ActiveCfg = Windows|Any CPU 154 | {2037DFA6-4065-498F-B91B-9C4C29D433A4}.Windows|Mixed Platforms.ActiveCfg = Windows|Any CPU 155 | {2037DFA6-4065-498F-B91B-9C4C29D433A4}.Windows|x86.ActiveCfg = Windows|Any CPU 156 | {2037DFA6-4065-498F-B91B-9C4C29D433A4}.Windows8|Any CPU.ActiveCfg = Windows8|Any CPU 157 | {2037DFA6-4065-498F-B91B-9C4C29D433A4}.Windows8|Mixed Platforms.ActiveCfg = Windows8|Any CPU 158 | {2037DFA6-4065-498F-B91B-9C4C29D433A4}.Windows8|x86.ActiveCfg = Windows8|Any CPU 159 | EndGlobalSection 160 | GlobalSection(SolutionProperties) = preSolution 161 | HideSolutionNode = FALSE 162 | EndGlobalSection 163 | EndGlobal 164 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/World/PropManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework; 6 | using DreamStateMachine.Actions; 7 | using Microsoft.Xna.Framework.Graphics; 8 | using Microsoft.Xna.Framework.Content; 9 | using System.Xml.Linq; 10 | 11 | namespace DreamStateMachine.Behaviors 12 | { 13 | class PropManager 14 | { 15 | List props; 16 | Dictionary PropPrototypes; 17 | Dictionary DoorPrototypes; 18 | Dictionary PotionPrototypes; 19 | Dictionary KeyPrototypes; 20 | Dictionary WeaponItemPrototypes; 21 | Random random; 22 | 23 | public PropManager() 24 | { 25 | props = new List(); 26 | PropPrototypes = new Dictionary(); 27 | DoorPrototypes = new Dictionary(); 28 | PotionPrototypes = new Dictionary(); 29 | KeyPrototypes = new Dictionary(); 30 | WeaponItemPrototypes = new Dictionary(); 31 | random = new Random(); 32 | 33 | Actor.Death += new EventHandler(Actor_Death); 34 | Actor.Drop += new EventHandler(Actor_Drop); 35 | WorldManager.worldChange += new EventHandler(World_Change); 36 | } 37 | 38 | public void initPropConfig(ContentManager content, String PropConfigFile) 39 | { 40 | var doc = XDocument.Load(PropConfigFile); 41 | var Props = doc.Element("Props").Elements("Prop"); 42 | var Doors = doc.Element("Props").Elements("Door"); 43 | var Potions = doc.Element("Props").Elements("Potion"); 44 | var Keys = doc.Element("Props").Elements("Key"); 45 | var WeaponItems = doc.Element("Props").Elements("Weapon"); 46 | 47 | String PropClass; 48 | Texture2D PropTexture; 49 | int PropWidth; 50 | int PropHeight; 51 | 52 | String DoorClass; 53 | Texture2D DoorTexture; 54 | int DoorWidth; 55 | int DoorHeight; 56 | 57 | String PotionClass; 58 | Texture2D PotionTexture; 59 | int PotionWidth; 60 | int PotionHeight; 61 | int PotionRestore; 62 | 63 | String KeyClass; 64 | Texture2D KeyTexture; 65 | int KeyWidth; 66 | int KeyHeight; 67 | 68 | String WeaponClass; 69 | Texture2D WeaponTexture; 70 | int WeaponX; 71 | int WeaponY; 72 | int WeaponWidth; 73 | int WeaponHeight; 74 | 75 | int texWidth; 76 | int texHeight; 77 | foreach (XElement Prop in Props) 78 | { 79 | PropClass = Prop.Attribute("className").Value; 80 | PropTexture = content.Load(Prop.Attribute("texture").Value); 81 | PropWidth = int.Parse(Prop.Attribute("width").Value); 82 | PropHeight = int.Parse(Prop.Attribute("height").Value); 83 | texWidth = int.Parse(Prop.Attribute("texWidth").Value); 84 | texHeight = int.Parse(Prop.Attribute("texHeight").Value); 85 | 86 | this.PropPrototypes[PropClass] = new Prop(PropTexture, PropWidth, PropHeight, texWidth, texHeight); 87 | this.PropPrototypes[PropClass].className = PropClass; 88 | 89 | } 90 | foreach (XElement Door in Doors) 91 | { 92 | DoorClass = Door.Attribute("className").Value; 93 | DoorTexture = content.Load(Door.Attribute("texture").Value); 94 | DoorWidth = int.Parse(Door.Attribute("width").Value); 95 | DoorHeight = int.Parse(Door.Attribute("height").Value); 96 | texWidth = int.Parse(Door.Attribute("texWidth").Value); 97 | texHeight = int.Parse(Door.Attribute("texHeight").Value); 98 | 99 | this.DoorPrototypes[DoorClass] = new Door(DoorTexture, DoorWidth, DoorHeight, texWidth, texHeight); 100 | this.DoorPrototypes[DoorClass].className = DoorClass; 101 | } 102 | foreach (XElement Potion in Potions) 103 | { 104 | PotionClass = Potion.Attribute("className").Value; 105 | PotionTexture = content.Load(Potion.Attribute("texture").Value); 106 | PotionWidth = int.Parse(Potion.Attribute("width").Value); 107 | PotionHeight = int.Parse(Potion.Attribute("height").Value); 108 | texWidth = int.Parse(Potion.Attribute("texWidth").Value); 109 | texHeight = int.Parse(Potion.Attribute("texHeight").Value); 110 | PotionRestore = int.Parse(Potion.Attribute("restore").Value); 111 | 112 | this.PotionPrototypes[PotionClass] = new Potion(PotionTexture, 113 | PotionWidth, PotionHeight, 114 | texWidth, texHeight, PotionRestore); 115 | this.PotionPrototypes[PotionClass].className = PotionClass; 116 | } 117 | foreach (XElement Key in Keys) 118 | { 119 | KeyClass = Key.Attribute("className").Value; 120 | KeyTexture = content.Load(Key.Attribute("texture").Value); 121 | KeyWidth = int.Parse(Key.Attribute("width").Value); 122 | KeyHeight = int.Parse(Key.Attribute("height").Value); 123 | texWidth = int.Parse(Key.Attribute("texWidth").Value); 124 | texHeight = int.Parse(Key.Attribute("texHeight").Value); 125 | 126 | this.KeyPrototypes[KeyClass] = new Key(KeyTexture, 127 | KeyWidth, KeyHeight, 128 | texWidth, texHeight); 129 | this.KeyPrototypes[KeyClass].className = KeyClass; 130 | } 131 | foreach (XElement Weapon in WeaponItems) 132 | { 133 | WeaponClass = Weapon.Attribute("className").Value; 134 | WeaponTexture = content.Load(Weapon.Attribute("texture").Value); 135 | WeaponX = int.Parse(Weapon.Attribute("offsetX").Value); 136 | WeaponY = int.Parse(Weapon.Attribute("offsetY").Value); 137 | WeaponWidth = int.Parse(Weapon.Attribute("width").Value); 138 | WeaponHeight = int.Parse(Weapon.Attribute("height").Value); 139 | texWidth = int.Parse(Weapon.Attribute("texWidth").Value); 140 | texHeight = int.Parse(Weapon.Attribute("texHeight").Value); 141 | 142 | this.WeaponItemPrototypes[WeaponClass] = new WeaponItem(WeaponTexture,WeaponClass, 143 | WeaponWidth, WeaponHeight, 144 | WeaponX, WeaponY, 145 | texWidth, texHeight); 146 | } 147 | } 148 | 149 | public void spawnProp(Prop Prop, Point spawnTile, int spawnType) 150 | { 151 | //Prop.onSpawn(spawnTile, spawnType); 152 | //Prop.world = worldManager.curWorld; 153 | } 154 | 155 | public void spawnDoor(Door door, Point spawnTile, int spawnType) 156 | { 157 | door.onSpawn(spawnTile, spawnType); 158 | //Prop.world = worldManager.curWorld; 159 | } 160 | 161 | public void spawnPotion(Potion potion, Point spawnTile, int spawnType) 162 | { 163 | potion.onSpawn(spawnTile, spawnType); 164 | } 165 | 166 | public void spawnKey(Key key, Point spawnTile, int spawnType) 167 | { 168 | key.onSpawn(spawnTile, spawnType); 169 | } 170 | 171 | public void spawnWeapon(WeaponItem weapon, Point spawnTile, int spawnType) 172 | { 173 | weapon.onSpawn(spawnTile, spawnType); 174 | } 175 | 176 | public void spawnProps(List spawns) 177 | { 178 | foreach (SpawnFlag spawn in spawns) 179 | { 180 | if (spawn.spawnType == (int)SPAWNTYPES.PROP || spawn.spawnType == (int)SPAWNTYPES.DOOR || spawn.spawnType == (int)SPAWNTYPES.POTION || spawn.spawnType == (int)SPAWNTYPES.KEY) 181 | { 182 | if (PropPrototypes.ContainsKey(spawn.className)) 183 | { 184 | Prop PropToCopy = (Prop)PropPrototypes[spawn.className].Clone(); 185 | Point spawnTile = spawn.tilePosition; 186 | 187 | spawnProp(PropToCopy, spawnTile, spawn.spawnType); 188 | props.Add(PropToCopy); 189 | } 190 | else if(DoorPrototypes.ContainsKey(spawn.className)) 191 | { 192 | Door DoorToCopy = (Door)DoorPrototypes[spawn.className].Clone(); 193 | Point spawnTile = spawn.tilePosition; 194 | 195 | spawnDoor(DoorToCopy, spawnTile, spawn.spawnType); 196 | props.Add(DoorToCopy); 197 | } 198 | else if (PotionPrototypes.ContainsKey(spawn.className)) 199 | { 200 | Potion PotionToCopy = (Potion)PotionPrototypes[spawn.className].Clone(); 201 | Point spawnTile = spawn.tilePosition; 202 | 203 | spawnPotion(PotionToCopy, spawnTile, spawn.spawnType); 204 | props.Add(PotionToCopy); 205 | } 206 | else if (KeyPrototypes.ContainsKey(spawn.className)) 207 | { 208 | Key KeyToCopy = (Key)KeyPrototypes[spawn.className].Clone(); 209 | Point spawnTile = spawn.tilePosition; 210 | 211 | spawnKey(KeyToCopy, spawnTile, spawn.spawnType); 212 | props.Add(KeyToCopy); 213 | } 214 | } 215 | } 216 | } 217 | 218 | public void update(float dt) 219 | { 220 | } 221 | 222 | private void Actor_Death(object sender, EventArgs args) 223 | { 224 | Actor deadActor = (Actor)sender; 225 | Point pointOfDeath = new Point(); 226 | pointOfDeath.X = deadActor.hitBox.Center.X / deadActor.world.tileSize; 227 | pointOfDeath.Y = deadActor.hitBox.Center.Y / deadActor.world.tileSize; 228 | if (deadActor.hasKey) 229 | { 230 | spawnKey(KeyPrototypes["key"], pointOfDeath, 0); 231 | } 232 | foreach (KeyValuePair entry in deadActor.lootTable) 233 | { 234 | List dropPoints = new List(); 235 | dropPoints.Add( new Point(pointOfDeath.X - 1, pointOfDeath.Y - 1)); 236 | dropPoints.Add( new Point(pointOfDeath.X, pointOfDeath.Y - 1)); 237 | dropPoints.Add( new Point(pointOfDeath.X + 1, pointOfDeath.Y - 1)); 238 | dropPoints.Add( new Point(pointOfDeath.X - 1, pointOfDeath.Y)); 239 | dropPoints.Add( new Point(pointOfDeath.X + 1, pointOfDeath.Y)); 240 | dropPoints.Add( new Point(pointOfDeath.X - 1, pointOfDeath.Y + 1)); 241 | dropPoints.Add( new Point(pointOfDeath.X , pointOfDeath.Y + 1)); 242 | dropPoints.Add( new Point(pointOfDeath.X + 1, pointOfDeath.Y + 1)); 243 | float value = (float)random.NextDouble(); 244 | if (value <= entry.Value) 245 | { 246 | Point newDropPoint = dropPoints.Find(tile => deadActor.world.tileIsInBounds(tile.X, tile.Y)); 247 | spawnWeapon(WeaponItemPrototypes[entry.Key], newDropPoint, (int)SPAWNTYPES.ITEM); 248 | dropPoints.Remove(newDropPoint); 249 | } 250 | } 251 | } 252 | 253 | private void Actor_Drop(object sender, PickupEventArgs args) 254 | { 255 | Actor droppingActor = (Actor)sender; 256 | Point pointOfDrop = new Point(); 257 | pointOfDrop.X = droppingActor.hitBox.Center.X / droppingActor.world.tileSize; 258 | pointOfDrop.Y = droppingActor.hitBox.Center.Y / droppingActor.world.tileSize; 259 | spawnWeapon(WeaponItemPrototypes[args.itemClassName], pointOfDrop, (int)SPAWNTYPES.ITEM); 260 | } 261 | 262 | private void World_Change(object sender, EventArgs args) 263 | { 264 | WorldManager worldManager = (WorldManager)sender; 265 | if (worldManager.curWorld != null) 266 | { 267 | List spawns = worldManager.curWorld.getSpawns(); 268 | spawnProps(spawns); 269 | } 270 | } 271 | } 272 | } 273 | -------------------------------------------------------------------------------- /DreamStateMachine/Game/Actor/ActorManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Microsoft.Xna.Framework; 6 | using DreamStateMachine.Actions; 7 | using Microsoft.Xna.Framework.Graphics; 8 | using Microsoft.Xna.Framework.Content; 9 | using System.Xml.Linq; 10 | 11 | namespace DreamStateMachine.Behaviors 12 | { 13 | class ActorManager 14 | { 15 | 16 | Dictionary actorPrototypes; 17 | Dictionary animationPrototypes; 18 | Random random; 19 | Actor player; 20 | 21 | public ActorManager() 22 | { 23 | actorPrototypes = new Dictionary(); 24 | animationPrototypes = new Dictionary(); 25 | random = new Random(); 26 | 27 | Actor.Death += new EventHandler(Actor_Death); 28 | WorldManager.worldChange += new EventHandler(World_Change); 29 | } 30 | 31 | void Actor_Death(object sender, EventArgs e) 32 | { 33 | if (((Actor)sender).className == "slime") 34 | { 35 | float x = ((Actor)sender).hitBox.Center.X / ((Actor)sender).world.tileSize; 36 | float y = ((Actor)sender).hitBox.Center.Y / ((Actor)sender).world.tileSize; 37 | List spawns = new List(); 38 | SpawnFlag enemySpawn = new SpawnFlag("slimejr", new Point((int)x, (int)y), 2); 39 | //SpawnFlag enemySpawn2 = new SpawnFlag("slimejr", new Point((int)x, (int)y), 2); 40 | spawns.Add(enemySpawn); 41 | //spawns.Add(enemySpawn2); 42 | spawnActors(spawns); 43 | } 44 | } 45 | 46 | public void initActorConfig(ContentManager content, String actorConfigFile) 47 | { 48 | XDocument actorDoc = XDocument.Load(actorConfigFile); 49 | List actors = actorDoc.Element("Actors").Elements("Actor").ToList(); 50 | List actorAnimations; 51 | List actorItems; 52 | String actorClass; 53 | String animationName; 54 | String animationType; 55 | Texture2D actorTexture; 56 | float actorDamageFactor; 57 | int actorMaxSpeed; 58 | int actorWidth; 59 | int actorHeight; 60 | int actorHealth; 61 | int actorSight; 62 | int actorReach; 63 | int texWidth; 64 | int texHeight; 65 | 66 | String itemClassName; 67 | float itemWeight; 68 | 69 | foreach (XElement actor in actors) 70 | { 71 | actorClass = actor.Attribute("className").Value; 72 | actorTexture = content.Load(actor.Attribute("texture").Value); 73 | actorMaxSpeed = int.Parse(actor.Attribute("maxSpeed").Value); 74 | actorWidth = int.Parse(actor.Attribute("width").Value); 75 | actorHeight = int.Parse(actor.Attribute("height").Value); 76 | texWidth = int.Parse(actor.Attribute("texWidth").Value); 77 | texHeight = int.Parse(actor.Attribute("texHeight").Value); 78 | actorHealth = int.Parse(actor.Attribute("health").Value); 79 | actorDamageFactor = float.Parse(actor.Attribute("damageFactor").Value); 80 | actorSight = int.Parse(actor.Attribute("sight").Value); 81 | actorReach = int.Parse(actor.Attribute("reach").Value); 82 | actorPrototypes[actorClass] = new Actor(actorTexture, actorWidth, actorHeight, texWidth, texHeight); 83 | actorPrototypes[actorClass].className = actorClass; 84 | actorPrototypes[actorClass].maxHealth = actorHealth; 85 | actorPrototypes[actorClass].health = actorHealth; 86 | actorPrototypes[actorClass].damageFactor = actorDamageFactor; 87 | actorPrototypes[actorClass].maxSpeed = actorMaxSpeed; 88 | actorPrototypes[actorClass].sight = actorSight; 89 | actorPrototypes[actorClass].reach = actorReach; 90 | actorPrototypes[actorClass].animations = new Dictionary(); 91 | actorAnimations = actor.Elements("Animation").ToList(); 92 | 93 | foreach (XElement actorAnimation in actorAnimations) 94 | { 95 | if (this.animationPrototypes.ContainsKey(actorAnimation.Attribute("name").Value)) 96 | { 97 | animationName = actorAnimation.Attribute("name").Value; 98 | animationType = actorAnimation.Attribute("type").Value; 99 | actorPrototypes[actorClass].animations[animationType] = animationPrototypes[animationName]; 100 | } 101 | } 102 | 103 | actorItems = actor.Elements("Item").ToList(); 104 | 105 | foreach (XElement item in actorItems) { 106 | itemClassName = item.Attribute("className").Value; 107 | itemWeight = float.Parse(item.Attribute("weight").Value); 108 | 109 | actorPrototypes[actorClass].lootTable.Add(itemClassName, itemWeight); 110 | } 111 | 112 | } 113 | } 114 | 115 | public void initAnimationConfig(ContentManager content, String animationConfigFile) 116 | { 117 | List meleeAttackTypes = new List { "single_box_attack", "multi_box_attack" }; 118 | List projectileAttackTypes = new List { "projectile_attack" }; 119 | 120 | XDocument animationDoc = XDocument.Load(animationConfigFile); 121 | List animations = animationDoc.Element("Animations").Elements("Animation").ToList(); 122 | List frames; 123 | List attackBoxes; 124 | String animationName; 125 | String animationAttackType; 126 | bool animationHoldingWeapon; 127 | int animationFrames; 128 | int animationFPS; 129 | int texColumnIndex; 130 | int texRowIndex; 131 | 132 | int frameIndex; 133 | String weaponStance; 134 | float weaponRotation; 135 | int attackOffsetX; 136 | int attackOffsetY; 137 | int attackWidth; 138 | int attackHeight; 139 | Rectangle attackRect; 140 | List attackRects; 141 | FrameInfo[] frameInfos; 142 | FrameInfo frameInfo; 143 | int attackDamage; 144 | List attackPoints; 145 | Point gripPoint; 146 | 147 | 148 | foreach (XElement animation in animations) 149 | { 150 | animationName = animation.Attribute("name").Value; 151 | animationAttackType = animation.Attribute("attackType").Value; 152 | animationHoldingWeapon = bool.Parse(animation.Attribute("holdingWeapon").Value); 153 | animationFrames = int.Parse(animation.Attribute("frames").Value); 154 | animationFPS = int.Parse(animation.Attribute("fps").Value); 155 | texColumnIndex = int.Parse(animation.Attribute("columnIndex").Value); 156 | texRowIndex = int.Parse(animation.Attribute("rowIndex").Value); 157 | 158 | frames = animation.Elements("Frame").ToList(); 159 | frameInfos = new FrameInfo[animationFrames]; 160 | if (meleeAttackTypes.Contains(animationAttackType) || animationHoldingWeapon) 161 | { 162 | 163 | foreach (XElement frame in frames) 164 | { 165 | frameIndex = int.Parse(frame.Attribute("frameIndex").Value); 166 | frameInfo = new FrameInfo(); 167 | attackRects = new List(); 168 | if(animationHoldingWeapon){ 169 | gripPoint = new Point(); 170 | gripPoint.X = int.Parse(frame.Attribute("gripX").Value); 171 | gripPoint.Y = int.Parse(frame.Attribute("gripY").Value); 172 | weaponStance = frame.Attribute("stance").Value; 173 | weaponRotation = float.Parse(frame.Attribute("rotation").Value); 174 | frameInfo.gripPoint = gripPoint; 175 | frameInfo.stance = weaponStance; 176 | frameInfo.rotation = weaponRotation; 177 | 178 | } 179 | if (meleeAttackTypes.Contains(animationAttackType)) 180 | { 181 | attackPoints = new List(); 182 | attackDamage = int.Parse(frame.Attribute("damage").Value); 183 | frameInfo.attackDamage = attackDamage; 184 | attackBoxes = frame.Elements("AttackBox").ToList(); 185 | foreach (XElement attackBox in attackBoxes) 186 | { 187 | attackOffsetX = int.Parse(attackBox.Attribute("viewOffsetX").Value); 188 | attackOffsetY = int.Parse(attackBox.Attribute("viewOffsetY").Value); 189 | attackWidth = int.Parse(attackBox.Attribute("attackWidth").Value); 190 | attackHeight = int.Parse(attackBox.Attribute("attackHeight").Value); 191 | attackRect = new Rectangle(attackOffsetX, attackOffsetY, attackWidth, attackHeight); 192 | attackPoints.Add(attackRect); 193 | } 194 | frameInfo.attackPoints = attackPoints; 195 | } 196 | frameInfos[frameIndex] = frameInfo; 197 | } 198 | 199 | } 200 | 201 | animationPrototypes[animationName] = new AnimationInfo 202 | { 203 | frames = frameInfos, 204 | name = animationName, 205 | frameCount = animationFrames, 206 | type = animationAttackType, 207 | fps = animationFPS, 208 | texColumn = texColumnIndex, 209 | texRow = texRowIndex 210 | }; 211 | } 212 | } 213 | 214 | public void spawnActor(Actor actor, Point spawnTile, int spawnType) 215 | { 216 | actor.onSpawn(spawnTile, spawnType); 217 | //actor.world = worldManager.curWorld; 218 | } 219 | 220 | public void spawnActors(List spawns) 221 | { 222 | foreach (SpawnFlag spawn in spawns) 223 | { 224 | if (actorPrototypes.ContainsKey(spawn.className)) 225 | { 226 | Point spawnTile = spawn.tilePosition; 227 | Vector2 newSightVector = new Vector2((float)random.NextDouble() * 2 - 1, (float)random.NextDouble() * 2 - 1); 228 | Actor actorToCopy; 229 | if (spawn.className.Equals("player") && player != null) 230 | { 231 | actorToCopy = (Actor)player.Clone(); 232 | } 233 | else 234 | { 235 | actorToCopy = (Actor)actorPrototypes[spawn.className].Clone(); 236 | if (spawn.hasKey) 237 | actorToCopy.hasKey = true; 238 | 239 | } 240 | actorToCopy.setGaze(newSightVector); 241 | spawnActor(actorToCopy, spawnTile, spawn.spawnType); 242 | } 243 | } 244 | } 245 | 246 | public void respawnActors(List spawns) 247 | { 248 | foreach (SpawnFlag spawn in spawns) 249 | { 250 | if (actorPrototypes.ContainsKey(spawn.className)) 251 | { 252 | Actor actorToCopy = (Actor)actorPrototypes[spawn.className].Clone(); 253 | Point spawnTile = spawn.tilePosition; 254 | Vector2 newSightVector = new Vector2((float)random.NextDouble() * 2 - 1, (float)random.NextDouble() * 2 - 1); 255 | actorToCopy.setGaze(newSightVector); 256 | spawnActor(actorToCopy, spawnTile, spawn.spawnType); 257 | } 258 | } 259 | } 260 | 261 | private void World_Change(Object sender, EventArgs eventArgs) 262 | { 263 | WorldManager worldManager = (WorldManager)sender; 264 | player = worldManager.playerTransfer; 265 | if (worldManager.curWorld != null) 266 | { 267 | List spawns = worldManager.curWorld.getSpawns(); 268 | spawnActors(spawns); 269 | } 270 | player = null; 271 | } 272 | } 273 | } 274 | --------------------------------------------------------------------------------