示例#1
0
 public Decoration(DecorManager dm, ref TextureRegion[] tileRegions)
 {
     _dm = dm;
     _hitRect = new Rectangle(0, 0, 50, 50);
     _tileRegions = tileRegions;
     _numberOfElementsAllTogether = DecorHelper.BushCount + DecorHelper.RockCount + DecorHelper.TreeCount;
     _spriteBatch = PlayScreen.Spritebatch;
     _myTexture = PlayScreen.DecorationTexture;
     _treeDestroyAnimation = new DestroyTreeAnim("treefalling");
 }
示例#2
0
文件: Manager.cs 项目: Choochoo/Ship
        public Manager()
        {
            if (MyManager == null)
                MyManager = this;
            else return;

            //!!watch order!!
            _tileManager = new TileManager(this);
            _charManager = new CharacterManager();
            _decorManager = new DecorManager();
            _miniTileManager = new MiniTileManager();
            _interfaceManager = new InterfaceManager();
            _messageManager = new MessageManager();
            _loaderBaseManager = new LoaderBaseManager();
            _itemPool = new ItemPool(10);

            //load data
            _tileManager.LoadData(ref _loaderBaseManager.Loaders);
            _decorManager.LoadData();
            _charManager.LoadData();
        }
示例#3
0
        public bool SetInfo(DecorManager decorManager, byte type)
        {
            _visible = type != DecorHelper.None;
            MyType = type;
            if (!_visible) return false;

            _animLastUpdate = 0;
            _lasthitPointUpdate = 500;

            //returns isLightSource;

            if (type >= DecorHelper.Tree && type <= DecorHelper.Bush)
            {
                var rand = new Random(SectorX + MySectorSpotX + SectorY + MySectorSpotY);
                _bounds = new Rectangle[1];
                _addons = new Vector2[1];

                _myType = Foliage;
                var value = 0;
                switch (type)
                {
                    case DecorHelper.Tree:
                        value = rand.Next(1, DecorHelper.TreeCount + 1);

                        break;
                    case DecorHelper.Rock:
                        //as to be more than 1
                        value = (DecorHelper.TreeCount - 1) + 1;
                        break;
                    case DecorHelper.Bush:
                        value = (DecorHelper.TreeCount - 1) + 1 + rand.Next(1, DecorHelper.BushCount + 1);
                        break;
                }

                _bounds[0] = _tileRegions[value].Bounds;
                var valueX = (Position.X + rand.Next(16, 48)) - (_bounds[0].Width/2.0f);
                var valueY = Position.Y - _bounds[0].Height + rand.Next(16, 48);

                _addons[0] = new Vector2(valueX, valueY);

                switch (type)
                {
                    case DecorHelper.Tree:
                        _hitRect.Width = 40;
                        _hitRect.Height = 30;
                        _hitRect.X = (int) (valueX + ((_bounds[0].Width/2.0) - (HitRect.Width/2.0)));
                        _hitRect.Y = (int) (valueY + _bounds[0].Height - _hitRect.Height);
                        break;
                    case DecorHelper.Rock:
                    case DecorHelper.Bush:
                        _hitRect.Width = _bounds[0].Width;
                        _hitRect.Height = _bounds[0].Height - 15;
                        _hitRect.X = (int) valueX;
                        _hitRect.Y = (int) valueY + 15;
                        break;
                }
            }
            else if (type == DecorHelper.Fire)
            {
                _myType = Fire;
                _bounds = new Rectangle[3];
                _addons = new Vector2[4];
                var value = decorManager.FireStart;
                _bounds[0] = _tileRegions[value].Bounds;

                _position.X = 32 - _bounds[0].Width/2;
                _position.Y = 32 - _bounds[0].Height/2;
                _hitRect.X = (int) _position.X;
                _hitRect.Y = (int) _position.Y;
                _bounds[1] = _tileRegions[value + 1].Bounds;
                _bounds[2] = _tileRegions[value + 2].Bounds;
                _addons[0] = new Vector2(6, -4);
                _addons[1] = new Vector2(5, 0);
                _addons[2] = new Vector2(5, -(_bounds[2].Height/2));
                _addons[3] = new Vector2(5, -(_bounds[2].Height));
                return true;
            }

            return false;
        }