public NPC(string name, Vector3 position, ComponentManager componentManager, ContentManager content, GraphicsDevice graphics, string spritesheet) : base(name, position, componentManager, content, graphics, spritesheet) { MaxWalkTime = 5.0f; MaxDieTime = 1.0f; WalkTimer = new Timer((int)(10000*position.X) % 7, true); DieTimer = new Timer(MaxDieTime, false); Target = Vector3.Zero; OrientWithVelocity = true; Texture2D sprites = content.Load<Texture2D>(spritesheet); List<Point> deadFrame = new List<Point>(); deadFrame.Add(new Point(0, 1)); OrientedAnimation dead = new OrientedAnimation(new Animation(graphics, sprites, name + "_dead_left", 32, 32, deadFrame, true, Color.White, 14.0f, 0.8f, 1, false), new Animation(graphics, sprites, name + "_dead_right", 32, 32, deadFrame, true, Color.White, 14.0f, 0.8f, 1, true)); image.AddOrientedAnimation(dead); AnimationState["dead"] = dead.Name; List<Point> dyingFrame = new List<Point>(); dyingFrame.Add(new Point(0, 2)); dyingFrame.Add(new Point(1, 2)); dyingFrame.Add(new Point(2, 2)); dyingFrame.Add(new Point(3, 2)); dyingFrame.Add(new Point(4, 2)); OrientedAnimation dying = new OrientedAnimation(new Animation(graphics, sprites, name + "_dying_left", 32, 32, dyingFrame, false, Color.White, 7.0f, 0.8f, 1, false), new Animation(graphics, sprites, name + "_dying_right", 32, 32, dyingFrame, false, Color.White, 7.0f, 0.8f, 1, true)); image.AddOrientedAnimation(dying); dying.Play(); AnimationState["dying"] = dying.Name; List<Point> flyFrame = new List<Point>(); flyFrame.Add(new Point(0, 3)); OrientedAnimation fly = new OrientedAnimation(new Animation(graphics, sprites, name + "_fly_left", 32, 32, flyFrame, true, Color.White, 2.0f, 0.8f, 1, true), new Animation(graphics, sprites, name + "_fly_right", 32, 32, flyFrame, true, Color.White, 2.0f, 0.8f, 1, false)); image.AddOrientedAnimation(fly); AnimationState["fly"] = fly.Name; State = "walk"; SetAnimation(); Matrix translation = Matrix.CreateTranslation(new Vector3(0, 1, 0)); Texture2D heartsprite = content.Load<Texture2D>("heartrate"); monitor = new BillboardSpriteComponent(componentManager, "heart", this, translation, heartsprite, false); monitor.OrientsToCamera = true; List<Point> aliveP = new List<Point>(); aliveP.Add(new Point(0, 0)); aliveP.Add(new Point(1, 0)); aliveP.Add(new Point(2, 0)); aliveP.Add(new Point(3, 0)); monitor.AddAnimation(new Animation(graphics, heartsprite, "alive", 32, 10, aliveP, true, Color.White, 5.0f, 0.7f, 0.2f, false)); List<Point> deadP = new List<Point>(); deadP.Add(new Point(4, 0)); monitor.AddAnimation(new Animation(graphics, heartsprite, "dead", 32, 10, deadP, true, Color.White, 5.0f, 0.7f, 0.2f, false)); foreach (Animation anim in monitor.Animations.Values) anim.Play(); image.LocalTransform = Matrix.CreateTranslation(new Vector3(0, -0.25f, 0)); }
public Player(string tag, Vector3 position, ComponentManager componentManager, ContentManager content, GraphicsDevice graphics, string spritesheet) : base(tag, position, componentManager, content, graphics, "surgeonwalk") { pastPos = new Queue<Vector3>(); DefibCharge = 0; DefibChargeRate = 0.5f; isReady = false; Texture2D sprites = content.Load<Texture2D>(spritesheet); List<Point> lowIdle = new List<Point>(); lowIdle.Add(new Point(0, 1)); lowIdle.Add(new Point(1, 1)); lowIdle.Add(new Point(2, 1)); lowIdle.Add(new Point(3, 1)); OrientedAnimation idleLow = new OrientedAnimation(new Animation(graphics, sprites, tag + "_idle_low_left", 32, 32, lowIdle, true, Color.White, 10.0f, 0.8f, 1, false), new Animation(graphics, sprites, tag + "_idle_low_right", 32, 32, lowIdle, true, Color.White, 10.0f, 0.8f, 1, true)); idleLow.Play(); image.AddOrientedAnimation(idleLow); AnimationState["idle_low"] = idleLow.Name; List<Point> lowWalk = new List<Point>(); lowWalk.Add(new Point(0, 2)); lowWalk.Add(new Point(1, 2)); lowWalk.Add(new Point(2, 2)); lowWalk.Add(new Point(3, 2)); OrientedAnimation walkLow = new OrientedAnimation(new Animation(graphics, sprites, tag + "_walk_low_left", 32, 32, lowWalk, true, Color.White, 10.0f, 0.8f, 1, false), new Animation(graphics, sprites, tag + "_walk_low_right", 32, 32, lowWalk, true, Color.White, 10.0f, 0.8f, 1, true)); walkLow.Play(); image.AddOrientedAnimation(walkLow); AnimationState["walk_low"] = walkLow.Name; List<Point> highIdle = new List<Point>(); highIdle.Add(new Point(0, 3)); highIdle.Add(new Point(1, 3)); highIdle.Add(new Point(2, 3)); highIdle.Add(new Point(3, 3)); OrientedAnimation idleHigh = new OrientedAnimation(new Animation(graphics, sprites, tag + "_idle_high_left", 32, 32, highIdle, true, Color.White, 10.0f, 0.8f, 1, false), new Animation(graphics, sprites, tag + "_idle_high_right", 32, 32, highIdle, true, Color.White, 10.0f, 0.8f, 1, true)); idleHigh.Play(); image.AddOrientedAnimation(idleHigh); AnimationState["idle_high"] = idleHigh.Name; List<Point> highWalk = new List<Point>(); highWalk.Add(new Point(0, 4)); highWalk.Add(new Point(1, 4)); highWalk.Add(new Point(2, 4)); highWalk.Add(new Point(3, 4)); OrientedAnimation walkHigh = new OrientedAnimation(new Animation(graphics, sprites, tag + "_walk_high_left", 32, 32, highWalk, true, Color.White, 10.0f, 0.8f, 1, false), new Animation(graphics, sprites, tag + "_walk_high_right", 32, 32, highWalk, true, Color.White, 10.0f, 0.8f, 1, true)); walkHigh.Play(); image.AddOrientedAnimation(walkHigh); AnimationState["walk_high"] = walkHigh.Name; }