public virtual void Init() { weapon = GetComponentInChildren<Weapon>(); engine = GetComponentInChildren<Engine>(); cockpit = GetComponentInChildren<Cockpit> (); hull = GetComponentInChildren<Hull> (); wings = GetComponentInChildren<Wings> (); maxHealth = health = hull.maxHealth; rigidbody2D.mass = hull.mass; shipCollider = GetComponentInChildren<PolygonCollider2D>(); if (wings.maxShield > 0) { wings.parent = this; shipCollider.enabled = false; shieldCollider = GetComponentInChildren<CircleCollider2D>(); shieldCollider.enabled = true; } //activeWeapons = weapons; hitTime = Time.time; }
void UpdateSelected() { selectedWing = wings[wingIndex]; selectedEngine = engines[engineIndex]; selectedWeapon = weapons[weaponIndex]; selectedHull = hulls[hullIndex]; selectedCockpit = cockpits[cockpitIndex]; }
public void ShowShip(Entity entity, Entity player = null) { _enemy = player != null; _player = player; if (_schematicItems != null) { foreach (var item in _schematicItems) { item.ListElement.GetComponent <Prototype>().ReturnToPool(); } } _entity = entity; if (!_enemy) { _cockpit = entity.GetBehavior <Cockpit>(); _reactor = entity.GetBehavior <Reactor>(); _capacitors = entity.GetBehaviors <Capacitor>().ToArray(); _aetherDrive = entity.GetBehavior <AetherDrive>(); AetherDriveUi.SetActive(_aetherDrive != null); _radiators = entity.GetBehaviors <Radiator>().ToArray(); if (_radiators.Length == 0) { RadiatorTemperatureLabel.text = "N/A"; } _heatStorages = entity.GetBehaviors <HeatStorage>().ToArray(); if (_heatStorages.Length == 0) { HeatStorageTemperatureLabel.text = "N/A"; } _cargoBays = entity.CargoBays.ToArray(); if (_cargoBays.Length == 0) { CargoTemperatureLabel.text = "N/A"; } } _schematicItems = entity.Equipment .Where(x => x.Behaviors.Any(b => b.Data is WeaponData)) .Select(x => new SchematicDisplayItem { Item = x, ListElement = ListElementPrototype.Instantiate <SchematicListElement>(), Cooldown = _enemy ? null : (IProgressBehavior)x.Behaviors.FirstOrDefault(b => b is IProgressBehavior), // ItemUsage = _enemy ? null : (ItemUsage) x.Behaviors.FirstOrDefault(b=> b is ItemUsage), Weapon = (Weapon)x.Behaviors.FirstOrDefault(b => b is Weapon) }) .ToArray(); foreach (var x in _schematicItems) { if (x.Item.Data is WeaponItemData weaponItemData) { x.ListElement.ShowWeapon(weaponItemData); } //x.ListElement.Label.text = x.Item.EquippableItem.Name; if (!_enemy) { x.ListElement.InfiniteAmmoIcon.gameObject.SetActive(x.Weapon.WeaponData.AmmoType == Guid.Empty); x.ListElement.AmmoLabel.gameObject.SetActive(x.Weapon.WeaponData.AmmoType != Guid.Empty); } } }
// Use this for initialization void Start() { _car = RaceController.Locate().MyCar; _animator = GetComponent <Animator>(); }
public void Start(Cockpit cockpit) { this.Cockpit = cockpit; }
//Initializes the game world and starts a new random world public void Initialise(Cockpit cockpit) { this.cockpit = cockpit; Events.Start (cockpit); InitRandomWorld (0, 0); }
public void Initialize(Cockpit cockpit) { cockpit.Name = "photoCockpit"; // Configure how the cockpit moves cockpit.PositionMode = Cockpit.MovementMode.TrackPosition; // [RMS] use orientation mode to make cockpit follow view orientation. // (however default widgets below are off-screen!) //cockpit.PositionMode = Cockpit.MovementMode.TrackOrientation; // Add some UI elements to the cockpit // - cylinder & box buttons - double-click or drag/drop into scene // - button to start and cancel draw-primitives tool float fHUDRadius = 1.0f; Color bgColor = new Color(0.7f, 0.7f, 1.0f, 0.7f); Material bgMaterial = (bgColor.a == 1.0f) ? MaterialUtil.CreateStandardMaterial(bgColor) : MaterialUtil.CreateTransparentMaterial(bgColor); Material primMaterial = MaterialUtil.CreateStandardMaterial(Color.yellow); float fButtonsY = -50.0f; // degrees float fButtonsSpacing = 15.0f; float fPrimitivesX = -35.0f; DropPrimitiveButton cylinderButton = add_primitive_button(cockpit, "create_cylinder", fHUDRadius, fPrimitivesX, fButtonsY, PrimitiveType.Cylinder, SOTypes.Cylinder, 0.7f, bgMaterial, primMaterial, () => { return(new CylinderSO().Create(cockpit.Scene.DefaultSOMaterial)); }); cockpit.AddUIElement(cylinderButton); DropPrimitiveButton boxButton = add_primitive_button(cockpit, "create_box", fHUDRadius, fPrimitivesX + fButtonsSpacing, fButtonsY, PrimitiveType.Cube, SOTypes.Box, 0.8f, bgMaterial, primMaterial, () => { return(new BoxSO().Create(cockpit.Scene.DefaultSOMaterial)); }); cockpit.AddUIElement(boxButton); float fToolsX = 35.0f; float fToolButtonRadius = 0.08f; // buttons for draw-primitive tool and cancel-tool button ActivateToolButton drawPrimButton = add_tool_button(cockpit, DrawPrimitivesTool.Identifier, fHUDRadius, fToolsX - fButtonsSpacing, fButtonsY, fToolButtonRadius, bgMaterial, primMaterial, new toolInfo() { identifier = DrawSurfaceCurveTool.Identifier, sMeshPath = "draw_primitive", fMeshScaleFudge = 1.2f }); cockpit.AddUIElement(drawPrimButton); ActivateToolButton cancelButton = add_tool_button(cockpit, "cancel", fHUDRadius, fToolsX, fButtonsY, fToolButtonRadius, bgMaterial, primMaterial, new toolInfo() { identifier = "cancel", sMeshPath = "cancel", fMeshScaleFudge = 1.2f }); cockpit.AddUIElement(cancelButton); // Configure interaction behaviors // - below we add behaviors for mouse, gamepad, and spatial devices (oculus touch, etc) // - keep in mind that Tool objects will register their own behaviors when active // setup key handlers (need to move to behavior...) cockpit.AddKeyHandler(new SampleKeyHandler(cockpit.Context)); // these behaviors let us interact with UIElements (ie left-click/trigger, or either triggers for Touch) cockpit.InputBehaviors.Add(new VRMouseUIBehavior(cockpit.Context) { Priority = 0 }); cockpit.InputBehaviors.Add(new VRGamepadUIBehavior(cockpit.Context) { Priority = 0 }); cockpit.InputBehaviors.Add(new VRSpatialDeviceUIBehavior(cockpit.Context) { Priority = 0 }); // spatial device does camera manipulation via Behavior // (mouse/gamepad currently do not, but will in future!) cockpit.InputBehaviors.Add(new SpatialDeviceViewManipBehavior(cockpit) { Priority = 2 }); SpatialDeviceGrabBehavior grab = new SpatialDeviceGrabBehavior(cockpit) { StickMoveSpeed = 0.03f, Priority = 3 }; grab.OnBeginGrab += (sender, target) => { cockpit.Scene.Select(target, true); }; grab.OnEndGrab += (sender, target) => { cockpit.Scene.ClearSelection(); }; cockpit.InputBehaviors.Add(grab); // selection / multi-selection behaviors cockpit.InputBehaviors.Add(new MouseMultiSelectBehavior(cockpit.Context) { Priority = 10 }); cockpit.InputBehaviors.Add(new GamepadMultiSelectBehavior(cockpit.Context) { Priority = 10 }); cockpit.InputBehaviors.Add(new SpatialDeviceMultiSelectBehavior(cockpit.Context) { Priority = 10 }); // de-selection behaviors cockpit.InputBehaviors.Add(new MouseDeselectBehavior(cockpit.Context) { Priority = 999 }); cockpit.InputBehaviors.Add(new GamepadDeselectBehavior(cockpit.Context) { Priority = 999 }); cockpit.InputBehaviors.Add(new SpatialDeviceDeselectBehavior(cockpit.Context) { Priority = 999 }); cockpit.InputBehaviors.Add(new UndoShortcutBehavior(cockpit.Context) { Priority = 999 }); // screencap to your dropbox cockpit.OverrideBehaviors.Add(new ScreenCaptureBehavior() { Priority = 0, ScreenshotPath = Environment.GetEnvironmentVariable("homepath") + "\\DropBox\\ScreenShots\\" }); }
private void Awake() { _rigidbody = GetComponentInParent <Rigidbody>(); _car = GetComponentInParent <Cockpit>(); }
// Use this for initialization public void Initialise(Cockpit cockpit) { this.cockpit = cockpit; Events.Start (cockpit); }
public void Initialize(Cockpit cockpit) { cockpit.Name = "modelCockpit"; // Configure how the cockpit moves //cockpit.PositionMode = Cockpit.MovementMode.TrackPosition; // [RMS] use orientation mode to make cockpit follow view orientation. // (however default widgets below are off-screen!) cockpit.PositionMode = Cockpit.MovementMode.TrackOrientation; BoxContainer screenContainer = new BoxContainer(new Cockpit2DContainerProvider(cockpit)); PinnedBoxes2DLayoutSolver screenLayout = new PinnedBoxes2DLayoutSolver(screenContainer); PinnedBoxesLayout layout = new PinnedBoxesLayout(cockpit, screenLayout) { StandardDepth = 2.0f }; cockpit.AddLayout(layout, "2D", true); Func <string, float, HUDLabel> MakeButtonF = (label, buttonW) => { HUDLabel button = new HUDLabel() { Shape = CotangentUI.MakeMenuButtonRect(buttonW, CotangentUI.MenuButtonHeight), TextHeight = CotangentUI.MenuButtonTextHeight, AlignmentHorz = HorizontalAlignment.Center, BackgroundColor = CotangentUI.ButtonBGColor, TextColor = CotangentUI.ButtonTextColor, Text = label, EnableBorder = true, BorderWidth = CotangentUI.StandardButtonBorderWidth, BorderColor = CotangentUI.ButtonTextColor }; button.Create(); button.Name = label; button.Enabled = true; return(button); }; Vector2f progressOffsetY = 4 * CotangentUI.PixelScale * Vector2f.AxisY; HUDRadialProgress slicerProgress = new HUDRadialProgress() { Radius = 18 * CotangentUI.PixelScale }; slicerProgress.Create(); slicerProgress.Name = "slicer_progress"; int MAX_PROGRESS = 1000; slicerProgress.MaxProgress = MAX_PROGRESS; CC.SlicingProgressEvent += (status) => { if (status.bFailed) { double t = 0.5 * (double)status.curProgress / (double)status.maxProgress; slicerProgress.Progress = (int)(t * MAX_PROGRESS); slicerProgress.CompletedColor = Colorf.VideoRed; } else { double t = 0.5 * (double)status.curProgress / (double)status.maxProgress; slicerProgress.Progress = (int)(t * MAX_PROGRESS); slicerProgress.CompletedColor = Colorf.BlueMetal; } }; CC.ToolpathProgressEvent += (status) => { if (status.bFailed) { double t = 0.5 + 0.5 * (double)status.curProgress / (double)status.maxProgress; slicerProgress.Progress = (int)(t * MAX_PROGRESS); slicerProgress.CompletedColor = Colorf.VideoRed; } else { double t = 0.5 + 0.5 * (double)status.curProgress / (double)status.maxProgress; if (status.curProgress == 0 && status.maxProgress == 1) { t = 0; } slicerProgress.Progress = (int)(t * MAX_PROGRESS); slicerProgress.CompletedColor = (status.curProgress == status.maxProgress) ? Colorf.LightGreen : Colorf.BlueMetal; } }; layout.Add(slicerProgress, new LayoutOptions() { Flags = LayoutFlags.None, PinSourcePoint2D = LayoutUtil.BoxPointF(slicerProgress, BoxPosition.CenterBottom), PinTargetPoint2D = LayoutUtil.BoxPointF(screenContainer, BoxPosition.CenterBottom, progressOffsetY) }); HUDButton progressClick = new HUDButton() { Shape = new HUDShape(HUDShapeType.Disc, slicerProgress.Radius) }; fMaterial normalMaterial = MaterialUtil.CreateFlatMaterialF(Colorf.White, 0); fMaterial pauseMaterial = MaterialUtil.CreateTransparentImageMaterialF("icons/progress_pause"); fMaterial pausedMaterial = MaterialUtil.CreateTransparentImageMaterialF("icons/progress_play"); if (CCPreferences.ActiveSlicingUpdateMode == CCPreferences.SlicingUpdateModes.ImmediateSlicing) { progressClick.Create(normalMaterial, null, pauseMaterial); } else { progressClick.Create(pausedMaterial, null, null); } progressClick.Name = "progress_click"; layout.Add(progressClick, new LayoutOptions() { Flags = LayoutFlags.None, DepthShift = -0.1f, PinSourcePoint2D = LayoutUtil.BoxPointF(progressClick, BoxPosition.CenterBottom), PinTargetPoint2D = LayoutUtil.BoxPointF(screenContainer, BoxPosition.CenterBottom, progressOffsetY) }); progressClick.OnClicked += (o, e) => { if (CCPreferences.ActiveSlicingUpdateMode == CCPreferences.SlicingUpdateModes.ImmediateSlicing) { CCPreferences.ActiveSlicingUpdateMode = CCPreferences.SlicingUpdateModes.SliceOnDemand; progressClick.StandardMaterial = pausedMaterial; progressClick.HoverMaterial = null; } else { CCPreferences.ActiveSlicingUpdateMode = CCPreferences.SlicingUpdateModes.ImmediateSlicing; progressClick.StandardMaterial = normalMaterial; progressClick.HoverMaterial = pauseMaterial; } if (CC.Toolpather.ToolpathsValid == false) { // not sure why we have to invalidate slicing here, but if we don't toolpath // computation will not stop when we pause... CC.Slicer.InvalidateSlicing(); //CC.InvalidateToolPaths(); } }; CotangentUI.PrintViewHUDItems = new List <HUDStandardItem>() { slicerProgress, progressClick }; screenLayout.RecomputeLayout(); // Configure interaction behaviors // - below we add behaviors for mouse, gamepad, and spatial devices (oculus touch, etc) // - keep in mind that Tool objects will register their own behaviors when active // setup key handlers (need to move to behavior...) cockpit.AddKeyHandler(new CotangentKeyHandler(cockpit.Context)); // these behaviors let us interact with UIElements (ie left-click/trigger, or either triggers for Touch) cockpit.InputBehaviors.Add(new Mouse2DCockpitUIBehavior(cockpit.Context) { Priority = 0 }); cockpit.InputBehaviors.Add(new VRMouseUIBehavior(cockpit.Context) { Priority = 1 }); // selection / multi-selection behaviors // Note: this custom behavior implements some selection redirects that we use in various parts of Archform cockpit.InputBehaviors.Add(new MouseMultiSelectBehavior(cockpit.Context) { Priority = 10 }); // left click-drag to tumble, and left click-release to de-select cockpit.InputBehaviors.Add(new MouseClickDragSuperBehavior() { Priority = 100, DragBehavior = new MouseViewRotateBehavior(cockpit.Context) { Priority = 100, RotateSpeed = 3.0f }, ClickBehavior = new MouseDeselectBehavior(cockpit.Context) { Priority = 999 } }); // also right-click-drag to tumble cockpit.InputBehaviors.Add(new MouseViewRotateBehavior(cockpit.Context) { Priority = 100, RotateSpeed = 3.0f, ActivateF = MouseBehaviors.RightButtonPressedF, ContinueF = MouseBehaviors.RightButtonDownF }); // middle-click-drag to pan cockpit.InputBehaviors.Add(new MouseViewPanBehavior(cockpit.Context) { Priority = 100, PanSpeed = 0.01f, Adaptive = true, ActivateF = MouseBehaviors.MiddleButtonPressedF, ContinueF = MouseBehaviors.MiddleButtonDownF }); cockpit.OverrideBehaviors.Add(new MouseWheelZoomBehavior(cockpit) { Priority = 100, ZoomScale = 0.2f, Adaptive = true }); // touch input cockpit.InputBehaviors.Add(new TouchUIBehavior(cockpit.Context) { Priority = 1 }); cockpit.InputBehaviors.Add(new Touch2DCockpitUIBehavior(cockpit.Context) { Priority = 0 }); cockpit.InputBehaviors.Add(new TouchViewManipBehavior(cockpit.Context) { Priority = 999, TouchZoomSpeed = 0.1f, TouchPanSpeed = 0.03f }); }
// Use this for initialization void Start() { _race = RaceController.Locate(); _myCar = _race.MyCar; }