Esempio n. 1
0
 public GameObject(Vector2 pos, AnimationTexture animTex)
     : this()
 {
     this.position = pos;
     this.aT       = animTex;
     scaler        = 1.0f;
 }
Esempio n. 2
0
        public void Initialize(Vector2 pos, float mass, Vector2 velocity,
                               int boundingBoxWidth, int boundingBoxHeight,
                               AnimatedSpriteSheet animSS, AnimationTexture animTex,
                               TimeSpan timeToLive, float scaler, Character owner)
        {
            this.position = pos;
            this.mass     = mass;
            this.velocity = velocity;
            if (animSS != null)
            {
                Vector2 temp = animSS.getBoundingBox();
                this.boundingBox.X      = (int)pos.X;
                this.boundingBox.Y      = (int)pos.Y;
                this.boundingBox.Width  = (int)(temp.X * scaler);
                this.boundingBox.Height = (int)(temp.Y * scaler);
                this.aSS = animSS;
            }
            else if (animTex != null)
            {
                Vector2 temp = animTex.getBoundingBox();
                this.boundingBox.X      = (int)pos.X;
                this.boundingBox.Y      = (int)pos.Y;
                this.boundingBox.Width  = (int)(temp.X * scaler);
                this.boundingBox.Height = (int)(temp.Y * scaler);
                this.aT = animTex;
            }

            this.isActive        = true;
            this.ttl             = timeToLive;
            this.scaler          = scaler;
            this.owner           = owner;
            this.currentRotation = MathHelper.ToRadians(random.Next(75));
            this.rotVal         += MathHelper.ToRadians(random.Next(7) + 1);
        }
Esempio n. 3
0
 public Projectile(Vector2 pos, float mass, Vector2 velocity,
                   int boundingBoxWidth, int boundingBoxHeight,
                   AnimationTexture animT, TimeSpan timeToLive, float scaler)
     : base(pos, mass, velocity, boundingBoxWidth, boundingBoxHeight, animT)
 {
     this.ttl   = timeToLive;
     this.owner = null;
 }
Esempio n. 4
0
        public void LoadTextures(ContentManager content, String prefix)
        {
            //String prefix = "Player\\player";

            idle = new AnimationTexture(TimeSpan.Zero, true);
            idle.AddFrame(content.Load <Texture2D>(@prefix + "_idle"));
            idle.ResetTimer(TimeSpan.Zero);
            idle.SetFrameRate(0.0001);
            idle.ReStartAnimation(TimeSpan.Zero);

            run = new AnimationTexture(TimeSpan.Zero, true);
            try
            {
                run.AddFrame(content.Load <Texture2D>(@prefix + "_run2"));
                run.AddFrame(content.Load <Texture2D>(@prefix + "_run1"));
                run.AddFrame(content.Load <Texture2D>(@prefix + "_run2"));
                run.AddFrame(content.Load <Texture2D>(@prefix + "_run3"));
                run.SetFrameRate(5.0);
                run.ReStartAnimation(TimeSpan.Zero);
                run.ResetTimer(TimeSpan.Zero);
            }
            catch (Exception e)
            { run = idle; }

            try
            {
                jump = new AnimationTexture(TimeSpan.Zero, false);
                jump.AddFrame(content.Load <Texture2D>(@prefix + "_jump1"));
                jump.AddFrame(content.Load <Texture2D>(@prefix + "_jump2"));
                jump.AddFrame(content.Load <Texture2D>(@prefix + "_jump3"));
                jump.AddFrame(content.Load <Texture2D>(@prefix + "_jump4"));
                jump.SetFrameRate(15.0);
                jump.ReStartAnimation(TimeSpan.Zero);
                jump.ResetTimer(TimeSpan.Zero);
            }
            catch (Exception e)
            { jump = idle; }

            try
            {
                throwItem = new AnimationTexture(TimeSpan.Zero, true);
                throwItem.AddFrame(content.Load <Texture2D>(@prefix + "_shoot"));
                throwItem.SetFrameRate(0.0001);
                throwItem.ResetTimer(TimeSpan.Zero);
                throwItem.ReStartAnimation(TimeSpan.Zero);
            }
            catch (Exception e)
            { throwItem = idle; }

            try
            {
                punch = new AnimationTexture(TimeSpan.Zero, false);
                punch.AddFrame(content.Load <Texture2D>(@prefix + "_throwing3"));
                punch.AddFrame(content.Load <Texture2D>(@prefix + "_throwing2"));
                punch.AddFrame(content.Load <Texture2D>(@prefix + "_throwing1"));
                punch.AddFrame(content.Load <Texture2D>(@prefix + "_throwing4"));
                punch.SetFrameRate(10.0);
                punch.ResetTimer(TimeSpan.Zero);
                punch.ReStartAnimation(TimeSpan.Zero);
                punch.SetFrameRate(10.0);
            }
            catch (Exception e)
            { punch = idle; }

            addAnimation("Idle", idle);
            addAnimation("Walk", run);
            addAnimation("Jump", jump);
            addAnimation("Shoot", throwItem);
            addAnimation("Punch", punch);
        }
Esempio n. 5
0
 public virtual void addAnimation(string animName, AnimationTexture animTex)
 {
     this.animationLibrary.Add(animName, animTex);
 }
Esempio n. 6
0
 public GameObject(Vector2 pos, AnimationTexture animTex, float scaler) : this(pos, animTex)
 {
     this.scaler = scaler;
 }
 public InteractiveObject(Vector2 pos, float mass, Vector2 velocity, int boundingBoxWidth, int boundingBoxHeight, AnimationTexture animT, float scaler)
     : this(pos, mass, velocity, boundingBoxWidth, boundingBoxHeight, animT)
 {
     this.scaler = scaler;
 }
 /// <summary>
 /// Good STUFF!
 /// Constructor for proper interactive objects frmo animatedTextures.
 /// </summary>
 public InteractiveObject(Vector2 pos, float mass, Vector2 velocity, int boundingBoxWidth, int boundingBoxHeight, AnimationTexture animT)
     : base(pos, animT)
 {
     construct(mass, velocity, boundingBoxWidth, boundingBoxHeight);
 }