Esempio n. 1
0
        public void LoadRegion(RegionNames regionName, Dictionary <RegionNames, ContentManager> contentManagers,
                               Dictionary <RegionNames, Dictionary <int, Texture2D> > regionTextures,
                               Dictionary <RegionNames, List <GameObject> > regionGameObjects,
                               Dictionary <RegionNames, List <GameObject> > regionCameraObjects,
                               Dictionary <RegionNames, List <GameObject> > regionBackgroundObjects,
                               Dictionary <RegionNames, List <GameObject> > regionForegroundObjects)
        {
            var regionContentManager = new ContentManager(_serviceProvider, _rootDirectory);
            var newRegionTextures    = new Dictionary <int, Texture2D>();

            var stringRegionName = Enum.GetName(typeof(RegionNames), regionName);
            var filePrefix       = "EnvironmentTextures/" + stringRegionName + "/";

            var fileNames = regionContentManager.Load <Dictionary <int, string> >(filePrefix + stringRegionName + "Names");

            foreach (var file in fileNames.Keys)
            {
                newRegionTextures.Add(file, regionContentManager.Load <Texture2D>(filePrefix + fileNames[file]));
            }

            var gameObjects   = new List <GameObject>();
            var cameraObjects = new List <GameObject>();
            var bgObjects     = new List <GameObject>();
            var fgObjects     = new List <GameObject>();

            _regionConstructor.ConstructRegion(regionName, gameObjects, cameraObjects, bgObjects, fgObjects);

            contentManagers.Add(regionName, regionContentManager);
            regionTextures.Add(regionName, newRegionTextures);
            regionGameObjects.Add(regionName, gameObjects);
            regionCameraObjects.Add(regionName, cameraObjects);
            regionBackgroundObjects.Add(regionName, bgObjects);
            regionForegroundObjects.Add(regionName, fgObjects);
        }
        public DoubleImageTabItem(IContainerExtension container, IRegionManager regionManager)
        {
            InitializeComponent();

            int count = 2;

            for (int i = 0; i < count; i++)
            {
                var view = container.Resolve <ImagePanel>();
                view.SetContentIndex(i);

                regionManager.RegisterViewWithRegion(
                    RegionNames.GetImageContentRegionName(count, i),
                    () => view);
            }

            // NG:以下では登録できるがViewModelに引数を渡せない
            //regionManager.RegisterViewWithRegion("Image2ContentRegion", typeof(ImagePanel));

            // NG:以下で登録しようとするとRegionが見つからないと言われる謎
            //regionManager.AddToRegion("Image2ContentRegion", container.Resolve<ImagePanel>());

            // NG:以下で登録しようとするとRegionが見つからないと言われる謎
            //regionManager.Regions["Image2ContentRegion"].Add(container.Resolve<ImagePanel>());
        }
 /// <summary>
 /// リージョンのViewを削除する
 /// </summary>
 private void RemoveImagePanelViewRegions()
 {
     foreach (var name in RegionNames.GetImageContentRegionNames(_contentCount))
     {
         _regionManager.Regions[name].RemoveAll();
     }
 }
Esempio n. 4
0
 public PiercingWeapon(RegionNames region, List <int> imageIndexes, Layer layer, Vector2 anchorPoint, int damage, int swingSpeed, Vector2 weaponImageSize, float length, Vector2 headSize) :
     base(region, imageIndexes, layer, anchorPoint, damage, swingSpeed, weaponImageSize)
 {
     _type     = WeaponType.Piercing;
     _animator = new Animator(ConstructAnimations(), WeaponAnimations.HIDDEN);
     _length   = length;
     _headSize = headSize;
 }
Esempio n. 5
0
 public RegionOffset(RegionNames anchorRegion, RegionNames otherRegion, int anchorZone, int otherZone, Vector2 offset)
 {
     _anchorRegion = anchorRegion;
     _otherRegion  = otherRegion;
     _anchorZone   = anchorZone;
     _otherZone    = otherZone;
     _offset       = offset;
 }
Esempio n. 6
0
 public void BeginSpin(GameStates spinEndState, RegionNames region)
 {
     _spinning          = true;
     _queuedUpState     = spinEndState;
     _fullScreenSpin    = true;
     _spinCounter       = 0;
     _regionImageToShow = region;
 }
Esempio n. 7
0
        public BackgroundImageObject(RegionNames region, List <int> imageIndex, Layer layer, Vector2 anchorPoint, Vector2 size)
            : base(region, imageIndex, layer, anchorPoint, 0)
        {
            var animationDictionary = new Dictionary <int, Animation>();

            animationDictionary.Add(0, new Animation(0, 1, 1, size));

            _animator = new Animator(animationDictionary, 0);
        }
Esempio n. 8
0
        public BluntingWeapon(RegionNames region, List <int> imageIndexes, Layer layer, Vector2 anchorPoint, int damage, int swingSpeed, Vector2 weaponImageSize, float length, float bulbRadius) :
            base(region, imageIndexes, layer, anchorPoint, damage, swingSpeed, weaponImageSize)
        {
            _type     = WeaponType.Blunting;
            _animator = new Animator(ConstructAnimations(), 0);

            _rectangular = false;
            _length      = length;
            _bulbRadius  = bulbRadius;
        }
Esempio n. 9
0
        public Camera(RegionNames region, List <int> imageIndex, Layer layer, Vector2 anchorPoint, float gravitationalConstant)
            : base(region, imageIndex, layer, anchorPoint, gravitationalConstant)
        {
            _position    = new Vector2(0, 0);
            _panLocation = new Vector2(0, 0);
            _panning     = false;
            _locked      = false;
            _mask        = GameConstants.PHANTOM_COLLISION_MASK;

            _collisionBoxes.Add(new RectangleCollisionBox(this, new Vector2(0, 0), 1, 1, _mask));
        }
Esempio n. 10
0
        public Spinner(ResourceManager resourceManager, Fader fader)
        {
            _resourceManager = resourceManager;
            _fader           = fader;

            var animationDictionary = new Dictionary <int, Animation>();

            animationDictionary.Add(0, new Animation(0, 6, 3, new Vector2(60, 60)));
            _animator = new Animator(animationDictionary, 0);

            _regionImageToShow = RegionNames.Unknown;
            _spinCounter       = 0;
        }
Esempio n. 11
0
        public GameObject(RegionNames region, List <int> imageIndexes, Layer layer, Vector2 anchorPoint, float gravitationalConstant)
        {
            _region                = region;
            _imageIndexes          = imageIndexes;
            _layer                 = layer;
            _gravitationalConstant = gravitationalConstant;
            _anchorPoint           = anchorPoint;
            _position              = anchorPoint;               // is this right?
            _collisionBoxes        = new List <CollisionBox>(); // we might not want to do this here

            _velocityPerFrame     = new Vector2(0, 0);
            _accelerationPerFrame = new Vector2(0, 0);
        }
Esempio n. 12
0
        private void CreateZoneDrawInfo(RegionNames region, Zone zone, List <DrawInfo> info, Vector2 offset, ResourceManager resourceManager, Vector2 cameraTopLeft)
        {
            foreach (var scenery in zone.SceneryObjects)
            {
                var textures      = resourceManager.RegionContent[region].SceneryTextures[scenery.Name];
                var texture       = GetTextureFromList(textures, scenery.Animator);
                var drawLocation  = scenery.Location + scenery.Animator.DrawOffset + offset;
                var x             = scenery.Animator.ImageSize.X * scenery.Animator.AnimationCounter;
                var y             = (scenery.Animator.ImageSize.Y * scenery.Animator.CurrentAnimation.Row) % GameConstants.MAX_TEXTURE_SIZE.Y;
                var drawRectangle = new Rectangle((int)x, (int)y, (int)scenery.Animator.ImageSize.X, (int)scenery.Animator.ImageSize.Y);
                var drawInfo      = new DrawInfo(scenery.OnFloor, texture, drawLocation, drawRectangle, scenery.Level);

                if (IsOnScreen(cameraTopLeft, drawLocation, scenery.Animator.ImageSize))
                {
                    info.Add(drawInfo);
                }
            }

            foreach (var tileObject in zone.TileObjects)
            {
                var textures      = resourceManager.RegionContent[region].ObjectTextures[tileObject.Name];
                var texture       = GetTextureFromList(textures, tileObject.Animator);
                var drawLocation  = tileObject.Location + tileObject.Animator.DrawOffset + offset;
                var x             = tileObject.Animator.ImageSize.X * tileObject.Animator.AnimationCounter;
                var y             = (tileObject.Animator.ImageSize.Y * tileObject.Animator.CurrentAnimation.Row) % GameConstants.MAX_TEXTURE_SIZE.Y;
                var drawRectangle = new Rectangle((int)x, (int)y, (int)tileObject.Animator.ImageSize.X, (int)tileObject.Animator.ImageSize.Y);
                var drawInfo      = new DrawInfo(false, texture, drawLocation, drawRectangle, tileObject.Level);

                if (IsOnScreen(cameraTopLeft, drawLocation, tileObject.Animator.ImageSize))
                {
                    info.Add(drawInfo);
                }
            }

            foreach (var npc in zone.Npcs)
            {
                var textures      = resourceManager.RegionContent[region].NpcTextures[npc.Name];
                var texture       = GetTextureFromList(textures, npc.Animator);
                var drawLocation  = npc.Location + npc.Animator.DrawOffset + offset;
                var x             = npc.Animator.ImageSize.X * npc.Animator.AnimationCounter;
                var y             = (npc.Animator.ImageSize.Y * npc.Animator.CurrentAnimation.Row) % GameConstants.MAX_TEXTURE_SIZE.Y;
                var drawRectangle = new Rectangle((int)x, (int)y, (int)npc.Animator.ImageSize.X, (int)npc.Animator.ImageSize.Y);
                var drawInfo      = new DrawInfo(false, texture, drawLocation, drawRectangle, npc.Level);

                if (IsOnScreen(cameraTopLeft, drawLocation, npc.Animator.ImageSize))
                {
                    info.Add(drawInfo);
                }
            }
        }
        /// <summary>
        /// 指定Countに対応する画像RegionのViewsを取得(2画面なら 2_0 → 2_1 を返す)
        /// </summary>
        /// <returns></returns>
        //private IEnumerable<T> GetImageContentViews<T>() where T : FrameworkElement =>
        //    RegionNames.GetImageContentRegionNames(_contentCount)
        //        .Select(name => _regionManager.Regions[name].Views.Cast<T>().FirstOrDefault());

        /// <summary>
        /// Viewを作成してリージョンに登録する
        /// </summary>
        private void RegisterImagePanelViewRegions(int contentIndexOffset = 0)
        {
            var regionNames = RegionNames.GetImageContentRegionNames(_contentCount);

            foreach (var(name, index) in regionNames.Indexed())
            {
                _regionManager.RegisterViewWithRegion(name, () =>
                {
                    var contentIndex = (index + contentIndexOffset) % _contentCount;
                    var parameters   = ImageViewParameterFactory.GetImageViewParameters(contentIndex, _contentCount);
                    return(_container.Resolve <ImagePanel>(parameters));
                });
            }
        }
        public TripleImageTabItem(IContainerExtension container, IRegionManager regionManager)
        {
            InitializeComponent();

            int count = 3;

            for (int i = 0; i < count; i++)
            {
                var view = container.Resolve <ImagePanel>();
                view.SetContentIndex(i);

                regionManager.RegisterViewWithRegion(
                    RegionNames.GetImageContentRegionName(count, i),
                    () => view);
            }
        }
        /// <summary>
        /// 画像タブを移行させる
        /// </summary>
        /// <param name="regionManager"></param>
        /// <param name="tabIndex">切り替え後のTab指定(1画面=1, null=切替えなし)</param>
        private static void NativateImageTabContent(IRegionManager regionManager, int?tabIndex)
        {
            if (!tabIndex.HasValue)
            {
                return;
            }
            var index = tabIndex.Value;

            if (index < 0 || _imageCountMax < index)
            {
                throw new IndexOutOfRangeException(index.ToString());
            }

            var tabName = RegionNames.GetTabContentName(index);

            regionManager.RequestNavigate(MainTabContentRegion, tabName);
        }
Esempio n. 16
0
        public Weapon(RegionNames region, List <int> imageIndexes, Layer layer, Vector2 anchorPoint, int damage, int swingSpeed, Vector2 weaponSize)
            : base(region, imageIndexes, layer, anchorPoint, 0f)
        {
            _damage     = damage;
            _swingSpeed = swingSpeed;

            _maskType = GameConstants.STANDARD_COLLISION_MASK;
            _mask     = GameConstants.STANDARD_COLLISION_MASK + GameConstants.TERRAIN_COLLISION_MASK;

            _weaponSize = weaponSize;

            _attackLeftBoxOffsets     = new Dictionary <CollisionBox, List <Vector2> >();
            _attackRightBoxOffsets    = new Dictionary <CollisionBox, List <Vector2> >();
            _airAttackLeftBoxOffsets  = new Dictionary <CollisionBox, List <Vector2> >();
            _airAttackRightBoxOffsets = new Dictionary <CollisionBox, List <Vector2> >();

            _attackFinished = true;
        }
        public PathfinderTraitForm()
        {
            InitializeComponent();

            this.loadedModifierList = CharacterCreator.Helpers.FileIO.Load <BindingList <ModifierData> >(this.modifierLoadPath);

            this.traitList              = CharacterCreator.Helpers.FileIO.Load <BindingList <TraitData> >(this.savePath);
            this.traitBox.DataSource    = this.traitList;
            this.traitBox.DisplayMember = "TraitName";
            this.traitBox.ValueMember   = "TraitName";

            this.traitTypeBox.DataSource      = TraitType.GetValues(typeof(TraitType));
            this.traitRegionBox.DataSource    = RegionNames.GetValues(typeof(RegionNames));
            this.traitCampaignBox.DataSource  = CampaignNames.GetValues(typeof(CampaignNames));
            this.traitRaceBox.DataSource      = RaceNames.GetValues(typeof(RaceNames));
            this.traitReligionBox.DataSource  = ReligionNames.GetValues(typeof(ReligionNames));
            this.traitConditionBox.DataSource = ConditionalStates.GetValues(typeof(ConditionalStates));
        }
        /// <summary>
        /// 画像(ViewModel)を右回りで入れ替え
        /// </summary>
        /// <param name="rightShiftRequest">右シフト回数</param>
        private void RightShiftViewModels(int rightShiftRequest = 1)
        {
            if (_contentCount <= 1)
            {
                return;                      // 回転する必要なし
            }
            if (rightShiftRequest == 0)
            {
                return;
            }

#if true
            // Vの作り直し
            RemoveImagePanelViewRegions();

            // 画像コンテンツ番号のシフト量(これまでの累積回転数を考慮)
            var indexShift = (-(_rightShiftCounter + rightShiftRequest)) % _contentCount;
            if (indexShift < 0)
            {
                indexShift += _contentCount;
            }
            RegisterImagePanelViewRegions(indexShift);
#elif false
            // Vの入れ替え
            var views = GetImageContentViews <FrameworkElement>().ToList().RightShift(rightShift);
            foreach (var(name, index) in RegionNames.GetImageContentRegionNames(_contentCount).Indexed())
            {
                _regionManager.Regions[name].RemoveAll();
                _regionManager.RegisterViewWithRegion(name, () => views[index]);
            }
#else
            // VMの入れ替え
            var views   = GetImageContentViews <FrameworkElement>().ToArray();
            var vmodels = views.Select(x => x.DataContext).ToArray().AsSpan()
                          .RightShift(rightShift);

            for (int i = 0; i < views.Length; i++)
            {
                views[i].DataContext = vmodels[i];
            }
#endif
            // ViewModel内の回転数を加算
            _rightShiftCounter += rightShiftRequest;
        }
Esempio n. 19
0
        public SingleImageTabItem(IContainerExtension container, IRegionManager regionManager)
        {
            InitializeComponent();

            // 以下で動くが他画像に合わせる
            //regionManager.RegisterViewWithRegion(RegionNames.ImageContentRegion1_0, typeof(ImagePanel));

            int count = 1;

            for (int i = 0; i < count; i++)
            {
                var view = container.Resolve <ImagePanel>();
                view.SetContentIndex(i);

                regionManager.RegisterViewWithRegion(
                    RegionNames.GetImageContentRegionName(count, i),
                    () => view);
            }
        }
        public PlayerCharacter(RegionNames region, List <int> imageIndexes, Layer layer, Vector2 anchorPoint, float gravitationalConstant)
            : base(region, imageIndexes, layer, anchorPoint, gravitationalConstant)
        {
            _mask = GameConstants.PHANTOM_COLLISION_MASK + GameConstants.TERRAIN_COLLISION_MASK + GameConstants.STANDARD_COLLISION_MASK;

            _animator = new Animator(ConstructAnimations(), PlayerCharacterAnimationNames.STAND_RIGHT);
            _state    = CharacterStates.Stand;
            _collisionBoxes.Add(new RectangleCollisionBox(this, new Vector2(0, 0), (int)GameConstants.PLAYER_SPRITE_SIZE.X, (int)GameConstants.PLAYER_SPRITE_SIZE.Y, _mask));
            _availableWeapons = new List <Weapon>();
            _equippedWeapon   = -1;

            _totalReboundDistance = new Vector2(0, 0);
            _facingDirection      = Directions.Right;
            _jumpedVelocity       = new Vector2(0, 0);
            _dashCounter          = 0;

            _totalAdditionalJumpAccel = new Vector2(0, 0);

            _okStand = true;
        }
 public MoveableTerrainObject(RegionNames region, List <int> imageIndex, Layer layer, Vector2 anchorPoint, float gravitationalConstant)
     : base(region, imageIndex, layer, anchorPoint, gravitationalConstant)
 {
 }
Esempio n. 22
0
 public StationaryTerrainObject(RegionNames region, List <int> imageIndex, Layer layer, Vector2 anchorPoint, float friction)
     : base(region, imageIndex, layer, anchorPoint, friction)
 {
 }
Esempio n. 23
0
 public CameraCollisionObject(RegionNames region, List <int> imageIndex, Layer layer, Vector2 anchorPoint, float gravitationalConstant)
     : base(region, imageIndex, layer, anchorPoint, gravitationalConstant)
 {
     _mask = GameConstants.PHANTOM_COLLISION_MASK;
 }
 public StandardGameObject(RegionNames region, List <int> imageIndex, Layer layer, Vector2 anchorPoint, float gravitationalConstant)
     : base(region, imageIndex, layer, anchorPoint, gravitationalConstant)
 {
     _maskType = GameConstants.STANDARD_COLLISION_MASK;
 }
Esempio n. 25
0
        // i think this is fine since the npc name is what defines the texture i suppose
        public static Dictionary <NpcNames, List <Texture2D> > LoadNpcsForRegion(ContentManager contentManager, RegionNames region)
        {
            var npcTextures = new Dictionary <NpcNames, List <Texture2D> >();
            var npcs        = RegionFactory.GetInfoForRegion(region).Npcs;

            foreach (var npc in npcs)
            {
                var fileNames = GetFileNamesFromType(npc);
                var textures  = new List <Texture2D>();

                foreach (var file in fileNames)
                {
                    textures.Add(contentManager.Load <Texture2D>(file));
                }

                npcTextures.Add(npc, textures);
            }

            return(npcTextures);
        }
Esempio n. 26
0
 public SlashingWeapon(RegionNames region, List <int> imageIndexes, Layer layer, Vector2 anchorPoint, int damage, int swingSpeed, Vector2 weaponSize) :
     base(region, imageIndexes, layer, anchorPoint, damage, swingSpeed, weaponSize)
 {
     _type     = WeaponType.Slashing;
     _animator = new Animator(ConstructAnimations(), WeaponAnimations.HIDDEN);
 }
Esempio n. 27
0
        public static Dictionary <SceneryNames, List <Texture2D> > LoadSceneryTextures(ContentManager contentManager, RegionNames region)
        {
            var textureDictionary = new Dictionary <SceneryNames, List <Texture2D> >();

            var sceneryToLoad = RegionFactory.GetInfoForRegion(region).Scenery;

            foreach (var item in sceneryToLoad)
            {
                var list      = new List <Texture2D>();
                var fileNames = _sceneryInfo[item].FileNames;

                foreach (var name in fileNames)
                {
                    list.Add(contentManager.Load <Texture2D>(name));
                }

                textureDictionary[item] = list;
            }

            return(textureDictionary);
        }
Esempio n. 28
0
        private void DrawFileSelectImages(SpriteBatch sb, LogicHandler logic, ResourceManager resourceManager, Vector2 screenRatio, int index)
        {
            RegionNames file0Region = DataHelper.File0SaveData != null ? DataHelper.File0SaveData.FileInfo.LastRegion : RegionNames.None;
            RegionNames file1Region = DataHelper.File1SaveData != null ? DataHelper.File1SaveData.FileInfo.LastRegion : RegionNames.None;
            RegionNames file2Region = DataHelper.File2SaveData != null ? DataHelper.File2SaveData.FileInfo.LastRegion : RegionNames.None;

            var imageRectange = new Rectangle(0, 0, (int)FILE_IMAGE_SIZE.X, (int)FILE_IMAGE_SIZE.Y);

            sb.Draw(
                resourceManager.MenuResourceManager.FilePictures[file0Region],
                FILE_IMAGE_0_LOCATION * screenRatio,
                imageRectange,
                logic.DrawColor,
                GameConstants.DEFAULT_ROTATION,
                GameConstants.DEFAULT_IMAGE_ORIGIN,
                screenRatio,
                SpriteEffects.None,
                GameConstants.DEFAULT_LAYER);

            sb.Draw(
                resourceManager.MenuResourceManager.FilePictures[file1Region],
                FILE_IMAGE_1_LOCATION * screenRatio,
                imageRectange,
                logic.DrawColor,
                GameConstants.DEFAULT_ROTATION,
                GameConstants.DEFAULT_IMAGE_ORIGIN,
                screenRatio,
                SpriteEffects.None,
                GameConstants.DEFAULT_LAYER);

            sb.Draw(
                resourceManager.MenuResourceManager.FilePictures[file2Region],
                FILE_IMAGE_2_LOCATION * screenRatio,
                imageRectange,
                logic.DrawColor,
                GameConstants.DEFAULT_ROTATION,
                GameConstants.DEFAULT_IMAGE_ORIGIN,
                screenRatio,
                SpriteEffects.None,
                GameConstants.DEFAULT_LAYER);

            if (index == -1)
            {
                return;
            }

            var highlightLocation = FILE_IMAGE_0_LOCATION;

            if (index == 0)
            {
                highlightLocation = FILE_IMAGE_0_LOCATION;
            }
            else if (index == 1)
            {
                highlightLocation = FILE_IMAGE_1_LOCATION;
            }
            else if (index == 2)
            {
                highlightLocation = FILE_IMAGE_2_LOCATION;
            }

            sb.Draw(
                resourceManager.MenuResourceManager.FileImageHighlight,
                highlightLocation * screenRatio,
                imageRectange,
                logic.DrawColor,
                GameConstants.DEFAULT_ROTATION,
                GameConstants.DEFAULT_IMAGE_ORIGIN,
                screenRatio,
                SpriteEffects.None,
                GameConstants.DEFAULT_LAYER);
        }
 public TestPierceWeapon(RegionNames region, Layer layer, Vector2 anchorPoint) :
     base(region, new List <int>() { (int)WeaponNames.TestPierce }, Layer.MidMidground, anchorPoint, 7, 2, new Vector2(200, 200), 100, new Vector2(30, 20))
 {
     _name = WeaponNames.TestPierce;
     base.FillOffsets();
 }
 public TestSlashWeapon(RegionNames region, Layer layer, Vector2 anchorPoint) :
     base(region, new List <int>() { (int)WeaponNames.TestSlash }, Layer.MidMidground, anchorPoint, 5, 1, new Vector2(150, 150))
 {
     _name = WeaponNames.TestSlash;
     FillBoxOffsets();
 }