/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { wandererWorld = Matrix.Identity; wanderer = new WandererBody(this); heightMapTransformSystem_Wanderer = new HeightMapTransformSystem_Wanderer(); heightMapComponent = new HeightMapComponent(); heightMapCameraComponent = new HeightMapCameraComponent(); robotComponent = new RobotComponent(); heightMapSystem = new HeightmapSystem(); heightMapTranformSystem = new HeightMapTranformSystem(); heightMapRenderSystem = new HeightMapRenderSystem(graphics.GraphicsDevice); robotSystem = new RobotSystem(); robotTranformSystem = new RobotTranformSystem(); robotRenderSystem = new RobotRenderSystem(); collisionSystem = new CollisionSystem(); houseSystem = new HouseSystem(this); systemRenderer = new Renderer(); base.Initialize(); }
public void Visit(RobotComponent component) { if (component.Modules.Any()) { throw new PerpetuumException(ErrorCodes.RobotHasModulesEquipped); } }
public RobotComponent CreateRobot() { RobotComponent newRobot = Instantiate(Robot, RobotSpawn.position, Quaternion.identity, transform); newRobot.gameObject.SetActive(true); InstantiatedRobots.Add(newRobot); return(newRobot); }
public void Visit(RobotComponent component) { AddItemInfo(component); var bonus = component.ExtensionBonuses.ToDictionary("a", cb => cb.ToDictionary()); if (bonus.Count > 0) { _info[k.bonus] = bonus; } }
public bool checkTypePiece(RobotComponent pieza) { bool enc = false; for (int i = 0; i < Components.Count && !enc; i++) { if (Components[i].type == pieza.type) { enc = true; } } return(enc); }
// Use this for initialization void Start() { Vector3 angles = transform.eulerAngles; x = angles.y; y = angles.z; Quaternion rotation = Quaternion.Euler(0.1f * rotateSpeed * distance * 0.02f, 0f * rotateSpeed * distance * 0.02f, 0); Vector3 position = rotation * new Vector3(0.0f, 0.0f, -distance) + target.position; targetRotation = rotation; targetPosition = position; currentComponent = Instantiate(motors[0]).GetComponent <RobotComponent>(); }
public bool AddRobotComponent(RobotComponent pieza, GameObject gameObjectComponent) { if (!CanICatch(pieza)) { return(false); } else { //Permetre agafar una peça si ja està la anterior posada. PlayerCompSystem.Components.Add(pieza); PlayerCompSystem.ComponentsGameObject.Add(gameObjectComponent); emitirParticulasGetObject(); soundController.cogerPieza(); return(true); } }
public bool CanICatch(RobotComponent pieza) { if (pieza.type == PieceType.Arms) { for (int i = 0; i < PlayerCompSystem.Components.Count; i++) { if (PlayerCompSystem.Components[i].type == PieceType.Legs) { return(true); } } } else if (pieza.type == PieceType.Legs) { return(true); } else if (pieza.type == PieceType.Back) { bool hasLegs = false; bool hasArms = false; for (int i = 0; i < PlayerCompSystem.Components.Count; i++) { if (PlayerCompSystem.Components[i].type == PieceType.Legs) { hasLegs = true; } if (PlayerCompSystem.Components[i].type == PieceType.Arms) { hasArms = true; } } if (hasLegs && hasArms) { return(true); } } return(false); }
public void OnLimbRemoved(RobotComponent limb, AttachmentSlot slot, AttachmentType type) { if (LimbRemoved != null) { LimbRemoved(limb, slot, type); } }
public RobotController(RobotComponent component) { _component = component; _component.Collision.OnCollisionDetected.AddListener(OnCollisionEnter); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); Texture2D heightMapTexture2D = Content.Load <Texture2D>("US_Canyon"); Texture2D heightMapGrassTexture = Content.Load <Texture2D>("grass2"); Texture2D heightMapFireTexture = Content.Load <Texture2D>("fire"); Texture2D BrickTexture = Content.Load <Texture2D>("wall_texture"); Model robotModel = Content.Load <Model>("Lab2Model"); Texture2D robotTexture = Content.Load <Texture2D>("robot_texture"); Texture2D roofTexture = Content.Load <Texture2D>("roof"); Texture2D timberWallTexture = Content.Load <Texture2D>("timber_wall"); Texture2D timberRoofTexture = Content.Load <Texture2D>("timber_roof"); heightMapComponent = new HeightMapComponent { HeightMap = heightMapTexture2D, HeightMapTexture = heightMapGrassTexture, GraphicsDevice = graphics.GraphicsDevice, Width = heightMapTexture2D.Width, Height = heightMapTexture2D.Height, HeightMapData = new float[heightMapTexture2D.Width, heightMapTexture2D.Height] }; heightMapCameraComponent = new HeightMapCameraComponent() { ViewMatrix = Matrix.CreateLookAt(new Vector3(-100, 0, 0), Vector3.Zero, Vector3.Up), ProjectionMatrix = Matrix.CreatePerspective(1.2f, 0.9f, 1.0f, 1000.0f), TerrainMatrix = Matrix.CreateTranslation(new Vector3(0, -100, 256)), Position = new Vector3(-100, 0, 0), Direction = Vector3.Zero, Movement = new Vector3(1, 1, 1), Rotation = new Vector3(2, 2, 2) * 0.01f, TerrainPosition = new Vector3(0, -100, 256), }; heightMapCameraComponent.Frustum = new BoundingFrustum(heightMapCameraComponent.ViewMatrix * heightMapCameraComponent.ProjectionMatrix); //var h1 = new HouseComponent(new Vector3(40, 100, 40), new Vector3(100, 50, -100), Matrix.Identity, BrickTexture, roofTexture); //var h2 = new HouseComponent(new Vector3(40, 100, 40), new Vector3(950, 50, -100), Matrix.Identity, BrickTexture, roofTexture); //var h3 = new HouseComponent(new Vector3(40, 100, 40), new Vector3(950, 50, -900), Matrix.Identity, BrickTexture, roofTexture); //int h1Id = EntityComponentManager.GetManager().CreateNewEntityId(); //EntityComponentManager.GetManager().AddComponentToEntity(h1Id, h1); //int h2Id = EntityComponentManager.GetManager().CreateNewEntityId(); //EntityComponentManager.GetManager().AddComponentToEntity(h2Id, h2); //int h3Id = EntityComponentManager.GetManager().CreateNewEntityId(); //EntityComponentManager.GetManager().AddComponentToEntity(h3Id, h3); int heightMapId = EntityComponentManager.GetManager().CreateNewEntityId(); EntityComponentManager.GetManager().AddComponentToEntity(heightMapId, heightMapComponent); EntityComponentManager.GetManager().AddComponentToEntity(heightMapId, heightMapCameraComponent); CreateRandomHouses(10, BrickTexture, roofTexture, timberWallTexture, timberRoofTexture); heightMapSystem.CreateHeightMaps(); robotComponent = new RobotComponent { Speed = 0, Texture = robotTexture, PlaneObjectWorld = Matrix.Identity, TransformMatrices = new Matrix[robotModel.Bones.Count], Effect = new BasicEffect(graphics.GraphicsDevice), Scale = Matrix.CreateScale(0.5f), Position = new Vector3(0f, 1300f, 0f), RobotProjection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver2, 1280 / 720, 0.1f, 500f), RobotView = Matrix.CreateLookAt(new Vector3(70, 50, 30), new Vector3(0, 0, 20), Vector3.Backward) }; robotCameraComponent = new RobotCameraComponent { MaxRotation = MathHelper.PiOver4, RotationSpeed = 0.003f, ModelRotation = 0, Model = robotModel, Direction = true, LeftArmMatrix = robotModel.Bones["LeftArm"].Transform, RightArmMatrix = robotModel.Bones["RightArm"].Transform, LeftLegMatrix = robotModel.Bones["LeftLeg"].Transform, RightLegMatrix = robotModel.Bones["RightLeg"].Transform, Rotation = Quaternion.CreateFromAxisAngle(Vector3.Right, MathHelper.PiOver2) * Quaternion.CreateFromAxisAngle(Vector3.Up, MathHelper.Pi), RotationInDegrees = 0 }; int robotId = EntityComponentManager.GetManager().CreateNewEntityId(); EntityComponentManager.GetManager().AddComponentToEntity(robotId, robotComponent); EntityComponentManager.GetManager().AddComponentToEntity(robotId, robotCameraComponent); //robotSystem.CreateRobots(); }
public void NextLegAbility() { List<RobotComponent> legAbilities = currentLegs.Where(l => l is LimbComponent).ToList(); int activeIndex = 0; if (activeLeg != null) { activeIndex = legAbilities.FindIndex(leg => leg == activeLeg); activeIndex += 1; if (legAbilities.Count > 0) { activeIndex %= legAbilities.Count; } } if (legAbilities.Count > 0) { if (activeLeg) { activeLeg.isActive = false; } activeLeg = legAbilities[activeIndex]; activeLeg.isActive = true; } else { if (activeLeg) { activeLeg.isActive = false; } activeLeg = null; } RefreshInputHints(); }
void OnParentDestroyed(RobotComponent component) { SetSelectedParent(null); if (state == AttachmentState.SelectChild || state == AttachmentState.AttachingPart || state == AttachmentState.AttachingToLevelObject) { Abort(); } }
public void OnLimbRemoved(RobotComponent limb, AttachmentSlot slot, AttachmentType type) { if (type == AttachmentType.Arm) { if (anim) { anim.SetBool("aimLeft", false); anim.SetBool("aimRight", false); } currentArms.Remove(limb); if (limb == activeArm) { activeArm = null; NextArmAbility(); } } if (type == AttachmentType.Leg) { currentLegs.Remove(limb); if (limb == activeLeg) { activeLeg = null; NextLegAbility(); } } allComponents.Remove(limb); rigidbody2D.fixedAngle = HasLimbs; AudioSource.PlayClipAtPoint(limbAttachSound, transform.position); switch (slot) { case AttachmentSlot.LeftHip: anim.SetBool("hasLeftLeg", false); break; case AttachmentSlot.RightHip: anim.SetBool("hasRightLeg", false); break; case AttachmentSlot.Spine: if (limb is TorsoComponent) { anim.SetBool("hasTorso", false); } else { anim.SetBool("hasLimbAsTorso", false); } break; } RefreshInputHints(); }
public void OnLimbAdded(RobotComponent limb, AttachmentSlot slot, AttachmentType type) { if (type == AttachmentType.Arm) { currentArms.Add(limb); if (activeArm == null) { NextArmAbility(); } } if (type == AttachmentType.Leg) { currentLegs.Add(limb); if (activeLeg == null) { NextLegAbility(); } } allComponents.Add(limb); transform.eulerAngles = Vector3.zero; AudioSource.PlayClipAtPoint(limbRemoveSound, transform.position); switch (slot) { case AttachmentSlot.LeftHip: anim.SetBool("hasLeftLeg", true); break; case AttachmentSlot.RightHip: anim.SetBool("hasRightLeg", true); break; case AttachmentSlot.Spine: if (limb is TorsoComponent) { anim.SetBool("hasTorso", true); } else { anim.SetBool("hasLimbAsTorso", true); } break; } RefreshInputHints(); }
private void SpawnRobot() { RobotComponent robotComponent = _component.CreateRobot(); _level.Robot = new RobotController(robotComponent); }
public void NextArmAbility() { anim = GetComponentInChildren<Animator>(); int activeIndex = 0; if (activeArm != null) { if (anim && activeArm.shouldAim == true) { anim.SetBool(activeArm.parentAttachmentPoint.animatorAimFlag, false); } activeIndex = currentArms.FindIndex(arm => arm == activeArm); activeIndex += 1; if (currentArms.Count > 0) { activeIndex %= currentArms.Count; } } if (currentArms.Count > 0) { if (activeArm) { activeArm.isActive = false; } activeArm = currentArms[activeIndex]; activeArm.isActive = true; if (anim) { anim.SetBool(activeArm.parentAttachmentPoint.animatorAimFlag, true); } } else { if (activeArm) { activeArm.isActive = false; } activeArm = null; } RefreshInputHints(); }