コード例 #1
0
ファイル: Enemy.cs プロジェクト: surfintime0027/ArmorPotion
 public Enemy(World world)
     : base(world)
 {
     _isAction = false;
     _sightRadius = 100;
     _actionComponents = new Dictionary<String, IAIComponent>();
 }
コード例 #2
0
ファイル: Enemy.cs プロジェクト: surfintime0027/ArmorPotion
        public Enemy(World world, EnemyData data)
            : base(world)
        {
            _isAction = false;
            _sightRadius = data.SightRadius;

            this.Texture = data.Texture;
            this.Velocity = data.Velocity;

            this.AnimatedSprites = data.DeepCopySprites;
            this._idleComponent = data.IdleComponent.Clone();
            this._decisionComponent = data.DecisionComponent.Clone();
            this._actionComponents = data.DeepCopyActionComponents;

            this.LeftCollisionOffset = data.LeftCollisionOffset;
            this.RightCollisionOffset = data.RightCollisionOffset;
            this.TopCollisionOffset = data.TopCollisionOffset;
            this.BottomCollisionOffset = data.BottomCollisionOffset;
            this._health = new AttributePair(data.Health);

            this.AnimatedSprites.First().Value.IsAnimating = true;

            _healthTexture = world.Game.Content.Load<Texture2D>(@"Gui/EnemyHealthBar");

            String[] color = data.Color.Split(',');
            if(color.Length == 3)
                _tintColor = new Color(int.Parse(color[0]), int.Parse(color[1]), int.Parse(color[2]));

            foreach (AnimatedSprite sprite in AnimatedSprites.Values)
            {
                sprite.TintColor = _tintColor;
            }
        }
コード例 #3
0
 public AreaOfEffectProjectile(World world, Item source, ProjectileTarget target, EventType eventType, bool triggerEvents, Vector2 destination, int lifetime)
     : base(world, source, target, eventType, triggerEvents)
 {
     _position = destination;
     _destination = destination;
     _lifetime = lifetime;
 }
コード例 #4
0
        public ConeProjectile(World world, Item source, ProjectileTarget target, EventType eventType, bool triggerEvents, float liveDistance, Vector2 startingPosition, Vector2 destination, double angleSpread)
            : base(world, source, target, eventType, triggerEvents, liveDistance, startingPosition, destination)
        {
            this._destination = destination;

            double spread = RandomGenerator.Random.NextDouble() * (angleSpread);
            Velocity = new Vector2((float)Math.Cos(_angle ) * 2 + (float)spread, (float)Math.Sin(_angle) * 2 + (float)spread);
        }
コード例 #5
0
 public Projectile(World world, Item source, ProjectileTarget target, EventType eventType, bool triggerEvents)
     : base(world)
 {
     _source = source;
     _eventType = eventType;
     _triggerEvents = triggerEvents;
     _damagedOnce = false;
     _target = target;
     _damageAmount = 5;
 }
コード例 #6
0
        public LinearProjectile(World world, Item source, ProjectileTarget target, EventType eventType, bool triggerEvents, float liveDistance, Vector2 startingPosition, double angle)
            : base(world, source, target, eventType, triggerEvents)
        {
            _liveDistance = liveDistance;
            _startingPosition = startingPosition;
            _angle = angle;

            Position = startingPosition;
            Velocity = new Vector2((float)Math.Cos(_angle) * 4, (float)Math.Sin(_angle) * 4);
        }
コード例 #7
0
        public LinearProjectile(World world, Item source, ProjectileTarget target, EventType eventType, bool triggerEvents, float liveDistance, Vector2 startingPosition, Vector2 destination)
            : base(world, source, target, eventType, triggerEvents)
        {
            _liveDistance = liveDistance;
            _startingPosition = startingPosition;
            _destination = destination;
            _angle = GameMath.CalculateAngle(startingPosition, destination);

            Position = startingPosition;
            Velocity = new Vector2((float)Math.Cos(_angle) * 2, (float)Math.Sin(_angle) * 2);
        }
コード例 #8
0
ファイル: Map.cs プロジェクト: surfintime0027/ArmorPotion
        public Map(Tile[,] mapTop, Tile[,] mapBottom, List<Enemy> enemies, World world)
        {
            _tileMaps = new List<Tile[,]>();
            _tileMaps.Add(mapBottom);
            _tileMaps.Add(mapTop);

            _enemies = enemies;

            if (mapTop.GetLength(0) != mapBottom.GetLength(0) || mapBottom.GetLength(1) != mapTop.GetLength(1))
                throw new Exception("Invalid map lengths.");

            _width = mapTop.GetLength(0) - 1;
            _height = mapBottom.GetLength(1) - 1;

            _world = world;
            _camera = _world.Camera;
        }
コード例 #9
0
        public ThrowProjectile(World world, Item source, ProjectileTarget target, EventType eventType, bool triggerEvents, Vector2 startingPostion, float throwDistance, float beginningAngle, float projectileDistance, double projectileSpread, float revolutions, float projectilesPerIteration, bool triggerSecondaryProjectileEvents, Vector2 aoeDestination, int aoeLife)
            : base(world, source, target, eventType, triggerEvents)
        {
            _position = startingPostion;

            _startingPosition = startingPostion;
            _throwDistance = throwDistance;
            _beginningAngle = MathHelper.ToRadians(beginningAngle);
            _angle = _beginningAngle;
            _projectileDistance = projectileDistance;
            _projectileSpread = projectileSpread;
            _triggerSecondaryProjectileEvents = triggerSecondaryProjectileEvents;
            _angleCycle = revolutions * 2 * Math.PI;
            _deltaAngle = projectilesPerIteration / _angleCycle;
            _aoeDestination = aoeDestination;
            _aoeLife = aoeLife;

            _thrown = false;
            Velocity = new Vector2((float)Math.Cos(beginningAngle) * 2, (float)Math.Sin(beginningAngle) * 2);
            _triggerEvents = false;
        }
コード例 #10
0
ファイル: Entity.cs プロジェクト: surfintime0027/ArmorPotion
        public Entity(World world)
        {
            _world = world;

            _xVelocityLimit = new Vector2(Int32.MinValue, Int32.MaxValue);
            _yVelocityLimit = new Vector2(Int32.MinValue, Int32.MaxValue);

            _animatedSprite = new Dictionary<String, AnimatedSprite>();
            _currentSpriteKey = String.Empty;

            _leftCollisionOffset = 0;
            _rightCollisionOffset = 0;
            _topCollisionOffset = 0;
            _bottomCollisionOffset = 0;

            _isAlive = true;

            //TODO: Temp Health, need to allow health to be set for individual enemies
            _health = new AttributePair(600);
            _shield = new AttributePair(300);
            _tintColor = Color.White;
        }
コード例 #11
0
        public static Map Load(String mapTopLocation, String mapBottomLocation, String enemyLocation, World world)
        {
            Dictionary<int, Texture2D> textureDictionary = new Dictionary<int,Texture2D>();

            textureDictionary.Add(01, world.Game.Content.Load<Texture2D>(@"Tiles\FloorTile"));
            textureDictionary.Add(02, world.Game.Content.Load<Texture2D>(@"Tiles\WallTile"));
            textureDictionary.Add(03, world.Game.Content.Load<Texture2D>(@"Tiles\DoorTile"));
            textureDictionary.Add(04, world.Game.Content.Load<Texture2D>(@"Tiles\SwitchTile"));
            textureDictionary.Add(05, world.Game.Content.Load<Texture2D>(@"Tiles\HoleTile"));
            textureDictionary.Add(06, world.Game.Content.Load<Texture2D>(@"Tiles\WaterTile"));
            textureDictionary.Add(07, world.Game.Content.Load<Texture2D>(@"Tiles\LavaTile"));
            textureDictionary.Add(08, world.Game.Content.Load<Texture2D>(@"Tiles\CooledLavaTile"));
            textureDictionary.Add(09, world.Game.Content.Load<Texture2D>(@"Tiles\IceTile"));
            textureDictionary.Add(10, world.Game.Content.Load<Texture2D>(@"Tiles\DeepWaterTile"));
            textureDictionary.Add(11, world.Game.Content.Load<Texture2D>(@"Tiles\LightningSwitch"));
            textureDictionary.Add(12, world.Game.Content.Load<Texture2D>(@"Tiles\FireSwitch"));
            textureDictionary.Add(13, world.Game.Content.Load<Texture2D>(@"Tiles\IceSwitch"));
            textureDictionary.Add(14, world.Game.Content.Load<Texture2D>(@"Tiles\DoorOpenTile"));
            textureDictionary.Add(15, world.Game.Content.Load<Texture2D>(@"Tiles\LadderTile"));

            Map loadedMap = new Map(loadMap(mapTopLocation, textureDictionary), loadMap(mapBottomLocation, textureDictionary), LoadEnemies(world, enemyLocation), world);
            for (int i = 0; i <= loadedMap.getMapLevel(1).GetLength(0) - 1; i++)
            {
                for (int c = 0; c <= loadedMap.getMapLevel(1).GetLength(1) - 1; c++)
                {
                    Tile tempTile = loadedMap.getMapLevel(1)[c, i];
                    if (tempTile != null)
                    {
                        if (tempTile.TileID == 11||tempTile.TileID == 12||tempTile.TileID == 13)
                        {
                            SwitchTile switchTile = (SwitchTile)tempTile;
                            switchTile.parseOneselfAndAddThineSelfToThouDictionaryOfLinkedTileObjects_Cheers(loadedMap.getMapLevel(1));
                        }
                    }
                }
            }
            return loadedMap;
        }
コード例 #12
0
ファイル: Game1.cs プロジェクト: surfintime0027/ArmorPotion
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            SpriteBatch = new SpriteBatch(GraphicsDevice);
            world = new World(this);

            ItemFactory itemFactory = new ItemFactory(world, @"Items");

            EnemyFactory factory = new EnemyFactory(world, @"Enemy");
            world.EnemyFactory = factory;

            Map dungeonOne = MapLoader.Load("Content/Maps/DungeonOne_top.txt", "Content/Maps/DungeonOne_bottom.txt", "Content/Maps/DungeonOne_enemy.txt", world);
            world.CurrentDungeon = dungeonOne;

            Item item = itemFactory.Create("Super Awesome Potion");
            item.Position = new Vector2(70, 70);
            world.item = item;

            Animation animation = new Animation(1, 32, 32, 0, 0);
            Animation animation2 = new Animation(1, 256, 256, 0, 0);

            AnimatedSprite sprite = new AnimatedSprite(Content.Load<Texture2D>(@"Items\Weapons\Fireball"), new Dictionary<AnimationKey, Animation> { { AnimationKey.Right, animation } });
            AnimatedSprite light = new AnimatedSprite(Content.Load<Texture2D>(@"Enemy\LightBugAttack"), new Dictionary<AnimationKey, Animation> { { AnimationKey.Right, animation2 } });

            world.Player.Inventory.TempaQuips.Add(new Sword(Content.Load<Texture2D>(@"Gui\SwordIcon"), "Sword"));

            world.Player.Inventory.TempaQuips.Add((Gun)itemFactory.Create("Bobs Gun"));
            world.Player.Inventory.SelectRelativeTempaQuip(world.Player, 0);

            world.Player.Inventory.TempaQuips.Add(new Zapper(Content.Load<Texture2D>(@"Gui\GogglesIcon"), "BobsZapper", light));

            world.Player.Inventory.TempaQuips.Add(new SomeConeWeapon(Content.Load<Texture2D>(@"Gui\GravityBootsIcon"), "BobsCone", sprite.Clone()));

            world.Player.Inventory.TempaQuips.Add((EBall)itemFactory.Create("E-Ball Fire"));
            world.Player.Inventory.TempaQuips.Add((EBall)itemFactory.Create("E-Ball Ice"));
            world.Player.Inventory.TempaQuips.Add((EBall)itemFactory.Create("E-Ball Lightning"));
        }
コード例 #13
0
        private static List<Enemy> LoadEnemies(World world, String fileLocation)
        {
            List<Enemy> enemies = new List<Enemy>();
            using (Stream fileStream = TitleContainer.OpenStream(fileLocation))
            {
                using (StreamReader reader = new StreamReader(fileStream))
                {
                    String enemy = "";
                    while ((enemy = reader.ReadLine()) != null)
                    {
                        String[] enemyData = enemy.Split('|');

                        Enemy loadedEnemy = world.EnemyFactory.Create(enemyData[0]);
                        loadedEnemy.Position = new Vector2(float.Parse(enemyData[1]), float.Parse(enemyData[2]));

                        enemies.Add(loadedEnemy);
                    }
                }
            }

            return enemies;
        }
コード例 #14
0
ファイル: Player.cs プロジェクト: surfintime0027/ArmorPotion
        public Player(World world, Texture2D texture, Texture2D attackTexture)
            : base(world)
        {
            AttackTranslation = new Vector2(-64, -64);
            _currentTranslation = Vector2.Zero;

            int spriteWidth = 128;
            int spriteHeight = 128;
            int frameCount = 4;

            Dictionary<AnimationKey, Animation> animations = new Dictionary<AnimationKey, Animation>();

            Animation animation = new Animation(frameCount, spriteWidth, spriteHeight, 0, 0);
            animations.Add(AnimationKey.Down, animation);

            animation = new Animation(frameCount, spriteWidth, spriteHeight, 0, spriteHeight);
            animations.Add(AnimationKey.Left, animation);

            animation = new Animation(frameCount, spriteWidth, spriteHeight, 0, spriteHeight * 2);
            animations.Add(AnimationKey.Right, animation);

            animation = new Animation(frameCount, spriteWidth, spriteHeight, 0, spriteHeight * 3);
            animations.Add(AnimationKey.Up, animation);

            AnimatedSprite sprite = new AnimatedSprite(
                texture,
                animations,
                Color.White);

            AnimatedSprites.Add("Normal", sprite);

            spriteWidth = 256;
            spriteHeight = 256;

            animations = new Dictionary<AnimationKey, Animation>();

            animation = new Animation(frameCount, spriteWidth, spriteHeight, 0, 0, false);
            animation.FramesPerSecond = 10;

            animations.Add(AnimationKey.Down, animation);

            animation = new Animation(frameCount, spriteWidth, spriteHeight, 0, spriteHeight, false);
            animation.FramesPerSecond = 10;

            animations.Add(AnimationKey.Right, animation);

            animation = new Animation(frameCount, spriteWidth, spriteHeight, 0, spriteHeight * 2, false);
            animation.FramesPerSecond = 10;

            animations.Add(AnimationKey.Left, animation);

            animation = new Animation(frameCount, spriteWidth, spriteHeight, 0, spriteHeight * 3, false);
            animation.FramesPerSecond = 10;

            animations.Add(AnimationKey.Up, animation);

            sprite = new AnimatedSprite(
                attackTexture,
                animations,
                Color.White);

            AnimatedSprites.Add("Attack", sprite);

            _health = new AttributePair(400);
            _shield = new AttributePair(200);

            Rectangle windowBounds = World.Game.Window.ClientBounds;
            _inventory = new InventoryManager(World.Game.Content, new Vector2(10, windowBounds.Height - 70));
            _velocity = new Vector2(3, 3);

            this.XCollisionOffset = 30;
            this.TopCollisionOffset = (int)(CurrentSprite.Height / 2);

            _healthClock = new HealthClock(_health, _shield, new Vector2(10, 10), World.Game.Content);
        }