コード例 #1
0
 public void AddOrientedAnimation(OrientedAnimation animation)
 {
     if (CurrentOrientedAnimation == null)
     {
         CurrentOrientedAnimation = animation;
     }
     foreach (Animation anim in animation)
     {
         AddAnimation(anim);
     }
     OrientedAnimations[animation.Name] = animation;
 }
コード例 #2
0
ファイル: NPC.cs プロジェクト: careid/myheartisinthework
        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));
        }
コード例 #3
0
ファイル: Player.cs プロジェクト: careid/myheartisinthework
        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;
        }
コード例 #4
0
ファイル: Person.cs プロジェクト: careid/myheartisinthework
        public Person(string _tag, Vector3 position,
            ComponentManager componentManager,
            ContentManager content,
            GraphicsDevice graphics,
            string spritesheet)
            : base(componentManager, "person", componentManager.RootComponent, Matrix.CreateTranslation(position),  new Vector3(0.5f, 1.0f, 0.5f),
            new Vector3(0.0f, -0.3f, 0.0f),  1.0f, 1.0f, 0.999f, 0.999f)
        {
            OrientWithVelocity = true;
            Texture2D sprites = content.Load<Texture2D>(spritesheet);
            tag = _tag;
            Tags.Add(tag);
            string name = "person";
            OrientWithVelocity = true;
            this.team = null;
            Score = 0.0f;
            AnimationState = new Dictionary<string,string>();
            IsSleeping = false;

            List<Point> offsets = new List<Point>();
            offsets.Add(new Point(0, 0));

            Point offset = offsets[RandomHelper.random.Next(0, offsets.Count)];

            List<Point> rightFrames = new List<Point>();
            rightFrames.Add(new Point(1 + offset.X, 0 + offset.Y));
            rightFrames.Add(new Point(2 + offset.X, 0 + offset.Y));
            rightFrames.Add(new Point(3 + offset.X, 0 + offset.Y));
            rightFrames.Add(new Point(4 + offset.X, 0 + offset.Y));

            Animation walkRight = new Animation(graphics, sprites, name + "_walk_right", 32, 32, rightFrames, true, Color.White, 10.0f, 0.8f, 1, true);

            List<Point> leftFrames = new List<Point>();
            leftFrames.Add(new Point(1 + offset.X, 0 + offset.Y));
            leftFrames.Add(new Point(2 + offset.X, 0 + offset.Y));
            leftFrames.Add(new Point(3 + offset.X, 0 + offset.Y));
            leftFrames.Add(new Point(4 + offset.X, 0 + offset.Y));

            Animation walkLeft = new Animation(graphics, sprites, name + "_walk_left", 32, 32, leftFrames, true, Color.White, 10.0f, 0.8f, 1, false);

            List<Point> rightFramesIdle = new List<Point>();
            rightFramesIdle.Add(new Point(0 + offset.X, 0 + offset.Y));

            Animation idleRight = new Animation(graphics, sprites, name + "_idle_right", 32, 32, rightFramesIdle, true, Color.White, 2.0f, 0.8f, 1, true);

            List<Point> leftFramesIdle = new List<Point>();
            leftFramesIdle.Add(new Point(0 + offset.X, 0 + offset.Y));

            Animation idleLeft = new Animation(graphics, sprites, name + "_idle_left", 32, 32, leftFramesIdle, true, Color.White, 2.0f, 0.8f, 1, false);

            walkLeft.Play();
            walkRight.Play();
            idleLeft.Play();
            idleRight.Play();

            Matrix spriteMatrix = Matrix.Identity;
            image = new OrientableBillboardSpriteComponent(componentManager, "idlesprite", this, spriteMatrix, sprites);
            OrientedAnimation idle = new OrientedAnimation(idleLeft, idleRight);
            image.AddOrientedAnimation(idle);
            AnimationState["idle"] = idle.Name;
            OrientedAnimation walk = new OrientedAnimation(walkLeft, walkRight);
            image.AddOrientedAnimation(walk);
            AnimationState["walk"] = walk.Name;

            Matrix shadowTransform = Matrix.CreateRotationX((float)Math.PI * 0.5f);
            //shadowTransform.Translation = new Vector3(0.0f, -0.31f, 0.0f);
            shadow = new ShadowComponent(componentManager, "shadow", this, shadowTransform, content.Load<Texture2D>("shadowcircle"));
            shadow.OrientsToCamera = false;
            List<Point> shP = new List<Point>();
            shP.Add(new Point(0, 0));
            Animation shadowAnimation = new Animation(graphics, content.Load<Texture2D>("shadowcircle"), "sh", 32, 32, shP, false, Color.White, 1, 0.7f, 0.7f, false);
            shadow.AddAnimation(shadowAnimation);
            shadowAnimation.Play();
            shadow.SetCurrentAnimation("sh");

            Matrix teamTransform = Matrix.CreateRotationX((float)Math.PI * 0.5f);
            //shadowTransform.Translation = new Vector3(0.0f, -0.31f, 0.0f);
            ShadowComponent team = new ShadowComponent(componentManager, "team", this, shadowTransform, content.Load<Texture2D>("circle"));
            team.OrientsToCamera = false;
            List<Point> circleP = new List<Point>();
            circleP.Add(new Point(0, 0));
            Animation circleAnimation = new Animation(graphics, content.Load<Texture2D>("circle"), "teamcircle", 32, 32, shP, false, Color.Red, 1, 0.9f, 0.9f, false);
            team.AddAnimation(circleAnimation);
            circleAnimation.Play();
            team.SetCurrentAnimation("teamcircle");
            teamCircle = team;

            Tags.Add("Walker");

            velocityController = new VelocityController(this);
            velocityController.IsTracking = true;
        }