/// <summary> /// Get the color of the currently active node. If the active node is null /// then it gets the color of the current color palette selection. /// </summary> /// <returns></returns> public static Vector4 GetCurrentColor() { int colorIndex = InGame.inGame.shared.curObjectColor; Classification.Colors color = ColorPalette.GetColorFromIndex(colorIndex); return(Classification.ColorVector4(color)); } // end of WayPoint GetActiveColor()
public override bool MatchAction(Reflex reflex, out object param) { param = null; bool match = false; if (reflex.targetSet != null && reflex.targetSet.Param != null) { GameScoredSensor sensor = reflex.Sensor as GameScoredSensor; Classification.Colors color = (Classification.Colors)reflex.targetSet.Param; int curr = 0, prev; Scoreboard.Score score = sensor.GetScore(color); if (score != null) { curr = score.Curr; prev = score.Prev; // If the score changed and jumped across or landed on the trigger score if ((prev != curr) && ((prev < scoreTriggerValue && curr >= scoreTriggerValue) || (prev > scoreTriggerValue && curr <= scoreTriggerValue))) { match = true; } } } return(match); }
public static int GetButtonIdx(Classification.Colors color) { Debug.Assert((int)color >= (int)Classification.ColorInfo.First && (int)color <= (int)Classification.ColorInfo.Last); int retIdx = (int)color - (int)Classification.ColorInfo.First; return((retIdx < 0) ? 0 : ((retIdx >= kNumButtons) ? kNumButtons - 1 : retIdx)); }
} // end of Delete() /// <summary> /// Render spheres /// </summary> /// <param name="camera"></param> public void Render(Camera camera, bool edgesToo) { Vector4 color = rgbColor; // The shadow texture is rendered inverted so // for shadows always render in white. if (InGame.inGame.renderEffects == InGame.RenderEffect.ShadowPass) { color = new Vector4(1, 1, 1, 1); } Debug.Assert(edgePts.Count == 0); Debug.Assert(edgeEdit.Count == 0); Debug.Assert(edgeSelect.Count == 0); // First render the edges. for (int i = 0; i < Edges.Count; i++) { Edge edge = Edges[i]; Vector3 pos0 = edge.Node0.RenderPosition(!edgesToo); Vector3 pos1 = edge.Node1.RenderPosition(!edgesToo); if (Edit || edge.Edit) { edgeEdit.Add(pos0); edgeEdit.Add(pos1); } else if (Select || edge.Select) { edgeSelect.Add(pos0); edgeSelect.Add(pos1); } else { edgePts.Add(pos0); edgePts.Add(pos1); } edge.Render(camera, color, !edgesToo); } if (edgesToo) { Utils.DrawFatLine(camera, edgePts, color); Utils.DrawFatLine(camera, edgeEdit, new Vector4(0.5f, 0.5f, 1.0f, 1.0f)); Utils.DrawFatLine(camera, edgeSelect, new Vector4(1.0f, 0.5f, 0.5f, 1.0f)); } edgePts.Clear(); edgeEdit.Clear(); edgeSelect.Clear(); // Then render the nodes. for (int i = 0; i < Nodes.Count; i++) { Node node = Nodes[i]; node.Render(camera, !edgesToo, color); } } // end of Path Render()
public override void SetColor(Classification.Colors color) { base.SetColor(color); // Apply a twitch to transition the RGBA color to match. // colorRGBA = ColorVector4(color); TwitchManager.Set <Vector4> set = delegate(Vector4 val, Object param) { tail.Color = val; }; TwitchManager.CreateTwitch(tail.Color, Classification.ColorVector4(color), set, 0.1f, TwitchCurve.Shape.EaseInOut); }
public Scoreboard.Score GetScore(Classification.Colors color) { Scoreboard.Score score; if (scores.TryGetValue((int)color, out score)) { return(score); } return(null); }
} // end of Setup() /// <summary> /// c'tor for use when targetting a point in space rather than an object. /// </summary> /// <param name="position"></param> /// <param name="targetPosition"></param> /// <param name="launcher"></param> /// <param name="verbPayload"></param> /// <param name="trackingMode"></param> /// <param name="color"></param> /// <returns></returns> static public CruiseMissile Create( Vector3 position, // Starting position. Vector3 targetPosition, // Location we're trying to hit. GameActor launcher, // Actor that launched this missile. float initialRotation, // GameThing.Verbs verbPayload, int damage, MissileChassis.BehaviorFlags behavior, Classification.Colors color, float desiredSpeed, float missileLifetime, bool wantSmoke) { CruiseMissile cm = NextAvailable(); cm.Setup( position, launcher, initialRotation, verbPayload, damage, behavior, color, desiredSpeed, wantSmoke); //Vector3 forward = Vector3.Normalize(targetPosition - position); //Vector3 side = Vector3.Cross(Vector3.UnitZ, forward); //if (side.LengthSquared() < 0.01f) //{ // side = Vector3.Cross(Vector3.UnitY, forward); //} //side.Normalize(); //Vector3 up = Vector3.Normalize(Vector3.Cross(forward, side)); //Matrix l2w = Matrix.Identity; //l2w.Right = forward; //l2w.Up = up; //l2w.Forward = side; //l2w.Translation = position; //cm.Movement.LocalMatrix = l2w; MissileChassis missileChassis = cm.Chassis as MissileChassis; Vector3 direction = targetPosition - launcher.WorldCollisionCenter; Vector3 delta = Vector3.Normalize(direction); float desiredPitch = (float)(Math.Atan2(delta.Z, new Vector2(delta.X, delta.Y).Length())); missileChassis.PitchAngle = desiredPitch; missileChassis.DeathTime = Time.GameTimeTotalSeconds + missileLifetime * 1.1f; missileChassis.TargetPosition = position + delta * desiredSpeed * missileLifetime * 10f; missileChassis.TargetObject = null; return(cm); } // end of CruiseMissile Create
public static GUIButton GetButton(Classification.Colors color) { int idx = GetButtonIdx(color); if (idx >= 0 && idx < kNumButtons) { return(GetButton(idx)); } return(null); }
public Fireball(Classification.Colors color) { updateObj = new UpdateObj(this); classification = new Classification("fireball", color, Classification.Shapes.Ball, Classification.Tastes.NotApplicable, Classification.Smells.Stinky, Classification.Physicalities.NotApplicable); } // end of Fireball c'tor
/// <summary> /// Sets the color of the actor using a twitch to smooth the transition. /// Don't set this directly on GameThings, use GameThing.SetColor instead. /// </summary> /// <param name="color"></param> public void SetColor(Classification.Colors value) { if (color != value) { color = value; // Twitch ColorRGBA from whatever the current value is toward the new value. TwitchManager.Set <Vector4> set = delegate(Vector4 val, Object param) { colorRGBA = val; }; TwitchManager.CreateTwitch(ColorRGBA, ColorVector4(color), set, 0.25f, TwitchCurve.Shape.EaseInOut); } } // end of SetColor
} // end of ColorPalette GetColorFromIndex() public static int GetIndexFromColor(Classification.Colors color) { int index = 0; switch (color) { case Classification.Colors.Black: index = 0; break; case Classification.Colors.Grey: index = 1; break; case Classification.Colors.White: index = 2; break; case Classification.Colors.Red: index = 3; break; case Classification.Colors.Orange: index = 4; break; case Classification.Colors.Yellow: index = 5; break; case Classification.Colors.Green: index = 6; break; case Classification.Colors.Blue: index = 7; break; case Classification.Colors.Purple: index = 8; break; case Classification.Colors.Pink: index = 9; break; case Classification.Colors.Brown: index = 10; break; } return(index); } // end of ColorPalette GetIndexFromColor()
} // end of ColorPalette Render() public static Classification.Colors GetColorFromIndex(int colorIndex) { Classification.Colors color = Classification.Colors.Red; switch (colorIndex) { case 0: color = Classification.Colors.Black; break; case 1: color = Classification.Colors.Grey; break; case 2: color = Classification.Colors.White; break; case 3: color = Classification.Colors.Red; break; case 4: color = Classification.Colors.Orange; break; case 5: color = Classification.Colors.Yellow; break; case 6: color = Classification.Colors.Green; break; case 7: color = Classification.Colors.Blue; break; case 8: color = Classification.Colors.Purple; break; case 9: color = Classification.Colors.Pink; break; case 10: color = Classification.Colors.Brown; break; } return(color); } // end of ColorPalette GetColorFromIndex()
// c'tor public Path(Classification.Colors color) { this.color = color; rgbColor = Classification.ColorVector4(color); Paths.Add(this); Road = new Road(this); ///This might not be the best place for this. Node.PrevNode.Reset(); } // end of Path c'tor
/// <summary> /// Fire a missile from the given shooter's position at the target position. /// </summary> /// <param name="shooter"></param> /// <param name="targetPos"></param> /// <param name="color"></param> /// <param name="verbPayload"></param> /// <returns></returns> public bool Fire(GameActor shooter, Vector3 targetPos, Classification.Colors color, GameThing.Verbs verbPayload, int damage) { if (numActiveBleeps < kMaxBleeps) { float speed = shooter.BlipSpeed; float time2Live = shooter.BlipRange / speed; Bleep bleep = new Bleep(); bleep.Position = shooter.WorldGlowPosition; bleep.StartHeight = bleep.Position.Z; bleep.Position.Z = shooter.WorldCollisionCenter.Z; bleep.Velocity = Vector3.Normalize(targetPos - bleep.Position) * speed; float vdotv = Vector3.Dot(bleep.Velocity, shooter.Movement.Velocity); if (vdotv > 0) { /// If the bullet is moving the same direction as the shooter, /// add in the shooter's speed in the bullet's direction. /// This will only speed up the bullet, not change it's firing /// direction. vdotv /= bleep.Velocity.LengthSquared(); bleep.Velocity += bleep.Velocity * vdotv; } bleep.Life = bleep.TTL = time2Live; bleep.VerbPayload = verbPayload; bleep.Damage = damage; Vector4 color4 = Classification.ColorVector4(color); /// Brighten up the color a bit. color4.X = MyMath.SmoothStep(0.0f, 1.0f, color4.X); color4.Y = MyMath.SmoothStep(0.0f, 1.0f, color4.Y); color4.Z = MyMath.SmoothStep(0.0f, 1.0f, color4.Z); bleep.Color = new Color(color4); bleep.TTTerraHit = CheckTerrainHit(bleep, speed); if (shooter.ActiveBleeps.Bleeps.Count == 0) { Shooters.Add(shooter); } shooter.ActiveBleeps.Bleeps.Add(bleep); // Increment the number of active bleeps. Without this, on the // current frame we can end up shooting enough new bleeps to // exceed the max. ++numActiveBleeps; return(true); } return(false); }
} // end of CruiseMissile InitSmokeEmitter() public override void SetColor(Classification.Colors color) { // Set the body color. base.SetColor(color); // Also change the smoke color. if (smokeEnabled) { OffsetEmitter oe = attachments[0] as OffsetEmitter; SharedSmokeSource sss = oe.Emitter as SharedSmokeSource; sss.Color = Classification.ColorVector4(color); } } // end of SetColor()
/// <summary> /// Fire a missile from the given shooter's position at the target position. /// </summary> /// <param name="shooter"></param> /// <param name="targetPos"></param> /// <param name="color"></param> /// <param name="verbPayload"></param> /// <returns></returns> public bool Fire(GameActor shooter, GameActor target, Vector3 targetPos, Classification.Colors color) { if (numActiveBeams < kMaxBeams) { float speed = shooter.BeamSpeed; float time2Live = shooter.BeamDist / speed; Beam Beam = new Beam(); Beam.Position = shooter.WorldCollisionCenter; Beam.StartHeight = shooter.WorldCollisionCenter.Z; Beam.Position.Z = shooter.WorldCollisionCenter.Z; // Save out the actor Beam.TargetActor = target; // Raise the height of the target pos slightly to avoid terrain hits targetPos.Z += heightOffSet; Beam.Velocity = Vector3.Normalize(targetPos - Beam.Position) * speed; float vdotv = Vector3.Dot(Beam.Velocity, shooter.Movement.Velocity); if (vdotv > 0) { /// If the bullet is moving the same direction as the shooter, /// add in the shooter's speed in the bullet's direction. /// This will only speed up the bullet, not change it's firing /// direction. vdotv /= Beam.Velocity.LengthSquared(); Beam.Velocity += Beam.Velocity * vdotv; } Beam.Life = Beam.TTL = time2Live; Vector4 color4 = Classification.ColorVector4(color); /// Brighten up the color a bit. color4.X = MyMath.SmoothStep(0.0f, 1.0f, color4.X); color4.Y = MyMath.SmoothStep(0.0f, 1.0f, color4.Y); color4.Z = MyMath.SmoothStep(0.0f, 1.0f, color4.Z); Beam.Color = new Color(color4); Beam.TTTerraHit = CheckTerrainHit(Beam, speed); if (shooter.ActiveBeams.Beams.Count == 0) { Shooters.Add(shooter); } shooter.ActiveBeams.Beams.Add(Beam); return(true); } return(false); }
public static void Reset() { activeTeam = Classification.Colors.NotApplicable; activePlayer = GamePadSensor.PlayerId.Dynamic; activeWinner = false; activeGameOver = false; alphaTeam = 0.0f; alphaWinner = 0.0f; alphaGameOver = 0.0f; timeoutTeam = 0.0; timeoutWinner = 0.0; timeoutGameOver = 0.0; }
/// <summary> /// Get height at position if it is on a road. /// </summary> /// <param name="pos"></param> /// <param name="height"></param> /// <returns></returns> public static bool GetHeight(Vector3 pos, ref float height, ref Classification.Colors color) { bool ret = false; foreach (Path path in paths) { if (path.Road != null) { if (path.Road.GetHeight(pos, ref height)) { color = path.Color; ret = true; } } } return(ret); }
public void FromActor(GameActor actor) { Debug.Assert(!actor.InRecycleBin); position = actor.Movement.Position; orientation = actor.Movement.RotationZ; heightOffset = actor.HeightOffset; color = actor.ClassColor; creatableId = actor.CreatableId; creatableName = actor.DisplayNameNumber; version = actor.Version; // Clone the parameters instead of calling CopyTo so that the creatable flag // is preserved. CopyTo deliberately excludes this this field when copying. parameters = actor.LocalParameters.Clone() as GameActor.TweakableParameters; tintable = true; brain = Brain.DeepCopy(actor.Brain); }
private static void RenderScore(Score score, Classification.Colors color) { SpriteBatch batch = UI2D.Shared.SpriteBatch; Color fore = Classification.XnaColor(color); Color back = fore == Color.Black ? Color.White : Color.Black; string str = score.Labeled ? score.Label + ": " : ""; // <---- Should include label str += score.Curr.ToString(); int width = 8 + (int)ScoreBoardFont().MeasureString(str).X; int x = (int)((float)BokuGame.bokuGame.GraphicsDevice.Viewport.Width - width); int y = y_margin + score.order * ScoreBoardFont().LineSpacing + (int)BokuGame.ScreenPosition.Y; batch.Begin(); TextHelper.DrawStringWithShadow(ScoreBoardFont, batch, x, y, str, fore, back, false); batch.End(); }
} // end of WayPoint GetActiveColor() /// <summary> /// Returns the path nearest the position of the right color. May return null if none exit. /// "Nearest" is defined as the path containing an edge which is nearest to the input point. /// </summary> /// <param name="color"></param> /// <param name="position"></param> /// <returns></returns> public static Path GetNearestPath(Classification.Colors color, Vector3 position) { Path nearestPath = null; float distSquared = float.MaxValue; for (int i = 0; i < Paths.Count; i++) { Path p = Paths[i]; if (p.Color == color || color == Classification.Colors.NotApplicable) { if (p.Edges.Count == 0) { // This path must only have a single node // so check that instead of the edges. Node n = p.Nodes[0]; float dist2 = Vector3.DistanceSquared(n.Position, position); if (dist2 < distSquared) { distSquared = dist2; nearestPath = p; } } else { for (int j = 0; j < p.Edges.Count; j++) { Edge e = p.Edges[j]; float dist2 = e.DistanceSquared(position); if (dist2 < distSquared) { nearestPath = p; distSquared = dist2; } } } } // end if path is the right color. } return(nearestPath); } // end of WayPoint GetNearestPath()
} // end of CruiseMissile Create /// <summary> /// c'tor to use when shooting at a particular object /// </summary> /// <param name="position"></param> /// <param name="targetPosition"></param> /// <param name="targetThing"></param> /// <param name="launcher"></param> /// <param name="verbPayload"></param> /// <param name="trackingMode"></param> /// <param name="color"></param> /// <returns></returns> static public CruiseMissile Create( Vector3 position, // Starting position. GameThing targetThing, // Object we're trying to hit. GameActor launcher, // Actor that launched this missile. float initialRotation, // GameThing.Verbs verbPayload, int damage, MissileChassis.BehaviorFlags behavior, Classification.Colors color, float desiredSpeed, float missileLifetime, bool wantSmoke) { CruiseMissile cm = NextAvailable(); cm.Setup( position, launcher, initialRotation, verbPayload, damage, behavior, color, desiredSpeed, wantSmoke); MissileChassis missileChassis = cm.Chassis as MissileChassis; // Set initial speed taking into account the velocity of the launcher. Vector3 missileVelocity = new Vector3((float)Math.Cos(initialRotation), (float)Math.Sin(initialRotation), 0); float dot = Vector3.Dot(missileVelocity, launcher.Movement.Velocity); missileChassis.Speed = Math.Max(desiredSpeed, dot); missileChassis.DeathTime = Time.GameTimeTotalSeconds + missileLifetime; missileChassis.TargetPosition = targetThing.WorldCollisionCenter; missileChassis.TargetObject = targetThing; return(cm); } // end of CruiseMissile Create
/// <summary> /// This function will Register any objects that should be registered when used by a reflex. /// /// This is used by things like the scores and GUI buttons which only appear onscreen /// when used in an actor's kode. /// </summary> internal void RegisterReflexSupportedObject() { for (int i = 0; i < tasks.Count; ++i) { Task task = tasks[i]; for (int j = 0; j < task.reflexes.Count; ++j) { Reflex reflex = task.reflexes[j] as Reflex; //Register Score Bucket if (reflex.Actuator != null && reflex.Actuator.Categories.Get((int)BrainCategories.DoSetScore)) { ScoreBucket bucket = Modifier.ScoreBucketFromModifierSet(reflex.Modifiers); if (bucket != ScoreBucket.NotApplicable) { Scoreboard.Activate(bucket); } } //Register Color Touch Button foreach (Filter filter in reflex.Filters) { if (filter is GUIButtonFilter) { Classification.Colors eColor = (filter as GUIButtonFilter).color; if (eColor >= (Classification.Colors)Classification.ColorInfo.First && eColor <= (Classification.Colors)Classification.ColorInfo.Last) { Debug.Assert(null != GUIButtonManager.GetButton(eColor)); GUIButtonManager.GetButton(eColor).Active = true; } } } } } }
/// <summary> /// Query the score effect setting of a particular register. /// </summary> /// <param name="color"></param> /// <returns></returns> public static ScoreVisibility GetVisibility(Classification.Colors color) { return(scores[(int)color].Visibility); }
} // end of Update() private void UpdateTouch() { Camera camera = Boku.InGame.inGame.shared.camera; TouchEdit touchEdit = Boku.InGame.inGame.TouchEdit; TouchEdit.TouchHitInfo hitInfo = TouchEdit.HitInfo; // Don't update touchOver if the menus are active. This way the focus state will be preserved. if (!MenusActive && !SliderActive) { //handle color palette interactions if (touchOver.Over && touchOver.Path != null) { //set target color focusColorIndex = ColorPalette.GetIndexFromColor(touchOver.Path.Color); Boku.InGame.ColorPalette.Active = true; //check for touch on a new color Classification.Colors touchColor = Boku.InGame.ColorPalette.GetColorFromTouch(); if ((touchColor != Classification.Colors.None) && (touchOver.Path.Color != touchColor)) { touchOver.Path.Color = touchColor; focusColorIndex = ColorPalette.GetIndexFromColor(touchColor); Foley.PlayColorChange(); Boku.InGame.IsLevelDirty = true; } // For the duration of the color palette handling touch, all touch inputs are deferred. if (Boku.InGame.ColorPalette.HandlingTouch) { return; } } else { //no path selected, hide the palette Boku.InGame.ColorPalette.Active = false; } //clear selections if menu options change if (TouchInput.WasTouched && !Boku.InGame.inGame.TouchEdit.HasNonUITouch()) { touchOver.Clear(); } //adding/adjusting flags may change with update - but we don't want to allow a new path if we entered the update in //one of these modes bool allowNewPath = !touchOver.Adding && !touchOver.Adjusting; touchOver.Update(inGame, camera); // If the user presses the left button while not over anything // start adding a plain path. if (allowNewPath && !touchOver.Adding && !touchOver.Adjusting && TouchGestureManager.Get().TapGesture.WasRecognized&& Boku.InGame.inGame.touchEditUpdateObj.ToolBar.IsButtonActionToggledOn(ToolBar.TouchControls.BrushActionIDs.baNode) && Boku.InGame.inGame.TouchEdit.HasNonUITouch()) { Road.GenIndex = 0; touchOver.NewPath(hitInfo.TerrainPosition, focusColorIndex); } } //We stop adding in touch mode when the add node button is toggled off if (touchOver.Adding && !Boku.InGame.inGame.touchEditUpdateObj.ToolBar.IsButtonActionToggledOn(ToolBar.TouchControls.BrushActionIDs.baNode)) { touchOver.StopAdding(); } // Check to see if any of the menus need activating. if (TouchGestureManager.Get().TouchHoldGesture.WasRecognized&& Boku.InGame.inGame.TouchEdit.HasNonUITouch()) { // The menus may change depending on whether or not the full path is selected. SetUpMenus(); if (touchOver.Over) { if (touchOver.node != null) { nodeMenu.Activate(TouchInput.GetOldestTouch().position); } if (touchOver.edge != null) { edgeMenu.Activate(TouchInput.GetOldestTouch().position); } } else { groundMenu.Activate(TouchInput.GetOldestTouch().position); menuPosition = hitInfo.TerrainPosition; } } if (TouchGestureManager.Get().RotateGesture.IsValidated || TouchGestureManager.Get().PinchGesture.IsValidated || TouchGestureManager.Get().DoubleDragGesture.IsValidated) { //turn off menu if rotating, pinching or double dragging (i.e. terrain manipulation) groundMenu.Deactivate(); nodeMenu.Deactivate(); edgeMenu.Deactivate(); } groundMenu.Update(); nodeMenu.Update(); edgeMenu.Update(); // Change edge direction? if (touchOver.Over && touchOver.Path != null && touchOver.edge != null) { //direction change via double tap if (TouchGestureManager.Get().DoubleTapGesture.WasRecognized) { if (touchOver.ActOnPath) { touchOver.Path.IncDir(); } else { touchOver.edge.IncDir(); } } } // // Set up correct HelpOverlay // if (touchOver.Over) { if (touchOver.ActOnPath) { HelpOverlay.ReplaceTop("MouseEditPathsFocusPath"); } else if (touchOver.node != null) { HelpOverlay.ReplaceTop("MouseEditPathsFocusNode"); } else if (touchOver.edge != null) { HelpOverlay.ReplaceTop("MouseEditPathsFocusEdge"); } } }
/// <summary> /// Set the score effect of a particular register. /// </summary> /// <param name="color"></param> /// <param name="visibility"></param> public static void SetVisibility(Classification.Colors color, ScoreVisibility visibility) { scores[(int)color].Visibility = visibility; }
private void HandleTouchInput(Camera uicamera) { //TODO: this method is now extremely unwieldly - now that we have the basics down, refactor and consolidate the various checks if (GamePadInput.ActiveMode != GamePadInput.InputMode.Touch) { return; } // If the mouse took over from the touch, it should clear any // highlights the touch had going. Boku.InGame.inGame.MouseEdit.Clear(); Camera camera = Boku.InGame.inGame.shared.camera; TouchEdit touchEdit = Boku.InGame.inGame.TouchEdit; TouchEdit.TouchHitInfo hitInfo = null; //keep track of previous focus actor for comparisons this frame GameActor previousFocusActor = FocusActor; hitInfo = TouchEdit.HitInfo; //Check for color pallet hits if (Boku.InGame.ColorPalette.Active && (FocusActor != null) && !actorMenu.Active && !noActorMenu.Active) { Classification.Colors touchColor = Boku.InGame.ColorPalette.GetColorFromTouch(); if ((touchColor != Classification.Colors.None) && (FocusActor.ClassColor != touchColor)) { FocusActor.ClassColor = touchColor; focusColorIndex = ColorPalette.GetIndexFromColor(touchColor); Foley.PlayColorChange(); Boku.InGame.IsLevelDirty = true; } // For the duration of the color palette handling touch, all touch inputs are deferred. if (Boku.InGame.ColorPalette.HandlingTouch) { return; } } bool hasNonUITouch = touchEdit.HasNonUITouch(); bool hasValidTap = TouchGestureManager.Get().TapGesture.WasValidEditObjectTap; touchEdit.DoObject(camera); //check for tap to adjust hit actor if (hasValidTap || TouchGestureManager.Get().DoubleTapGesture.WasRecognized || TouchGestureManager.Get().TouchHoldGesture.WasRecognized || TouchGestureManager.Get().TouchHoldGesture.SlightHoldMade || (TouchGestureManager.Get().DragGesture.IsDragging&& TouchInput.InitialActorHit != null)) { if (hasNonUITouch && TouchGestureManager.Get().DragGesture.IsDragging&& TouchInput.InitialActorHit != null) { FocusActor = TouchInput.InitialActorHit; focusColorIndex = ColorPalette.GetIndexFromColor(FocusActor.Classification.Color); Boku.InGame.ColorPalette.Active = true; } else if (hasNonUITouch && hitInfo.HaveActor) { FocusActor = hitInfo.ActorHit; focusColorIndex = ColorPalette.GetIndexFromColor(FocusActor.Classification.Color); Boku.InGame.ColorPalette.Active = true; } else { FocusActor = null; Boku.InGame.ColorPalette.Active = false; } } //check for double tap on terrain to bring up add actor if (hasNonUITouch && TouchGestureManager.Get().DoubleTapGesture.WasRecognized&& FocusActor == null && !MenusActive && !SliderActive && inGame.editObjectUpdateObj.newItemSelectorShim.State != UIShim.States.Active) { // No actor in focus so activate AddItem menu. Vector2 position = new Vector2(hitInfo.TerrainPosition.X, hitInfo.TerrainPosition.Y); inGame.editObjectUpdateObj.ActivateNewItemSelector(position, true); } //handle dragging an actor if (TouchGestureManager.Get().DragGesture.IsDragging&& TouchInput.InitialActorHit != null && FocusActor != null) { //clear out menu if up actorMenu.Deactivate(); noActorMenu.Deactivate(); //select the focus actor when we start dragging if (selectedActor == null) { // Start draggin if over actor. selectedActor = FocusActor; actorOffset = selectedActor.Movement.Position - hitInfo.TerrainPosition; } Vector3 position = hitInfo.TerrainPosition + actorOffset; selectedActor.Movement.Position = Boku.InGame.SnapPosition(position); // Try and keep the bot directly under the mouse cursor while still being at the correct height. // A possible alternative would be to use the cursor's 2d position for the bot and just have the // bot float at the appropriate height over the cursor. This would allow more exact placement of // bots over terrain but it would mean a visual disconnect between where the cursor is and where // the bot is. There would also be a jump when the bot is first clicked on since the terrain // position of the cursor is most likely further back than the bot's current position. if (hitInfo.VerticalOffset == 0.0f) { Vector3 terrainToCameraDir = hitInfo.TerrainPosition - camera.From; terrainToCameraDir.Normalize(); position = hitInfo.TerrainPosition + terrainToCameraDir * (selectedActor.EditHeight / terrainToCameraDir.Z); selectedActor.Movement.Position = Boku.InGame.SnapPosition(position); } // If the actor is supposed to stay above water, try to enforce that. // This can have some strange visual effects since it forces the actor to // float above where the mouse cursor is but the alternative is to have // actor get dragged under water. if (selectedActor.StayAboveWater) { float waterAlt = Terrain.GetWaterBase(position); if (waterAlt != 0) { position.Z = waterAlt + selectedActor.EditHeight; selectedActor.Movement.Position = Boku.InGame.SnapPosition(position); } } Boku.InGame.IsLevelDirty = true; } else { selectedActor = null; //rules for context menus: // tap + hold -> always bring up menu (terrain or actor accordingly) // double tap -> bring up menu if over an actor (actor only) // single tap -> bring up menu if over an actor that was already selected (actor only) if (hasNonUITouch && (TouchGestureManager.Get().TouchHoldGesture.WasRecognized || (FocusActor != null && TouchGestureManager.Get().DoubleTapGesture.WasRecognized) || (FocusActor != null && hasValidTap && FocusActor == previousFocusActor))) { menuActor = FocusActor; menuCursorPosition = hitInfo.TerrainPosition; // We need to do this repeatedly since the Paste option will // change depending on what's in the cut/paste buffer. SetUpMenus(); if (FocusActor == null) { actorMenu.Deactivate(); noActorMenu.Activate(TouchInput.GetOldestTouch().position); } else { noActorMenu.Deactivate(); actorMenu.Activate(TouchInput.GetOldestTouch().position); // Turn off any thought balloons so they don't clutter the menu. ThoughtBalloonManager.RemoveThoughts(FocusActor); } } // Handle two finger actions. Only enabled when not dragging. if (hasNonUITouch && TouchInput.TouchCount == 2 && selectedActor == null) { PinchGestureRecognizer pinchGesture = TouchGestureManager.Get().GetActiveGesture(TouchGestureType.Pinch, TouchGestureType.Rotate) as PinchGestureRecognizer; if (pinchGesture != null && pinchGesture.IsPinching) { //Debug.WriteLine("Pinching... Scale: "+ pinchGesture.Scale ); DoScaleActor(pinchGesture.DeltaScale, FocusActor); } RotationGestureRecognizer rotationGesture = TouchGestureManager.Get().GetActiveGesture(TouchGestureType.Rotate, TouchGestureType.Pinch) as RotationGestureRecognizer; if (null != rotationGesture && rotationGesture.IsRotating) { DoRotateActor(rotationGesture.RotationDelta, FocusActor); } } } if (TouchGestureManager.Get().RotateGesture.IsValidated || TouchGestureManager.Get().PinchGesture.IsValidated || TouchGestureManager.Get().DoubleDragGesture.IsValidated) { //turn off menu if rotating, pinching or double dragging (i.e. terrain manipulation) actorMenu.Deactivate(); noActorMenu.Deactivate(); } noActorMenu.Update(); actorMenu.Update(); // Support for changing tree types via up/down arrow keys. if (FocusActor != null && FocusActor.Classification.name == "tree") { inGame.editObjectUpdateObj.MakeTreeChange(FocusActor); } // // Figure out help overlay mode. // if (inGame.editObjectUpdateObj.newItemSelectorShim.State == UIShim.States.Active) { // The pie menu is active. HelpOverlay.ReplaceTop("MouseEditAddItemMenu"); } else if (hitInfo != null && hitInfo.HaveActor) { // We have an actor in focus. if (FocusActor != null && FocusActor.Classification.name == "tree") { HelpOverlay.ReplaceTop("MouseEditEditObjectFocusTree"); } else { HelpOverlay.ReplaceTop("MouseEditEditObjectFocus"); } } }
/// <summary> /// Set the score persist setting of a particular register. /// </summary> /// <param name="color"></param> /// <param name="visibility"></param> public static void SetPersistFlag(Classification.Colors color, bool persist) { scores[(int)color].PersistFlag = persist; }
/// <summary> /// Query the score persist setting of a particular register. /// </summary> /// <param name="color"></param> /// <returns></returns> public static bool GetPersistFlag(Classification.Colors color) { return(scores[(int)color].PersistFlag); }
//Returns the corresponding scoreboard score object by color public static Scoreboard.Score GetScoreboardScore(Classification.Colors color) { return(scores.ContainsKey((int)color) ? scores[(int)color] : null); }