Exemple #1
0
 public Player(Texture2D texture, Rectangle spawnPos, int id)
     : base(texture, spawnPos, id)
 {
     if (_lifeBar == null)
         _lifeBar = ContentInterface.LoadTexture("White");
     _pointer = new PlayerPointer(this._name, ContentInterface.LoadTexture("Arrow"));
     _speed = Vector2.Zero;
     _onGround = false;
     //_bodyParts = new List<BodyPart>();
     _inventory = new Logic.Inventory(this);
     flying = true;
     _collisionOffset = new Vector4((((16 - spawnPos.Width) % 16 + 16) % 16) + 0.6f, 0, (((16 - spawnPos.Height) % 16 + 16) % 16) + 0.99975f, 0.0015f);
     //_completeBody = new BaseBody(null);
     int dim = _texture.Bounds.Height;
     _aniControl = new AnimationController();
     _aniControl.Run = new Animation(100, dim,dim, new int[] { 0, 1, 2, 3, 4, 5, 6});
     _aniControl.Idle = _aniControl.Run;
     _aniControl.Jump = new Animation(100, dim,dim, new int[] { 7, 8, 9, 10, 11, 12 });
     _aniControl.Fly = new Animation(100, dim,dim, new int[] { 12 });
     _aniControl.Fall = _aniControl.Fly;
     _aniControl.Land = new Animation(100, dim,dim, new int[] { 13, 14, 15, 16, 17 });
     _aniControl.Wall = new Animation(100, dim,dim, new int[] { 18, 19, 20, 21, 22, 23 });
     _attachedAnimations = new List<AnimationContainer>();
     //CalculateTotalBonus();
 }
Exemple #2
0
        public Player(string CharFile, Rectangle spawnPos, int id)
            : base(null,spawnPos,id)
        {
            _inventory = new Logic.Inventory(this);
            if (_lifeBar == null)
                _lifeBar = ContentInterface.LoadTexture("White");

            string fileContent = ContentInterface.LoadFile("chars/" + CharFile);
            string[] lines = fileContent.Split(new string[] { "\n", Environment.NewLine }, StringSplitOptions.None);
            int.TryParse(lines[0], out _rect.Width);
            int.TryParse(lines[1], out _rect.Height);
            int dimX;
            int dimY;
            int.TryParse(lines[2], out dimX);
            int.TryParse(lines[3], out dimY);
            string texture = lines[4];
            _texture = ContentInterface.LoadTexture(texture);
            int.TryParse(lines[5], out _hp);
            _maxhp = _hp;

            _aniControl = new AnimationController();
            for (int x = 0; x < lines.Length - 6; x++)
            {
                string[] nums = lines[6 + x].Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                int[] iNums = new int[nums.Length - 1];
                for (int y = 0; y < nums.Length - 1; y++)
                {
                    iNums[y] = int.Parse(nums[y + 1]);
                }
                int num = int.Parse(nums[0]);
                int dim = _texture.Bounds.Height;
                switch (x)
                {
                    case 0: _aniControl.Run = new Animation(num, dimX, dimY, iNums); break;
                    case 1: _aniControl.Idle = new Animation(num, dimX, dimY, iNums); break;
                    case 2: _aniControl.Jump = new Animation(num, dimX, dimY, iNums); break;
                    case 3: _aniControl.Fly = new Animation(num, dimX, dimY, iNums); break;
                    case 4: _aniControl.Fall = new Animation(num, dimX, dimY, iNums); break;
                    case 5: _aniControl.Land = new Animation(num, dimX, dimY, iNums); break;
                    case 6: _aniControl.Wall = new Animation(num, dimX, dimY, iNums); break;
                    default: _aniControl.AddAnimation(new Animation(num, dimX, dimY, iNums)); break;
                }
            }

            _speed = Vector2.Zero;
            _onGround = false;
            //_bodyParts = new List<BodyPart>();
            flying = true;
            _collisionOffset = new Vector4((((16 - _rect.Width) % 16 + 16) % 16) + 0.6f, 0, (((16 - _rect.Height) % 16 + 16) % 16) + 0.99975f, 0.0015f);
            //_completeBody = new BaseBody(null);
            //CalculateTotalBonus();
            _pointer = new PlayerPointer(this._name, ContentInterface.LoadTexture("Arrow"));
            _body = new Body.Body(this);
            _attachedAnimations = new List<AnimationContainer>();
        }