Exemplo n.º 1
0
 public Vertex(Vertex v)
 {
     position = v.position;
     normal = v.normal;
     direction = v.direction;
     velocity = v.velocity;
 }
Exemplo n.º 2
0
 public Vertex(Vertex v, Vector3 positionOffset)
 {
     position = v.position + positionOffset;
     normal = v.normal;
     direction = v.direction;
     velocity = v.velocity;
 }
Exemplo n.º 3
0
 public GunEmplacement(VL.TrackType trackType, VL.GunType gunType, Vector2 positionOffset, float radius, float depthOffset, BaseType baseType, Monster srcMonster)
 {
     this.gunType = gunType;
     this.trackType = trackType;
     this.positionOffset = positionOffset;
     this.radius = radius;
     this.baseRadius = .75f * radius;
     this.depthOffset = depthOffset;
     this.baseType = baseType;
     this.gunLine = srcMonster.position.direction;
     this.gunNormal = Vector3.Cross(gunLine, srcMonster.position.normal);
     this.position = srcMonster.position;
 }
Exemplo n.º 4
0
 public Projectile(Projectile p)
 {
     position = new Vertex(p.position);
     type = p.type;
     lifeTime = p.lifeTime;
     exploded = p.exploded;
     playerProjectile = p.playerProjectile;
     if(p.srcMonster != null)
         srcMonsterId = p.srcMonster.id;
     missileTarget = p.missileTarget;
     stopped = p.stopped;
     exploding = p.exploding;
     explodeTime = p.explodeTime;
     laserDepth = p.laserDepth;
 }
Exemplo n.º 5
0
 public GunEmplacement(GunEmplacement g)
 {
     trackType = g.trackType;
     currentAngle = g.currentAngle;
     fireCooldown = g.fireCooldown;
     //position = new Vertex(g.position);
     positionOffset = g.positionOffset;
     gunLine = g.gunLine;
     gunNormal = g.gunNormal;
     gunType = g.gunType;
     radius = g.radius;
     position = new Vertex();
     depthOffset = g.depthOffset;
     baseType = g.baseType;
     baseRadius = g.baseRadius;
 }
Exemplo n.º 6
0
        public Vertex Unfold(Room r, Vector3 n, Vector3 u)
        {
            Vector3 anchor = r.center + Math.Abs(Vector3.Dot(r.size / 2, n)) * n;
            Vertex v = new Vertex();

            if (normal == n)
            {
                v.normal = normal;
                v.position = position;
                v.velocity = velocity;
                v.direction = direction;
            }
            else if (Vector3.Dot(normal, n) == 0)
            {
                Vector3 badComponent = Vector3.Dot(n, position - anchor) * n;
                Vector3 badVelComponent = Vector3.Dot(n, velocity) * n;
                Vector3 badDirComponent = Vector3.Dot(n, direction) * n;
                float badVelLength = Vector3.Dot(n, velocity);
                float badDirLength = Vector3.Dot(n, direction);
                v.position = position - badComponent + badComponent.Length() * normal;
                v.velocity = velocity - badVelComponent - badVelLength * normal;
                v.direction = direction - badDirComponent - badDirLength * normal;
                v.normal = n;
            }
            else
            {
                Vector3 upAnchor = r.center + Math.Abs(Vector3.Dot(r.size / 2, u)) * u;
                Vector3 badComponent = Vector3.Dot(u, position - upAnchor) * u;
                Vector3 gapComponent = Vector3.Dot(r.size, n) * n;
                float badVelLength = Vector3.Dot(u, velocity);
                float badDirLength = Vector3.Dot(u, direction);
                v.position = position - 2 * badComponent + gapComponent.Length() * n + gapComponent.Length() * u;
                v.velocity = velocity - 2*badVelLength * u;
                v.direction = direction - 2*badDirLength * u;

                v.normal = n;
            }
            return v;
        }
Exemplo n.º 7
0
 public Doodad(Doodad d, Room r, Vector3 n, Vector3 u)
 {
     position = d.position.Unfold(r, n, u);
     type = d.type;
     toggleOn = d.toggleOn;
     targetDoodad = d.targetDoodad;
     active = d.active;
     srcDoodad = d;
     stateTransition = d.stateTransition;
 }
Exemplo n.º 8
0
        public void Upgate(int gameTime, Monster srcMonster)
        {
            position = new Vertex(srcMonster.position);
            position.velocity = positionOffset.X * srcMonster.rightUnit - positionOffset.Y * srcMonster.upUnit;
            position.Update(Engine.player.currentRoom, 1);
            position.velocity = srcMonster.position.velocity;

            if ((Engine.player.center.position - position.position).Length() < weaponRange)
                fireCooldown -= gameTime;
            if (fireCooldown < 0)
                fireCooldown = 0;

            float cosTheta = 0f;
            float sinTheta = 0f;
            if (angleRotateSpeed != 0)
            {
                Vector3 aimTarget = Engine.player.center.position - position.position;
                aimTarget.Normalize();
                cosTheta = Vector3.Dot(srcMonster.upUnit, aimTarget);
                sinTheta = Vector3.Dot(srcMonster.rightUnit, aimTarget);
                float targetAngle = 0;
                if (sinTheta > 0)
                    targetAngle = (float)Math.Acos(cosTheta);
                else
                    targetAngle = (float)(2 * Math.PI) - (float)Math.Acos(cosTheta);
                float posGap = targetAngle - currentAngle;
                if (posGap < 0)
                    posGap += (float)Math.PI * 2;
                if (posGap < .1f)
                {
                }
                else if (posGap < Math.PI) currentAngle += angleRotateSpeed;
                else if (posGap > Math.PI) currentAngle -= angleRotateSpeed;

                if (currentAngle > 2 * Math.PI)
                    currentAngle -= (float)Math.PI * 2;
                if (currentAngle < 0)
                    currentAngle += (float)Math.PI * 2;
                if (!(srcMonster.moveType == VL.MovementType.Hover || srcMonster.moveType == VL.MovementType.ArmorBoss || srcMonster.moveType == VL.MovementType.RockBoss || srcMonster.moveType == VL.MovementType.SnakeBoss || srcMonster.moveType == VL.MovementType.BattleBoss))
                {
                    if (currentAngle > Math.PI / 2 && currentAngle < Math.PI)
                        currentAngle = (float)(Math.PI / 2 - .05f);
                    if (currentAngle > Math.PI && currentAngle < 3 * Math.PI / 2)
                        currentAngle = (float)(3 * Math.PI / 2 + .05f);
                }
            }
            else if (trackType == VL.TrackType.Up)
            {
                currentAngle = 0f;
            }
            else if (trackType == VL.TrackType.UpLeft)
            {
                currentAngle = (float)(7 * Math.PI / 4);
            }
            else if (trackType == VL.TrackType.UpRight)
            {
                currentAngle = (float)(Math.PI / 4);
            }
            else if (trackType == VL.TrackType.Left)
            {
                currentAngle = (float)(3 * Math.PI / 2);
            }
            else if (trackType == VL.TrackType.Right)
            {
                currentAngle = (float)(Math.PI / 2);
            }

            cosTheta = (float)Math.Cos(currentAngle);
            sinTheta = (float)Math.Sin(currentAngle);
            gunLine = srcMonster.right * sinTheta + srcMonster.up * cosTheta;
            gunNormal = Vector3.Cross(gunLine, position.normal);
            gunLine.Normalize();
            gunNormal.Normalize();

            if (srcMonster.moveType == VL.MovementType.RockBoss && (srcMonster.rockBoss.state == RockBossState.Snow_Flee1))
                return;

            if (fireCooldown == 0)
            {
                Vector3 projectileVelocity = gunLine;
                projectileVelocity.Normalize();

                fireCooldown = fireTime;
                if (srcMonster != null)
                {
                    fireCooldown += (ArmorBoss.r.Next(fireCooldown / 5) - fireCooldown / 10);
                }
                if (gunType == VL.GunType.Blaster || gunType == VL.GunType.Repeater)
                {
                    SoundFX.FireBlaster(position.position);
                    Engine.player.currentRoom.projectiles.Add(new Projectile(srcMonster, ProjectileType.Plasma, position.position + radius * gunLine, Vector3.Zero, position.normal, projectileVelocity));
                    if (gunType == VL.GunType.Repeater)
                    {
                        repeaterCount++;
                        repeaterCount %= 4;
                    }
                }
                if (gunType == VL.GunType.Beam)
                {
                    SoundFX.FireLaser(position.position);
                    Engine.player.currentRoom.projectiles.Add(new Projectile(srcMonster, ProjectileType.Laser, position.position + radius * gunLine, Vector3.Zero, position.normal, projectileVelocity));
                }
                if (gunType == VL.GunType.Missile)
                {
                    SoundFX.FireMissile(position.position);
                    Engine.player.currentRoom.projectiles.Add(new Projectile(srcMonster, ProjectileType.Missile, position.position + radius * gunLine, position.velocity, position.normal, projectileVelocity));
                }
                if (gunType == VL.GunType.Spread)
                {
                    SoundFX.FireBlaster(position.position);
                    SoundFX.FireBlaster(position.position);
                    SoundFX.FireBlaster(position.position);
                    Engine.player.currentRoom.projectiles.Add(new Projectile(srcMonster, ProjectileType.Plasma, position.position + radius * gunLine, Vector3.Zero, position.normal, projectileVelocity + .5f * gunNormal));
                    Engine.player.currentRoom.projectiles.Add(new Projectile(srcMonster, ProjectileType.Plasma, position.position + radius * gunLine, Vector3.Zero, position.normal, projectileVelocity - .5f * gunNormal));
                    Engine.player.currentRoom.projectiles.Add(new Projectile(srcMonster, ProjectileType.Plasma, position.position + radius * gunLine, Vector3.Zero, position.normal, projectileVelocity));
                }

            }
        }
Exemplo n.º 9
0
        public void AddSingleBlockSideToTriangleList(Vertex v1, Vertex v2, Color c, float depth, List<Vector2> texCoords, List<VertexPositionColorNormalTexture> triangleList)
        {
            Color shadedColor = Color.Blue;
            Color shadedColorBack = Color.Blue;
            if (v1.normal != v2.normal)
            {
                // corner edge case
                Vector3 fullEdge = v2.position - v1.position;
                Vector3 currentComponent = Vector3.Dot(v2.normal, fullEdge) * v2.normal;
                Vector3 nextComponent = Vector3.Dot(v1.normal, fullEdge) * v1.normal;
                Vector3 constantComponent = Vector3.Dot(Vector3.Cross(v2.normal, v1.normal), fullEdge) * Vector3.Cross(v2.normal, v1.normal);
                float currentPercent = currentComponent.Length() / (currentComponent.Length() + nextComponent.Length());

                Vector3 midPoint = v1.position + currentComponent + currentPercent * constantComponent;

                Vector3 edgeNormal = Vector3.Cross(midPoint - v1.position, v1.normal);
                edgeNormal.Normalize();
                shadedColor = FakeShader.Shade(c, edgeNormal);

                triangleList.Add(GenerateTexturedVertex(v1.position, texCoords[1], shadedColor, edgeNormal, depth));
                triangleList.Add(GenerateTexturedVertex(v1.position, texCoords[2], shadedColor, edgeNormal, -depth));
                triangleList.Add(GenerateTexturedVertex(midPoint, texCoords[0], shadedColor, edgeNormal, depth));

                triangleList.Add(GenerateTexturedVertex(midPoint, texCoords[0], shadedColor, edgeNormal, depth));
                triangleList.Add(GenerateTexturedVertex(v1.position, texCoords[2], shadedColor, edgeNormal, -depth));
                triangleList.Add(GenerateTexturedVertex(midPoint, texCoords[3], shadedColor, edgeNormal, -depth));

                triangleList.Add(GenerateTexturedVertex(midPoint, texCoords[1], shadedColor, edgeNormal, depth));
                triangleList.Add(GenerateTexturedVertex(midPoint, texCoords[2], shadedColor, edgeNormal, -depth));
                triangleList.Add(GenerateTexturedVertex(v2.position, texCoords[0], shadedColor, edgeNormal, depth));

                triangleList.Add(GenerateTexturedVertex(v2.position, texCoords[0], shadedColor, edgeNormal, depth));
                triangleList.Add(GenerateTexturedVertex(midPoint, texCoords[2], shadedColor, edgeNormal, -depth));
                triangleList.Add(GenerateTexturedVertex(v2.position, texCoords[3], shadedColor, edgeNormal, -depth));
            }
            else
            {

                Vector3 edgeNormal = Vector3.Cross(v2.position - v1.position, v1.normal);
                edgeNormal.Normalize();
                shadedColor = FakeShader.Shade(c, edgeNormal);
                // straight edge case
                triangleList.Add(GenerateTexturedVertex(v1.position, texCoords[1], shadedColor, edgeNormal, depth));
                triangleList.Add(GenerateTexturedVertex(v1.position, texCoords[2], shadedColor, edgeNormal, -depth));
                triangleList.Add(GenerateTexturedVertex(v2.position, texCoords[0], shadedColor, edgeNormal, depth));

                triangleList.Add(GenerateTexturedVertex(v2.position, texCoords[0], shadedColor, edgeNormal, depth));
                triangleList.Add(GenerateTexturedVertex(v1.position, texCoords[2], shadedColor, edgeNormal, -depth));
                triangleList.Add(GenerateTexturedVertex(v2.position, texCoords[3], shadedColor, edgeNormal, -depth));
            }
        }
Exemplo n.º 10
0
        public void DrawMapDecal(Vector3 cameraUp, Vector3 cameraRight, Texture2D decalTexture, Vertex v, bool objective, float decalSize, Color color)
        {
            float iconDistance = 3f;
            float iconSize = decalSize;
            if (objective == true)
            {
                iconDistance = 5f;
                iconSize = 3f + ObjectiveControl.oscillate * 3f / ObjectiveControl.maxOscillate;
            }
            if (WorldMap.state == ZoomState.Objectives || WorldMap.state == ZoomState.World || WorldMap.state == ZoomState.ZoomFromWorld || WorldMap.state == ZoomState.ZoomToWorld)
            {
                iconDistance *= 1f * (3 * WorldMap.worldZoomLevel);
                iconSize *= 1f + (2 * WorldMap.worldZoomLevel);
            }
            Vector3 offset = Vector3.Zero;

            Vector3 lowerLeft = v.position + iconSize * -cameraRight + iconSize * -cameraUp + v.normal * iconDistance;
            Vector3 lowerRight = v.position + iconSize * cameraRight + iconSize * -cameraUp + v.normal * iconDistance;
            Vector3 upperLeft = v.position + iconSize * -cameraRight + iconSize * cameraUp + v.normal * iconDistance;
            Vector3 upperRight = v.position + iconSize * cameraRight + iconSize * cameraUp + v.normal * iconDistance;

            VertexPositionColorNormalTexture[] mapDecalList = new VertexPositionColorNormalTexture[6];

            mapDecalList[0] = (new VertexPositionColorNormalTexture(lowerLeft, color, v.normal, Room.plateTexCoords[2]));
            mapDecalList[1] = (new VertexPositionColorNormalTexture(lowerRight, color, v.normal, Room.plateTexCoords[3]));
            mapDecalList[2] = (new VertexPositionColorNormalTexture(upperLeft, color, v.normal, Room.plateTexCoords[1]));

            mapDecalList[3] = (new VertexPositionColorNormalTexture(lowerRight, color, v.normal, Room.plateTexCoords[3]));
            mapDecalList[4] = (new VertexPositionColorNormalTexture(upperLeft, color, v.normal, Room.plateTexCoords[1]));
            mapDecalList[5] = (new VertexPositionColorNormalTexture(upperRight, color, v.normal, Room.plateTexCoords[0]));

            Engine.playerTextureEffect.Texture = decalTexture;
            Engine.playerTextureEffect.CurrentTechnique.Passes[0].Apply();
            Game1.graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList,
                mapDecalList, 0, mapDecalList.Count() / 3, VertexPositionColorNormalTexture.VertexDeclaration);
        }
Exemplo n.º 11
0
        public Doodad(Doodad d)
        {
            srcDoodad = this;
            style = d.style;
            //unfoldedPosition = new Vertex(d.unfoldedPosition);
            position = new Vertex(d.position);
            spawnPosition = new Vertex(d.spawnPosition);
            active = d.active;

            available = d.available;
            id = d.id;
            idle = d.idle;
            targetBehavior = d.targetBehavior;
            targetObject = d.targetObject;
            expectedBehavior = d.expectedBehavior;
            alreadyUsed = d.alreadyUsed;
            type = d.type;
            behaviors = d.behaviors;
            currentBehaviorId = d.currentBehaviorId;
            if(d.currentBehavior != null)
                currentBehaviorId = d.currentBehavior.id;
            orbsRemaining = d.orbsRemaining;
            doorDecal = d.doorDecal;
            currentTime = d.currentTime;
            nextBehavior = d.nextBehavior;
            breakTime = d.breakTime;
            behaviorStarted = d.behaviorStarted;
            toggleOn = d.toggleOn;
            abilityType = d.abilityType;
            originalAbilityType = d.originalAbilityType;
            cooldown = d.cooldown;
            activationCost = d.activationCost;
            speaker = d.speaker;
            targetDoodadId = d.targetDoodadId;
            if(d.targetDoodad != null)
                targetDoodadId = d.targetDoodad.id;
            targetBlockId = d.targetBlockId;
            if (d.targetBlock != null)
                targetBlockId = d.targetBlock.id;
            targetEdgeId = d.targetEdgeId;
            if (d.targetEdge != null)
                targetEdgeId = d.targetEdge.id;

            targetRoomId = d.targetRoomId;
            if(d.targetRoom != null)
                targetRoomId = d.targetRoom.id;
            stateTransition = d.stateTransition;
            stateTransitionDir = d.stateTransitionDir;
            stateTransitionVelocity = d.stateTransitionVelocity;
            _powered = d._powered;
            behaviors = new List<Behavior>();
            foreach (Behavior b in d.behaviors)
            {
                behaviors.Add(new Behavior(b));
            }
        }
Exemplo n.º 12
0
 public Ed(Edge e)
 {
     cbi = e.currentBehaviorId;
     ct = e.currentTime;
     bs = e.behaviorStarted;
     vs = new Vertex(e.start);
     ve = new Vertex(e.end);
     pv = e.properties.primaryValue;
     sv = e.properties.secondaryValue;
     to = e.toggleOn;
     nb = e.nextBehavior;
 }
Exemplo n.º 13
0
 public Projectile(Monster srcMonster, ProjectileType type, Vector3 position, Vector3 velocity, Vector3 normal, Vector3 direction)
 {
     this.srcMonster = srcMonster;
     if (srcMonster == null)
         playerProjectile = true;
     this.type = type;
     this.position = new Vertex(position - Engine.player.platformVelocity, normal, Vector3.Zero, direction);
     Vector3 extraVelocity = direction;
     extraVelocity.Normalize();
     this.position.velocity += extraVelocity * this.initVelocity;
     this.position.velocity += Vector3.Dot(velocity, direction) * direction;
     this.position.velocity += Engine.player.platformVelocity;
     this.referenceFrameSpeed = this.position.velocity.Length();
     this.laserDepth = -5f;
 }
Exemplo n.º 14
0
 public Projectile(Projectile p, Room r, Vector3 n, Vector3 u)
 {
     position = p.position.Unfold(r,n,u);
     referenceFrameSpeed = p.referenceFrameSpeed;
     srcProjectile = p;
     type = p.type;
 }
Exemplo n.º 15
0
        public void AddStripToTriangleListHelper(Vertex start, Vertex end, float depth, EdgeProperties properties, List<VertexPositionColorNormalTexture> triangleList)
        {
            Vector3 edgeDir = end.position - start.position;
            Vector3 edgeNormal = Vector3.Cross(end.position - start.position, start.normal);
            edgeNormal.Normalize();
            edgeDir.Normalize();
            Color baseColor = Color.White;
            if(properties.type == VL.EdgeType.Ice)
                baseColor = Color.White;
            if (properties.type == VL.EdgeType.Magnet)
                baseColor = Color.Gray;
            if (properties.type == VL.EdgeType.Bounce)
                baseColor = Color.Magenta;
            if (properties.type == VL.EdgeType.Electric)
            {
                if (properties.primaryValue == 0)
                    baseColor = new Color(40, 40, 40);
                else
                    baseColor = Color.Yellow;
            }
            if (properties.type == VL.EdgeType.ConveyorBelt)
                baseColor = Color.DarkGray;

            if (properties.type != VL.EdgeType.Spikes)
            {
                float epsilon = .01f;

                //side
                triangleList.Add(GenerateTexturedVertex(start.position + epsilon * edgeNormal, blankTexCoords[1], baseColor, start.normal, depth + epsilon));
                triangleList.Add(GenerateTexturedVertex(start.position - .5f * edgeNormal, blankTexCoords[1], baseColor, start.normal, depth + epsilon));
                triangleList.Add(GenerateTexturedVertex(end.position + epsilon * edgeNormal, blankTexCoords[1], baseColor, start.normal, depth + epsilon));

                triangleList.Add(GenerateTexturedVertex(end.position + epsilon * edgeNormal, blankTexCoords[1], baseColor, start.normal, depth + epsilon));
                triangleList.Add(GenerateTexturedVertex(start.position - .5f * edgeNormal, blankTexCoords[1], baseColor, start.normal, depth + epsilon));
                triangleList.Add(GenerateTexturedVertex(end.position - .5f * edgeNormal, blankTexCoords[1], baseColor, start.normal, depth + epsilon));

                //top
                triangleList.Add(GenerateTexturedVertex(start.position + epsilon * edgeNormal, blankTexCoords[1], baseColor, edgeNormal, depth + epsilon));
                triangleList.Add(GenerateTexturedVertex(start.position + epsilon * edgeNormal, blankTexCoords[1], baseColor, edgeNormal, -depth));
                triangleList.Add(GenerateTexturedVertex(end.position + epsilon * edgeNormal, blankTexCoords[1], baseColor, edgeNormal, depth + epsilon));

                triangleList.Add(GenerateTexturedVertex(end.position + epsilon * edgeNormal, blankTexCoords[1], baseColor, edgeNormal, -depth));
                triangleList.Add(GenerateTexturedVertex(start.position + epsilon * edgeNormal, blankTexCoords[1], baseColor, edgeNormal, -depth));
                triangleList.Add(GenerateTexturedVertex(end.position + epsilon * edgeNormal, blankTexCoords[1], baseColor, edgeNormal, depth + epsilon));
            }
            if (properties.type == VL.EdgeType.Spikes)
            {
                int numSpikes = 2 * (int)(end.position - start.position).Length();
                float spikeHeight = .75f;
                float spikeWidth = (end.position - start.position).Length() / numSpikes;
                Color spikeColor = new Color(180, 180, 180);
                for (int i = 0; i < numSpikes; i++)
                {
                    Vector3 spikeStart = start.position + i * spikeWidth * edgeDir;
                    Vector3 spikeEnd = start.position + (i + 1) * spikeWidth * edgeDir;
                    Vector3 spikePoint = .5f * (spikeStart + spikeEnd) + spikeHeight * edgeNormal;

                    Color shadedColor = Color.Blue;

                    shadedColor = FakeShader.Shade(spikeColor, start.normal);
                    triangleList.Add(GenerateTexturedVertex(spikeStart, blankTexCoords[1], shadedColor, start.normal, depth));
                    triangleList.Add(GenerateTexturedVertex(spikeEnd, blankTexCoords[1], shadedColor, start.normal, depth));
                    triangleList.Add(GenerateTexturedVertex(spikePoint, blankTexCoords[1], shadedColor, edgeNormal, depth / 2));

                    shadedColor = FakeShader.Shade(spikeColor, -start.normal);
                    triangleList.Add(GenerateTexturedVertex(spikeStart, blankTexCoords[1], shadedColor, -start.normal, 0));
                    triangleList.Add(GenerateTexturedVertex(spikeEnd, blankTexCoords[1], shadedColor, -start.normal, 0));
                    triangleList.Add(GenerateTexturedVertex(spikePoint, blankTexCoords[1], shadedColor, edgeNormal, depth / 2));

                    shadedColor = FakeShader.Shade(spikeColor, edgeDir);
                    triangleList.Add(GenerateTexturedVertex(spikeStart, blankTexCoords[1], shadedColor, edgeDir, depth));
                    triangleList.Add(GenerateTexturedVertex(spikeStart, blankTexCoords[1], shadedColor, edgeDir, 0));
                    triangleList.Add(GenerateTexturedVertex(spikePoint, blankTexCoords[1], shadedColor, edgeNormal, depth / 2));

                    shadedColor = FakeShader.Shade(spikeColor, -edgeDir);
                    triangleList.Add(GenerateTexturedVertex(spikeEnd, blankTexCoords[1], shadedColor, -edgeDir, depth));
                    triangleList.Add(GenerateTexturedVertex(spikeEnd, blankTexCoords[1], shadedColor, -edgeDir, 0));
                    triangleList.Add(GenerateTexturedVertex(spikePoint, blankTexCoords[1], shadedColor, edgeNormal, depth / 2));
                }

            }
            if (properties.type == VL.EdgeType.ConveyorBelt)
            {
                int numSegments = (int)(end.position - start.position).Length();
                float segmentWidth = (end.position - start.position).Length() / numSegments;
                float arrowWidth = 0;
                if (properties.primaryValue > 0)
                    arrowWidth = -.5f;
                if (properties.primaryValue < 0)
                    arrowWidth = .5f;

                for (int i = 1; i < numSegments; i++)
                {
                    triangleList.Add(GenerateTexturedVertex(start.position + i * segmentWidth * edgeDir,blankTexCoords[1], Color.Yellow, start.normal, depth + .002f));
                    triangleList.Add(GenerateTexturedVertex(start.position + i * segmentWidth * edgeDir - .5f * edgeNormal,blankTexCoords[1], Color.Yellow, start.normal, depth + .002f));
                    triangleList.Add(GenerateTexturedVertex(start.position + arrowWidth * edgeDir + i * segmentWidth * edgeDir - .25f * edgeNormal,blankTexCoords[1], Color.Yellow, start.normal, depth + .002f));
                }
            }
        }
Exemplo n.º 16
0
        public Doodad(VL.Doodad xmlDoodad, Vector3 normal)
        {
            srcDoodad = this;
            this.type = xmlDoodad.type;
            this.id = xmlDoodad.IDString;
            this.targetBehavior = xmlDoodad.targetBehavior;
            this.targetObject = xmlDoodad.targetObject;
            this.expectedBehavior = xmlDoodad.expectBehavior;
            this.activationCost = xmlDoodad.activationCost;

            this.abilityType = (AbilityType)xmlDoodad.ability;
            this.originalAbilityType = (AbilityType)xmlDoodad.ability;
            this.position = new Vertex(xmlDoodad.position, normal, Vector3.Zero, xmlDoodad.up);
            this.spawnPosition = new Vertex(xmlDoodad.position, normal, Vector3.Zero, xmlDoodad.up);
            behaviors = new List<Behavior>();
            currentBehavior = null;

            if (isOrb)
                active = true;
            if (type == VL.DoodadType.BluePowerStation)
                orbsRemaining = 1;
            if (type == VL.DoodadType.RedPowerStation)
                orbsRemaining = 1;

            if (type == VL.DoodadType.WallSwitch)
                stateTransition = 0;
            if (isStation)
                stateTransition = 0;
        }
Exemplo n.º 17
0
        public void AddTopStrip(Vertex start, Vertex end, float depth, float epsilon, bool flip, List<Vector2> texCoords, List<VertexPositionColorNormalTexture> triangleList)
        {
            Color baseColor = Color.White;

            if (start.normal == end.normal)
            {
                Vector3 edgeDir = end.position - start.position;
                Vector3 edgeNormal = Vector3.Cross(edgeDir, start.normal);
                edgeNormal.Normalize();
                edgeDir.Normalize();
                if(flip == true)
                    edgeNormal *= -1;

                triangleList.Add(GenerateTexturedVertex(start.position + epsilon * edgeNormal, texCoords[2], baseColor, edgeNormal, depth + epsilon));
                triangleList.Add(GenerateTexturedVertex(start.position + epsilon * edgeNormal, texCoords[1], baseColor, edgeNormal, -depth));
                triangleList.Add(GenerateTexturedVertex(end.position + epsilon * edgeNormal, texCoords[3], baseColor, edgeNormal, depth + epsilon));

                triangleList.Add(GenerateTexturedVertex(end.position + epsilon * edgeNormal, texCoords[0], baseColor, edgeNormal, -depth));
                triangleList.Add(GenerateTexturedVertex(start.position + epsilon * edgeNormal, texCoords[1], baseColor, edgeNormal, -depth));
                triangleList.Add(GenerateTexturedVertex(end.position + epsilon * edgeNormal, texCoords[3], baseColor, edgeNormal, depth + epsilon));
            }
            else
            {
                Vector3 fullEdge = end.position - start.position;
                Vector3 currentComponent = Vector3.Dot(end.normal, fullEdge) * end.normal;
                Vector3 nextComponent = Vector3.Dot(start.normal, fullEdge) * start.normal;
                Vector3 constantComponent = Vector3.Dot(Vector3.Cross(end.normal, start.normal), fullEdge) * Vector3.Cross(end.normal, start.normal);
                float currentPercent = currentComponent.Length() / (currentComponent.Length() + nextComponent.Length());

                Vector3 midPoint = start.position + currentComponent + currentPercent * constantComponent;

                Vector3 edgeDir = midPoint - start.position;
                Vector3 edgeNormal = Vector3.Cross(midPoint - start.position, start.normal);
                edgeNormal.Normalize();
                edgeDir.Normalize();
                if (flip == true)
                    edgeNormal *= -1;

                Vector2 midA = currentPercent * texCoords[3] + (1f-currentPercent) * texCoords[2];
                Vector2 midB = currentPercent * texCoords[0] + (1f-currentPercent) * texCoords[1];

                triangleList.Add(GenerateTexturedVertex(start.position + epsilon * edgeNormal, texCoords[2], baseColor, edgeNormal, depth + epsilon));
                triangleList.Add(GenerateTexturedVertex(start.position + epsilon * edgeNormal, texCoords[1], baseColor, edgeNormal, -depth));
                triangleList.Add(GenerateTexturedVertex(midPoint + epsilon * edgeNormal, midA, baseColor, edgeNormal, depth + epsilon));

                triangleList.Add(GenerateTexturedVertex(midPoint + epsilon * edgeNormal, midB, baseColor, edgeNormal, -depth));
                triangleList.Add(GenerateTexturedVertex(start.position + epsilon * edgeNormal, texCoords[1], baseColor, edgeNormal, -depth));
                triangleList.Add(GenerateTexturedVertex(midPoint + epsilon * edgeNormal, midA, baseColor, edgeNormal, depth + epsilon));

                edgeDir = end.position - midPoint;
                edgeNormal = Vector3.Cross(end.position - midPoint, end.normal);
                edgeNormal.Normalize();
                edgeDir.Normalize();
                if (flip == true)
                    edgeNormal *= -1;

                triangleList.Add(GenerateTexturedVertex(midPoint + epsilon * edgeNormal, midA, baseColor, edgeNormal, depth + epsilon));
                triangleList.Add(GenerateTexturedVertex(midPoint + epsilon * edgeNormal, midB, baseColor, edgeNormal, -depth));
                triangleList.Add(GenerateTexturedVertex(end.position + epsilon * edgeNormal, texCoords[3], baseColor, edgeNormal, depth + epsilon));

                triangleList.Add(GenerateTexturedVertex(end.position + epsilon * edgeNormal, texCoords[0], baseColor, edgeNormal, -depth));
                triangleList.Add(GenerateTexturedVertex(midPoint + epsilon * edgeNormal, midB, baseColor, edgeNormal, -depth));
                triangleList.Add(GenerateTexturedVertex(end.position + epsilon * edgeNormal, texCoords[3], baseColor, edgeNormal, depth + epsilon));

            }
        }
Exemplo n.º 18
0
 public void UpdateUnfoldedDoodad(Room r, Vector3 n, Vector3 u)
 {
     unfoldedPosition = position.Unfold(r, n, u);
 }
Exemplo n.º 19
0
        public void AddBlockSidesToTriangleList(List<Vertex> vList, Color c, float depth, List<Vector2> texCoords, List<VertexPositionColorNormalTexture> triangleList)
        {
            for (int i = 0; i < 4; i++)
            {
                Vertex vs = vList[i];
                Vertex ve = vList[(i + 1) % 4];

                if (vs.normal != ve.normal)
                {
                    Vertex vCorner1 = new Vertex(vs.position + Vector3.Dot(vs.direction, ve.position - vs.position) * vs.direction, vs.normal, vs.velocity, vs.direction);
                    Vertex vCorner2 = new Vertex(vCorner1.position, ve.normal, ve.velocity, ve.direction);

                    float halfLength1 = (vCorner1.position - vs.position).Length();
                    if (halfLength1 < 1.5f)
                    {
                        AddSingleBlockSideToTriangleList(vs, vCorner1, c, depth, startTexCoords, triangleList);
                    }
                    else
                    {
                        Vertex v2 = new Vertex((1.5f * vs.position + (halfLength1 - 1.5f) * vCorner1.position) / halfLength1, vs.normal, Vector3.Zero, vs.direction);
                        AddSingleBlockSideToTriangleList(vs, v2, c, depth, startTexCoords, triangleList);
                        AddSingleBlockSideToTriangleList(v2, vCorner1, c, depth, midTexCoords, triangleList);
                    }

                    float halfLength2 = (ve.position - vCorner2.position).Length();
                    if (halfLength2 < 1.5f)
                    {
                        AddSingleBlockSideToTriangleList(vCorner2, ve, c, depth, endTexCoords, triangleList);
                    }
                    else
                    {
                        Vertex v2 = new Vertex((1.5f * vCorner2.position + (halfLength2 - 1.5f) * ve.position) / halfLength2, vs.normal, Vector3.Zero, vs.direction);
                        AddSingleBlockSideToTriangleList(vCorner2, v2, c, depth, midTexCoords, triangleList);
                        AddSingleBlockSideToTriangleList(v2, ve, c, depth, endTexCoords, triangleList);

                    }

                }
                else if (vs.normal == ve.normal)
                {
                    float fullLength = (vs.position - ve.position).Length();
                    if (fullLength < 3)
                        AddSingleBlockSideToTriangleList(vs, ve, c, depth, texCoords, triangleList);
                    else
                    {
                        Vertex v3 = new Vertex((1.5f * vs.position + (fullLength - 1.5f) * ve.position) / fullLength, vs.normal, Vector3.Zero, vs.direction);
                        Vertex v2 = new Vertex(((fullLength - 1.5f) * vs.position + 1.5f * ve.position) / fullLength, vs.normal, Vector3.Zero, vs.direction);
                        AddSingleBlockSideToTriangleList(vs, v2, c, depth, startTexCoords, triangleList);
                        AddSingleBlockSideToTriangleList(v2, v3, c, depth, midTexCoords, triangleList);
                        AddSingleBlockSideToTriangleList(v3, ve, c, depth, endTexCoords, triangleList);
                    }
                }
            }
        }
Exemplo n.º 20
0
        public Doodad(VL.DoodadType type, Vector3 position, Vector3 normal, Vector3 direction)
        {
            id = "d_"+type.ToString();
            srcDoodad = this;
            this.type = type;
            this.position = new Vertex(position, normal, Vector3.Zero, direction);
            this.spawnPosition = new Vertex(position, normal, Vector3.Zero, direction);
            behaviors = new List<Behavior>();
            currentBehavior = null;
            if (type == VL.DoodadType.LeftDoor || type == VL.DoodadType.RightDoor)
                stateTransition = 0;

            if (isOrb)
                active = true;
        }
Exemplo n.º 21
0
        public void AddStripToTriangleList2(Edge e, float depth, List<VertexPositionColorNormalTexture> triangleList)
        {
            float edgeLength = (e.end.position - e.start.position).Length();

            if (e.start.normal != e.end.normal)
            {
                Vector3 fullEdge = e.end.position - e.start.position;
                Vector3 currentComponent = Vector3.Dot(e.end.normal, fullEdge) * e.end.normal;
                Vector3 nextComponent = Vector3.Dot(e.start.normal, fullEdge) * e.start.normal;
                Vector3 constantComponent = Vector3.Dot(Vector3.Cross(e.end.normal, e.start.normal), fullEdge) * Vector3.Cross(e.end.normal, e.start.normal);
                float currentPercent = currentComponent.Length() / (currentComponent.Length() + nextComponent.Length());
                Vector3 midPoint = e.start.position + currentComponent + currentPercent * constantComponent;
                edgeLength = (e.end.position - midPoint).Length() + (e.start.position - midPoint).Length();
            }

            int width = (int)(edgeLength+.5f);
            float blockWidth = edgeLength / width;

            List<Vertex> fullPointList = new List<Vertex>();
            for (int i = 0; i < width+1; i++)
            {
                Vector3 up = Vector3.Cross(e.start.normal, e.start.direction);
                fullPointList.Add(new Vertex(e.start, e.start.direction * i + up));
                fullPointList.Add(new Vertex(e.start, e.start.direction * i));
            }
            for (int i = 0; i < (width+1) * 2; i++)
            {
                fullPointList[i].Update(this, 0);
            }

            for (int i = 0; i < width; i++)
            {
                List<Vertex> subList = new List<Vertex>();
                List<Vertex> mirrorSubList = new List<Vertex>();
                Vector3 up = Vector3.Cross(fullPointList[(i * 2)].direction, fullPointList[i * 2].normal);

                mirrorSubList.Add(new Vertex(fullPointList[(i) * 2 + 1], .01f * up));
                mirrorSubList.Add(new Vertex(fullPointList[(i + 1) * 2 + 1], .01f * up));
                mirrorSubList.Add(fullPointList[(i + 1) * 2]);
                mirrorSubList.Add(fullPointList[i * 2]);

                subList.Add(new Vertex(fullPointList[(i+1) * 2 + 1], .01f*up));
                subList.Add(new Vertex(fullPointList[(i) * 2 + 1], .01f*up));
                subList.Add(fullPointList[(i) * 2]);
                subList.Add(fullPointList[(i+1) * 2]);
                /*foreach (Vertex v in mirrorSubList)
                    v.Update(this, 0);
                foreach (Vertex v in subList)
                    v.Update(this, 0);*/

                if (e.properties.type == VL.EdgeType.Ice)
                {
                    #region ice
                    if (i == width - 1)
                    {
                        AddBlockFrontToTriangleList(mirrorSubList, Color.White, depth + .01f, edgeSideEndTexCoords, triangleList, true);
                        AddTopStrip(fullPointList[(i + 1) * 2 + 1], fullPointList[i * 2 + 1], depth + .01f, .01f, true, edgeTopEndTexCoords, triangleList);
                    }
                    else if (i == 0)
                    {
                        AddBlockFrontToTriangleList(subList, Color.White, depth + .01f, edgeSideEndTexCoords, triangleList, true);
                        AddTopStrip(fullPointList[i * 2 + 1], fullPointList[(i + 1) * 2 + 1], depth + .01f, .01f, false, edgeTopEndTexCoords, triangleList);
                    }
                    else
                    {
                        AddBlockFrontToTriangleList(subList, Color.White, depth + .01f, edgeSideTexCoords, triangleList, true);
                        AddTopStrip(fullPointList[i * 2 + 1], fullPointList[(i + 1) * 2 + 1], depth + .01f, .01f, false, edgeTopTexCoords, triangleList);
                    }
                    #endregion
                }
                else if (e.properties.type == VL.EdgeType.Bounce)
                {
                    #region bounce
                    float treadRise = .1f;
                    float treadFraction = .75f;
                    if (i == width - 1)
                    {
                        Vertex v1t = new Vertex(fullPointList[i * 2 + 1], treadRise * up);
                        Vertex v3t = fullPointList[(i + 1) * 2 + 1];
                        Vertex v2t = new Vertex(fullPointList[i * 2 + 1], treadRise * up + treadFraction * (fullPointList[(i + 1) * 2 + 1].position - fullPointList[i * 2 + 1].position));
                        v1t.Update(this, 0);
                        v2t.Update(this, 0);
                        v3t.Update(this, 0);

                        List<Vertex> subListA = new List<Vertex>();
                        subListA.Add(new Vertex(subList[0], Vector3.Zero)); // Left
                        subListA.Add(new Vertex(subList[1], treadRise * up + treadFraction * (fullPointList[(i + 1) * 2 + 1].position - fullPointList[i * 2 + 1].position)));
                        subListA.Add(new Vertex(subList[2], treadFraction * (fullPointList[(i + 1) * 2 + 1].position - fullPointList[i * 2 + 1].position)));
                        subListA.Add(new Vertex(subList[3], Vector3.Zero)); // Left
                        foreach (Vertex v in subListA)
                            v.Update(this, 0);
                        List<Vertex> subListB = new List<Vertex>();
                        subListB.Add(new Vertex(subList[1], treadRise * up + treadFraction * (fullPointList[(i + 1) * 2 + 1].position - fullPointList[i * 2 + 1].position)));
                        subListB.Add(new Vertex(subList[1], treadRise * up));
                        subListB.Add(new Vertex(subList[2], Vector3.Zero));
                        subListB.Add(new Vertex(subList[2], treadFraction * (fullPointList[(i + 1) * 2 + 1].position - fullPointList[i * 2 + 1].position)));
                        foreach (Vertex v in subListB)
                            v.Update(this, 0);

                        AddTopStrip(v1t, v2t, depth + .011f, .00f, false, edgeTopTexCoords, triangleList);
                        AddTopStrip(v2t, v3t, depth + .011f, .00f, false, edgeTopTexCoords, triangleList);

                        AddBlockFrontToTriangleList(mirrorSubList, Color.White, depth + .01f, edgeSideEndTexCoords, triangleList, true);
                        AddBlockFrontToTriangleList(subListA, Color.White, depth + .011f, rubberSideSmallTexCoords, triangleList, true);
                        AddBlockFrontToTriangleList(subListB, Color.White, depth + .011f, rubberSideSmallTexCoords, triangleList, true);
                    }
                    else if (i == 0)
                    {
                        Vertex v1 = fullPointList[i * 2 + 1];
                        Vertex v3 = new Vertex(fullPointList[(i + 1) * 2 + 1], treadRise * up);
                        Vertex v2 = new Vertex(fullPointList[i * 2 + 1], treadRise * up + (1 - treadFraction) * (fullPointList[(i + 1) * 2 + 1].position - fullPointList[i * 2 + 1].position));
                        v1.Update(this, 0);
                        v2.Update(this, 0);
                        v3.Update(this, 0);

                        List<Vertex> subListA = new List<Vertex>();
                        subListA.Add(new Vertex(subList[0], treadRise * up)); // Left
                        subListA.Add(new Vertex(subList[1], treadRise * up + (1 - treadFraction) * (fullPointList[(i + 1) * 2 + 1].position - fullPointList[i * 2 + 1].position)));
                        subListA.Add(new Vertex(subList[2], (1 - treadFraction) * (fullPointList[(i + 1) * 2 + 1].position - fullPointList[i * 2 + 1].position)));
                        subListA.Add(new Vertex(subList[3], Vector3.Zero)); // Left
                        List<Vertex> subListB = new List<Vertex>();
                        subListB.Add(new Vertex(subList[1], treadRise * up + (1 - treadFraction) * (fullPointList[(i + 1) * 2 + 1].position - fullPointList[i * 2 + 1].position)));
                        subListB.Add(new Vertex(subList[1], Vector3.Zero));
                        subListB.Add(new Vertex(subList[2], Vector3.Zero));
                        subListB.Add(new Vertex(subList[2], (1 - treadFraction) * (fullPointList[(i + 1) * 2 + 1].position - fullPointList[i * 2 + 1].position)));

                        AddBlockFrontToTriangleList(subList, Color.White, depth + .01f, edgeSideEndTexCoords, triangleList, true);
                        AddBlockFrontToTriangleList(subListA, Color.White, depth + .011f, rubberSideSmallTexCoords, triangleList, true);
                        AddBlockFrontToTriangleList(subListB, Color.White, depth + .011f, rubberSideSmallTexCoords, triangleList, true);
                        AddTopStrip(v1, v2, depth + .011f, .00f, false, edgeTopTexCoords, triangleList);
                        AddTopStrip(v2, v3, depth + .011f, .00f, false, edgeTopTexCoords, triangleList);

                    }
                    else
                    {
                        Vertex v1 = new Vertex(fullPointList[i * 2 + 1], treadRise * up);
                        Vertex v2 = new Vertex(fullPointList[(i + 1) * 2 + 1], treadRise * up);
                        v1.Update(this, 0);
                        v2.Update(this, 0);
                        List<Vertex> subListA = new List<Vertex>();
                        subListA.Add(new Vertex(subList[0], treadRise * up));
                        subListA.Add(new Vertex(subList[1], treadRise * up));
                        subListA.Add(new Vertex(subList[2], Vector3.Zero));
                        subListA.Add(new Vertex(subList[3], Vector3.Zero));

                        AddBlockFrontToTriangleList(subList, Color.White, depth + .01f, edgeSideTexCoords, triangleList, true);
                        AddBlockFrontToTriangleList(subListA, Color.White, depth + .01f, rubberSideSmallTexCoords, triangleList, true);
                        AddTopStrip(v1, v2, depth + .01f, .00f, false, edgeTopTexCoords, triangleList);
                    }
            #endregion
                }
                else if (e.properties.type == VL.EdgeType.ConveyorBelt)
                {
                    #region conveyorbelt
                    float beltOffset = .0000125f * beltAnimation * e.properties.primaryValue;

                    beltOffset %= .125f;
                    if (beltOffset < 0)
                        beltOffset += .125f;

                    List<Vector2> activeBeltTopTexCoords = new List<Vector2>();
                    activeBeltTopTexCoords.Add(edgeTopTexCoords[0] + beltOffset * Vector2.UnitX);
                    activeBeltTopTexCoords.Add(edgeTopTexCoords[1] + beltOffset * Vector2.UnitX);
                    activeBeltTopTexCoords.Add(edgeTopTexCoords[2] + beltOffset * Vector2.UnitX);
                    activeBeltTopTexCoords.Add(edgeTopTexCoords[3] + beltOffset * Vector2.UnitX);
                    List<Vector2> activeBeltSideTexCoords = new List<Vector2>();
                    activeBeltSideTexCoords.Add(beltSideSmallTexCoords[0] + beltOffset * Vector2.UnitX);
                    activeBeltSideTexCoords.Add(beltSideSmallTexCoords[1] + beltOffset * Vector2.UnitX);
                    activeBeltSideTexCoords.Add(beltSideSmallTexCoords[2] + beltOffset * Vector2.UnitX);
                    activeBeltSideTexCoords.Add(beltSideSmallTexCoords[3] + beltOffset * Vector2.UnitX);

                    float treadRise = .08f;
                    float treadFraction = .8f;

                    if (i == width - 1)
                    {
                        Vertex v1t = new Vertex(fullPointList[i * 2 + 1], treadRise * up);
                        Vertex v3t = fullPointList[(i + 1) * 2 + 1];
                        Vertex v2t = new Vertex(fullPointList[i * 2 + 1], treadRise * up + treadFraction * (fullPointList[(i + 1) * 2 + 1].position - fullPointList[i * 2 + 1].position));

                        List<Vertex> subListA = new List<Vertex>();
                        subListA.Add(new Vertex(subList[0], Vector3.Zero)); // Left
                        subListA.Add(new Vertex(subList[1], treadRise * up + treadFraction * (fullPointList[(i + 1) * 2 + 1].position - fullPointList[i * 2 + 1].position)));
                        subListA.Add(new Vertex(subList[2], treadFraction * (fullPointList[(i + 1) * 2 + 1].position - fullPointList[i * 2 + 1].position)));
                        subListA.Add(new Vertex(subList[3], Vector3.Zero)); // Left
                        List<Vertex> subListB = new List<Vertex>();
                        subListB.Add(new Vertex(subList[1], treadRise * up + treadFraction * (fullPointList[(i + 1) * 2 + 1].position - fullPointList[i * 2 + 1].position)));
                        subListB.Add(new Vertex(subList[1], treadRise * up));
                        subListB.Add(new Vertex(subList[2], Vector3.Zero));
                        subListB.Add(new Vertex(subList[2], treadFraction * (fullPointList[(i + 1) * 2 + 1].position - fullPointList[i * 2 + 1].position)));

                        AddTopStrip(v1t, v2t, depth + .011f, .00f, false, activeBeltTopTexCoords, triangleList);
                        AddTopStrip(v2t, v3t, depth + .011f, .00f, false, activeBeltTopTexCoords, triangleList);
                        AddBlockFrontToTriangleList(mirrorSubList, Color.White, depth + .01f, edgeSideEndTexCoords, triangleList, true);
                        AddBlockFrontToTriangleList(subListA, Color.White, depth + .011f, activeBeltSideTexCoords, triangleList, true);
                        AddBlockFrontToTriangleList(subListB, Color.White, depth + .011f, activeBeltSideTexCoords, triangleList, true);
                    }
                    else if (i == 0)
                    {
                        Vertex v1 = fullPointList[i * 2 + 1];
                        Vertex v3 = new Vertex(fullPointList[(i + 1) * 2 + 1], treadRise * up);
                        Vertex v2 = new Vertex(fullPointList[i * 2 + 1], treadRise * up + (1-treadFraction) * (fullPointList[(i + 1) * 2 + 1].position - fullPointList[i * 2 + 1].position));
                        v1.Update(this, 0);
                        v2.Update(this, 0);
                        v3.Update(this, 0);

                        List<Vertex> subListA = new List<Vertex>();
                        subListA.Add(new Vertex(subList[0], treadRise * up)); // Left
                        subListA.Add(new Vertex(subList[1], treadRise * up+(1 - treadFraction) * (fullPointList[(i + 1) * 2 + 1].position - fullPointList[i * 2 + 1].position)));
                        subListA.Add(new Vertex(subList[2], (1-treadFraction) * (fullPointList[(i + 1) * 2 + 1].position - fullPointList[i * 2 + 1].position)));
                        subListA.Add(new Vertex(subList[3], Vector3.Zero)); // Left
                        List<Vertex> subListB = new List<Vertex>();
                        subListB.Add(new Vertex(subList[1], treadRise * up + (1-treadFraction) * (fullPointList[(i + 1) * 2 + 1].position - fullPointList[i * 2 + 1].position)));
                        subListB.Add(new Vertex(subList[1], Vector3.Zero));
                        subListB.Add(new Vertex(subList[2], Vector3.Zero));
                        subListB.Add(new Vertex(subList[2], (1 - treadFraction) * (fullPointList[(i + 1) * 2 + 1].position - fullPointList[i * 2 + 1].position)));

                        AddTopStrip(v1, v2, depth + .011f, .00f, false, activeBeltTopTexCoords, triangleList);
                        AddTopStrip(v2, v3, depth + .011f, .00f, false, activeBeltTopTexCoords, triangleList);
                        AddBlockFrontToTriangleList(subList, Color.White, depth + .01f, edgeSideEndTexCoords, triangleList, true);
                        AddBlockFrontToTriangleList(subListA, Color.White, depth + .011f, activeBeltSideTexCoords, triangleList, true);
                        AddBlockFrontToTriangleList(subListB, Color.White, depth + .011f, activeBeltSideTexCoords, triangleList, true);
                    }
                    else
                    {
                        Vertex v1 = new Vertex(fullPointList[i * 2 + 1], treadRise * up);
                        Vertex v2 = new Vertex(fullPointList[(i + 1) * 2 + 1], treadRise * up);
                        v1.Update(this, 0);
                        v2.Update(this, 0);

                        List<Vertex> subListA = new List<Vertex>();
                        subListA.Add(new Vertex(subList[0], treadRise * up));
                        subListA.Add(new Vertex(subList[1], treadRise * up));
                        subListA.Add(new Vertex(subList[2], Vector3.Zero));
                        subListA.Add(new Vertex(subList[3], Vector3.Zero));

                        AddTopStrip(v1, v2, depth + .011f, .00f, false, activeBeltTopTexCoords, triangleList);
                        AddBlockFrontToTriangleList(subList, Color.White, depth + .01f, edgeSideTexCoords, triangleList, true);
                        AddBlockFrontToTriangleList(subListA, Color.White, depth + .011f, activeBeltSideTexCoords, triangleList, true);
                    }
                    #endregion
                }
                else if (e.properties.type == VL.EdgeType.Electric && e.properties.primaryValue == 0)
                {
                    #region electric off
                    if (i == width - 1)
                    {
                        AddBlockFrontToTriangleList(mirrorSubList, Color.White, depth + .01f, edgeSideEndTexCoords, triangleList, true);
                        AddTopStrip(fullPointList[(i + 1) * 2 + 1], fullPointList[i * 2 + 1], depth + .01f, .01f, true, edgeTopEndTexCoords, triangleList);
                    }
                    else if (i == 0)
                    {
                        AddBlockFrontToTriangleList(subList, Color.White, depth + .01f, edgeSideEndTexCoords, triangleList, true);
                        AddTopStrip(fullPointList[i * 2 + 1], fullPointList[(i + 1) * 2 + 1], depth + .01f, .01f, false, edgeTopEndTexCoords, triangleList);
                    }
                    else
                    {
                        AddBlockFrontToTriangleList(subList, Color.White, depth + .01f, edgeSideTexCoords, triangleList, true);
                        AddTopStrip(fullPointList[i * 2 + 1], fullPointList[(i + 1) * 2 + 1], depth + .01f, .01f, false, edgeTopTexCoords, triangleList);
                    }
                    #endregion
                }
                else if (e.properties.type == VL.EdgeType.Electric && e.properties.primaryValue != 0)
                {
                    #region electric on
                    if (i == width - 1)
                    {
                        AddBlockFrontToTriangleList(mirrorSubList, Color.White, depth + .01f, edgeSideEndTexCoords, triangleList, true);
                        AddTopStrip(fullPointList[(i + 1) * 2 + 1], fullPointList[i * 2 + 1], depth + .01f, .01f, true, edgeTopEndTexCoords, triangleList);
                    }
                    else if (i == 0)
                    {
                        AddBlockFrontToTriangleList(subList, Color.White, depth + .01f, edgeSideEndTexCoords, triangleList, true);
                        AddTopStrip(fullPointList[i * 2 + 1], fullPointList[(i + 1) * 2 + 1], depth + .01f, .01f, false, edgeTopEndTexCoords, triangleList);
                    }
                    else
                    {
                        AddBlockFrontToTriangleList(subList, Color.White, depth + .01f, edgeSideTexCoords, triangleList, true);
                        AddTopStrip(fullPointList[i * 2 + 1], fullPointList[(i + 1) * 2 + 1], depth + .01f, .01f, false, edgeTopTexCoords, triangleList);
                    }
                    #endregion
                }
                else if (e.properties.type == VL.EdgeType.Fire && e.properties.primaryValue == 0)
                {
                    #region lava off
                    if (i == width - 1)
                    {
                        AddBlockFrontToTriangleList(mirrorSubList, Color.White, depth + .01f, edgeSideEndTexCoords, triangleList, true);
                        AddTopStrip(fullPointList[(i + 1) * 2 + 1], fullPointList[i * 2 + 1], depth + .01f, .01f, true, edgeTopEndTexCoords, triangleList);
                    }
                    else if (i == 0)
                    {
                        AddBlockFrontToTriangleList(subList, Color.White, depth + .01f, edgeSideEndTexCoords, triangleList, true);
                        AddTopStrip(fullPointList[i * 2 + 1], fullPointList[(i + 1) * 2 + 1], depth + .01f, .01f, false, edgeTopEndTexCoords, triangleList);
                    }
                    else
                    {
                        AddBlockFrontToTriangleList(subList, Color.White, depth + .01f, edgeSideTexCoords, triangleList, true);
                        AddTopStrip(fullPointList[i * 2 + 1], fullPointList[(i + 1) * 2 + 1], depth + .01f, .01f, false, edgeTopTexCoords, triangleList);
                    }
                    #endregion
                }
                else if (e.properties.type == VL.EdgeType.Fire && e.properties.primaryValue != 0)
                {
                    #region lava on
                    if (i == width - 1)
                    {
                        AddBlockFrontToTriangleList(mirrorSubList, Color.White, depth + .01f, edgeSideEndTexCoords, triangleList, true);
                        AddTopStrip(fullPointList[(i + 1) * 2 + 1], fullPointList[i * 2 + 1], depth + .01f, .01f, true, edgeTopEndTexCoords, triangleList);
                    }
                    else if (i == 0)
                    {
                        AddBlockFrontToTriangleList(subList, Color.White, depth + .01f, edgeSideEndTexCoords, triangleList, true);
                        AddTopStrip(fullPointList[i * 2 + 1], fullPointList[(i + 1) * 2 + 1], depth + .01f, .01f, false, edgeTopEndTexCoords, triangleList);
                    }
                    else
                    {
                        AddBlockFrontToTriangleList(subList, Color.White, depth + .01f, edgeSideTexCoords, triangleList, true);
                        AddTopStrip(fullPointList[i * 2 + 1], fullPointList[(i + 1) * 2 + 1], depth + .01f, .01f, false, edgeTopTexCoords, triangleList);
                    }
                    #endregion
                }
                else
                {
                    #region magnet
                    if (i == width - 1)
                        AddBlockFrontToTriangleList(mirrorSubList, Color.White, depth + .01f, edgeSideEndTexCoords, triangleList, true);
                    else if (i == 0)
                        AddBlockFrontToTriangleList(subList, Color.White, depth + .01f, edgeSideEndTexCoords, triangleList, true);
                    else
                        AddBlockFrontToTriangleList(subList, Color.White, depth + .01f, edgeSideTexCoords, triangleList, true);

                    AddTopStrip(fullPointList[i * 2 + 1], fullPointList[(i + 1) * 2 + 1], depth + .01f, .01f, false, edgeTopTexCoords, triangleList);
                    #endregion
                }
            }
        }
Exemplo n.º 22
0
 public void Reset(Monster srcMonster)
 {
     this.gunLine = srcMonster.position.direction;
     this.gunNormal = Vector3.Cross(gunLine, srcMonster.position.normal);
     this.position = srcMonster.position;
 }