Ejemplo n.º 1
0
        public override void Initialize()
        {
            MiniInit();

            for (int i = 0; i < vertices.Length; i++){
                VertexPositionNormalTexture vertex = vertices[i];

                vertex.Position.X = ((i > 1) ? (mapX + 1) * Tile.SIZE : mapX * Tile.SIZE);
                vertex.Position.Y = ((i % 2 != 0) ? (mapY + 1) * Tile.SIZE : mapY * Tile.SIZE);
                vertex.Position.Z = ((i % 2 != 0) ? (mapZ * Tile.HEIGHT) + HEIGHT : (mapZ) * Tile.HEIGHT);

                vertices[i] = vertex;
            }
            //config animations
            animations = new Dictionary<string, AdvancedAnimation>();
            for (int i = 0; i < 4; i++){
                AdvancedAnimation a = new AdvancedAnimation(texture, new Rectangle(0, i * (texture.Height / 4), texture.Width, texture.Height / 4), 4);
                a.frameTime = (i <= (int)Tile.Direction.SOUTH) ? 75 : 90;
                a.Start();
                animations[Enum.GetName(typeof(Tile.Direction), i)] = a;
            }
            animation = animations[dir.ToString()];

            animation.running = false;
            UpdateUVCoords();
        }
Ejemplo n.º 2
0
        public void Initialize()
        {
            MiniInit();
            position = new Vector3(0, -.5f, 3.75f);
            for (int i = 0; i < vertices.Length; i++){
                VertexPositionNormalTexture vertex = vertices[i];
                float s = 2f;
                vertex.Position.X = ((i > 1) ? (position.X + 1) * s * Tile.SIZE : (position.X) * s * Tile.SIZE);
                vertex.Position.Y = (i % 2 != 0) ? (position.Y + 1.75f) * s * Tile.SIZE : (position.Y) * s * Tile.SIZE;
                vertex.Position.Z = (i % 2 != 0) ? (position.Z) * s * HEIGHT : (position.Z) * s * HEIGHT;
                vertices[i] = vertex;
            }
            //config animations
            animations = new Dictionary<string, AdvancedAnimation>();
            animations["Idle"] = new AdvancedAnimation(texture, new Rectangle(0,0, 248, 35), 8);
            animations["Walking"] = new AdvancedAnimation(texture, new Rectangle(0, 35, 232, 34), 8);
            animations["Running"] = new AdvancedAnimation(texture, new Rectangle(0, 70, 192, 32), 6);
            animations["Walking"].frameTime = 70;
            animations["Walking"].Start();
            animation = animations["Idle"];

            animation.running = true;
            UpdateUVCoords();
        }