private void WindowLoaded(object sender, RoutedEventArgs e) { if (!loaded) { Carousel.Add(@"c:\sandbox\silverlight.wmv"); Carousel.Add(@"c:\sandbox\cocoigor.wmv"); Carousel.Add(@"c:\sandbox\Walking With Dinosaurs 6.mp4"); Carousel.Build(); Carousel.Activate(); loaded = true; } }
public Robot(string name, bool isPreview, bool human, Part[] parts) { Point position = new Point(); cachedPosition = position; cachedAngle = position; force = new Point(); damageReceived = 0; damageDealt = 0; active = true; positionInitialized = false; HUMAN = human; if (name != default && name != "") { this.name = name; } else { this.name = DEFAULT_NAME; } ATTACHMENTS = new Carousel <Attachment>(); SIZE = new Dimension(); foreach (Part part in parts) { if (part is Head) { HEAD = (Head)part; } else if (part is Body) { BODY = (Body)part; } else if (part is Mobility) { MOBILITY = (Mobility)part; } else { ATTACHMENTS.Add((Attachment)part); } } if (HEAD == null || BODY == null || MOBILITY == null) { throw new Exception(); } else { if (!isPreview) { GAME_OBJECT = new GameObject(); GAME_OBJECT.AddComponent <Rigidbody>(); Vector3 robotFootprint = GAME_OBJECT.AddComponent <BoxCollider>().bounds.size; GAME_OBJECT.GetComponent <Collider>().isTrigger = true; GAME_OBJECT.GetComponent <Rigidbody>().useGravity = true; setConstraints(); Vector3 rescale = GAME_OBJECT.transform.localScale; rescale.x = (float)SCALE / robotFootprint.x; rescale.y = (float)SCALE / robotFootprint.z; rescale.z = (float)SCALE / robotFootprint.z; GAME_OBJECT.transform.localScale = rescale; if (HEAD.GAME_OBJECT == default) { HEAD = new Head(HEAD.getID(), HEAD.getImage(), HEAD.getWeight(), HEAD.getShape(), HEAD.getDurability(), HEAD.getRemainingDurability()); } HEAD.GAME_OBJECT.transform.SetParent(GAME_OBJECT.transform, false); if (BODY.GAME_OBJECT == default) { BODY = new Body(BODY.getID(), BODY.getImage(), BODY.getWeight(), BODY.getShape(), BODY.getDurability(), BODY.getRemainingDurability(), BODY.getMaxAttachments()); } BODY.GAME_OBJECT.transform.SetParent(GAME_OBJECT.transform, false); if (MOBILITY.GAME_OBJECT == default) { MOBILITY = new Mobility(MOBILITY.getID(), MOBILITY.getImage(), MOBILITY.getWeight(), MOBILITY.getShape(), MOBILITY.getDurability(), MOBILITY.getRemainingDurability(), MOBILITY.getClimbAngle(), MOBILITY.getMaxSpeed(), MOBILITY.getMaxForce()); } MOBILITY.GAME_OBJECT.transform.SetParent(GAME_OBJECT.transform, false); Vector3 robotPosition = GAME_OBJECT.transform.position = position.toVector3(); MOBILITY.GAME_OBJECT.transform.position = new Vector3(robotPosition.x, 0, robotPosition.z); BODY.GAME_OBJECT.transform.position = new Vector3(robotPosition.x, MOBILITY.GAME_OBJECT.GetComponent <Renderer>().bounds.size.y *POSITION_MULTIPLIER, robotPosition.z); if (HEAD.getShape() == Shape.SHAPES.HEMISPHERE) { HEAD.GAME_OBJECT.transform.position = new Vector3(robotPosition.x, MOBILITY.GAME_OBJECT.GetComponent <Renderer>().bounds.size.y *POSITION_MULTIPLIER + BODY.GAME_OBJECT.GetComponent <Renderer>().bounds.size.y - HEAD.GAME_OBJECT.GetComponent <Renderer>().bounds.size.y / 2, robotPosition.z); } else { HEAD.GAME_OBJECT.transform.position = new Vector3(robotPosition.x, MOBILITY.GAME_OBJECT.GetComponent <Renderer>().bounds.size.y *POSITION_MULTIPLIER + BODY.GAME_OBJECT.GetComponent <Renderer>().bounds.size.y, robotPosition.z); } Vector3 footprint = GAME_OBJECT.AddComponent <BoxCollider>().bounds.size; SIZE = new Dimension(footprint.x, footprint.y, footprint.z); } double attachmentWeight = 0; if (ATTACHMENTS != null && ATTACHMENTS.Count > 0) { foreach (Attachment attachment in ATTACHMENTS) { attachmentWeight += attachment.getWeight(); } } WEIGHT = HEAD.getWeight() + BODY.getWeight() + MOBILITY.getWeight() + attachmentWeight; MAX_ATTACHMENTS = BODY.getMaxAttachments(); CLIMB_ANGLE = MOBILITY.getClimbAngle(); MAX_SPEED = MOBILITY.getMaxSpeed(); MAX_FORCE = MOBILITY.getMaxForce(); } }