public MovementTypeTemporaryEffect(MovementType movementType, int duration) { TurnsRemaining = duration; _movementType = movementType; EffectComplete = false; Name = movementType.ToString(); Id = Guid.NewGuid(); }
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { MovementType temp = (MovementType)value; writer.WriteStartObject(); writer.WritePropertyName("value"); serializer.Serialize(writer, temp.ToString()); writer.WriteEndObject(); }
public override string ReturnUnitInfo() { string result = unitName + "\nHP: " + FindDisplayHP().ToString() + "\nCan Capture: " + canCapture.ToString() + "\nMove type: " + MovementType.ToString() + "\nRange: " + minRange.ToString() + "-" + AttackRange.ToString() + "\nMovement range: " + TotalMovementPoints.ToString() + "\n" + description; return(result); }
private void PlayFoley(MovementType movementType, Transform foleyPosition = null) { foreach (FoleyImport import in foleyImports) { if (import.key == foleyType.ToString() + "_" + movementType.ToString()) { if (import.audioObject != null) { import.audioObject.TriggerDirectly(TriggeringAction.StartSound, foleyPosition); } } } }
public override void Update(float deltaTime) { base.Update(deltaTime); #if DEBUG GameViewportControl.debugInfos.Add(string.Format(System.Globalization.CultureInfo.CurrentCulture, "RemoteCharacterController CurrentMovementType[{0}] Acceleration[{1}] Velocity[{2}] Location[{3}] Rotation[{4}] \r\n", MovementType.ToString(), Acceleration.ToString(true), Velocity.ToString(true), Location.ToString(true), TargetActor.Rotation.ToString(true))); #endif }
public static async Task <bool> Move(double amount, MovementType type) { try { var values = new Dictionary <string, string> { { "amount", amount.ToString() }, { "type", type.ToString() } }; var content = new FormUrlEncodedContent(values); return((await Client.PostAsync($"{BackendUrl}/RaspPi/Move", content)).IsSuccessStatusCode); } catch (Exception) { return(false); } }
public static MovementType GetOpposite(this MovementType original) { switch (original) { case MovementType.Down: return(MovementType.Up); case MovementType.Up: return(MovementType.Down); case MovementType.Left: return(MovementType.Right); case MovementType.Right: return(MovementType.Left); default: throw new ArgumentException($"Cant find opposite for {original.ToString()}"); } }
void TryAddSpeedElement(MovementType type) { if (typeSpeedMap[type] >= 0) { if (type != MovementType.Walk) { var leadingText = new TextBlock(); leadingText.Text = $", {type.ToString()} "; leadingText.PreviewMouseDown += speedClearHandler; movementTypePanel.Children.Add(leadingText); } var speedInputBox = new TextBox(); speedInputBox.Text = typeSpeedMap[type].ToString(); speedInputBox.TextChanged += speedChangeHandler; movementTypePanel.Children.Add(speedInputBox); var trailingText = new TextBlock(); trailingText.Text = "ft"; movementTypePanel.Children.Add(trailingText); } }
protected virtual void HandleMovement() { if (moveDirection == Vector2.zero) { return; } switch (type) { case MovementType.MovePosition: rb.MovePosition(rb.position + (moveDirection * moveSpeed * speedFac * Time.fixedDeltaTime)); break; case MovementType.Velocity: rb.velocity = moveDirection * moveSpeed * speedFac; break; //case MovementType.AddForce: default: Debug.LogWarning("Uh oh! Movement type " + type.ToString() + " not supported for: " + name); break; } }
private void UpdateTexts() { _laneLabel.text = "Lane " + (_laneIndex + 1); _interpolationPanel.gameObject.SetActive(_methodType == MethodType.FixedUpdate && _physicsSyncType == PhysicsSyncType.Default); _bodyPanel.gameObject.SetActive(_movementType != MovementType.CharacterController_Move); if (_physicsSyncType == PhysicsSyncType.Default) { _methodText.text = _methodType.ToString(); _methodButton.interactable = true; } else { _methodText.text = MethodType.Update.ToString(); _methodButton.interactable = false; } _bodyText.text = _bodyType.ToString(); _movementText.text = _movementType.ToString().Replace("_", "."); _interpolationText.text = _interpolationType.ToString().Replace("_", " "); }
/// <summary> /// Moves the piece in the Chess board /// </summary> /// <param name="movementType"></param> /// <param name="newX"></param> /// <param name="newY"></param> public override void Move(MovementType movementType, int newX, int newY) { Logger.LogMessage(string.Format("Pawn at current location of {0},{1} is doing a movement type of {2} to {3}, {4}", XCoordinate, YCoordinate, movementType.ToString(), newX, newY), LogLevel.info); try { //first determine if the new position is valid //I am using the chessboard method to determine if the new X and Y are located on the //chess board if (_chessBoard.IsLegalBoardPosition(newX, newY)) { //determine legal moves for move vs capture switch (movementType) { case MovementType.Move: //verify that the x move is correct if (!VerifyXMove(newX)) { Logger.LogMessage("the new x coordinate is incorrect " + newX, LogLevel.error); //don't do the move return; } //verify that the Y move is correct if (!VerifyYMove(newY)) { Logger.LogMessage("the new y coordinate is incorrect " + newY, LogLevel.error); //don't do the move return; } break; //in this case Pawns can only move diagonally case MovementType.Capture: if (!VerifyDiagonalMove(newX, newY)) { Logger.LogMessage("the new x " + newX + " or y coordinate is incorrect " + newY, LogLevel.error); return; } break; case MovementType.Special: if (!VerifySpecialMove(newX, newY)) { Logger.LogMessage("the new x " + newX + " or y coordinate is incorrect " + newY, LogLevel.error); return; } break; default: break; } this.XCoordinate = newX; this.YCoordinate = newY; _chessBoard.Add(this, this.XCoordinate, this.YCoordinate, this.PieceColor); } else { string result = string.Format("Not an acceptable move X: {0} Y: {1}", newX, newY); Logger.LogMessage(result, LogLevel.error); } } catch (Exception ex) { Logger.LogMessage("An exception occurred" + ex.Message, LogLevel.error); } }
protected override Movement createMovement(MovementType type, Entity parent) { int speed = (int)parent.Speed; switch (type) { case MovementType.Bounce: return(new BounceMovement(speed, new Rectangle(50, 50, 1180, 600), parent.Body)); case MovementType.CardinalSouth: return(new CardinalMovement(speed, Movement.CardinalDirection.South)); case MovementType.Keyboard: return(new KeyboardMovement(speed)); case MovementType.None: return(new NoneMovement()); case MovementType.Mirror: return(new MirrorMovement(parent)); case MovementType.Boss: return(new BossMovement(speed)); default: throw new NotImplementedException("StandardMovementFactory: MovementType: " + type.ToString() + "not recognized"); } }
/// <summary> /// Constructor for <see cref="MovementSpriteSheet"/> /// </summary> /// <param name="filePath">The file path of the <see cref="MovementSpriteSheet"/></param> /// <param name="spriteName">The name of the sprite</param> public MovementSpriteSheet(string filePath, string spriteName) { // Loading and setting up graphics for movement sprite sheet movementImages = new Dictionary <MovementType, DirectionalSpriteSheet>(); for (MovementType movementType = MovementType.Walk; movementType <= MovementType.Thrust; ++movementType) { movementImages.Add(movementType, new DirectionalSpriteSheet($"{filePath}/{movementType.ToString()}", $"{spriteName}{movementType.ToString()}", movementNumFrames[movementType])); } }
private void PlayLayer(MovementType movementType, SurfaceLayerType surfaceLayerType, Transform layerPosition = null) { foreach (LayerImport import in layerImports) { if (surfaceLayerType != SurfaceLayerType.None && import.key == surfaceLayerType.ToString() + "_" + movementType.ToString()) { if (import.audioObject != null) { import.audioObject.TriggerDirectly(TriggeringAction.StartSound, layerPosition); } } } }
private void PlayFootstep(MovementType movementType, SurfaceType surfaceType, Transform footPosition = null) { foreach (FootstepImport import in footstepImports) { if (import.key == shoeOrFeetType.ToString() + "_" + surfaceType.ToString() + "_" + movementType.ToString()) { if (import.audioObject != null) { import.audioObject.TriggerDirectly(TriggeringAction.StartSound, footPosition); } } } }
private void setIssueNotes(MovementType Movement, decimal inchesToMove, decimal newFooterHeight) { MovementType MovementOfShift = Movement == MovementType.Up ? MovementType.Down : MovementType.Up; uxIssueNotes.Text = "Shifted details on the MAR " + Movement.ToString() + " by " + inchesToMove.ToString() + " inches by changing the header from " + uxHeaderHeightOG.Text.Trim() + " to " + uxHeaderHeightSug.Text.Trim() + " and the footer from " + uxPageFooterHeightOG.Text.Trim() + " to " + newFooterHeight.ToString("0.000") + ", moving all contents in the footer " + MovementOfShift.ToString() + " by " + inchesToMove.ToString("0.00") + " inches to compensate"; }
public void SetMovement(MovementType movement) { psMovementType = movement; Debug.Log("Setting particle magic shape to " + movement.ToString()); switch (psMovementType) { // case MovementType.Pour: // { // goto case MovementType.Push; // } case MovementType.Push: { var psVol = ps.velocityOverLifetime; psVol.enabled = false; var psLvol = ps.limitVelocityOverLifetime; psLvol.enabled = false; var psFol = ps.forceOverLifetime; psFol.enabled = true; var psNoise = ps.noise; psNoise.enabled = noiseStartEnabled; psNoise.strength = noisyNoise; var psMain = ps.main; psMain.simulationSpace = ParticleSystemSimulationSpace.World; // Don't kill the particles immortalParticleOn = false; break; } case MovementType.Stop: { // psMovementType = MovementType.Stop; initialVelocity = 0; maxVelocity = force * 10f + 10f; force = 0; var psVol = ps.velocityOverLifetime; psVol.enabled = false; var psLvol = ps.limitVelocityOverLifetime; psLvol.enabled = false; var psFol = ps.forceOverLifetime; psFol.enabled = false; var psNoise = ps.noise; if (psMovementType == MovementType.Control || psMovementType == MovementType.Path) { psNoise.enabled = false; } else { psNoise.enabled = true; psNoise.strength = new ParticleSystem.MinMaxCurve(.75f); } var psMain = ps.main; psMain.simulationSpace = ParticleSystemSimulationSpace.World; // Don't kill the particles immortalParticleOn = true; break; } default: { goto case MovementType.Stop; } } }
public void SaveToFile(string filename) { using (FileStream fs = File.Open(filename, FileMode.Create, FileAccess.Write)) { using (XmlWriter writer = XmlWriter.Create(fs)) // This forces the XmlWriter to flush to the file { writer.WriteStartDocument(); writer.WriteStartElement("UnitType"); writer.WriteAttributeString("name", name); writer.WriteAttributeString("maxHealth", XmlConvert.ToString(maxHealth)); writer.WriteAttributeString("attackType", attackType.ToString()); writer.WriteAttributeString("attackStrength", XmlConvert.ToString(attackStrength)); writer.WriteAttributeString("attackRange", XmlConvert.ToString(attackRange)); writer.WriteAttributeString("attackSpeed", XmlConvert.ToString(attackSpeed)); writer.WriteAttributeString("defense", XmlConvert.ToString(defense)); writer.WriteAttributeString("movementType", movementType.ToString()); writer.WriteAttributeString("movementSpeed", XmlConvert.ToString(movementSpeed)); writer.WriteAttributeString("gatherRate", XmlConvert.ToString(gatherRate)); writer.WriteAttributeString("goldCost", XmlConvert.ToString(goldCost)); writer.WriteAttributeString("ironCost", XmlConvert.ToString(ironCost)); writer.WriteAttributeString("manaCrystalsCost", XmlConvert.ToString(manaCrystalsCost)); writer.WriteAttributeString("textureFilename", textureFilename); writer.WriteAttributeString("textureFilename", textureFilename); writer.WriteAttributeString("frameWidth", XmlConvert.ToString(frameWidth)); writer.WriteAttributeString("frameHeight", XmlConvert.ToString(frameHeight)); foreach (var action in actions) { writer.WriteElementString("Action", action.ToString()); } foreach (var spell in spells) { writer.WriteElementString("Spell", spell.ToString()); } int directionIndex = 0; foreach (var direction in new [] { "Right", "Down", "Left", "Up" }) { writer.WriteStartElement("Idle" + direction); foreach (var idleIndex in idleIndices[directionIndex++]) { writer.WriteElementString("Frame", XmlConvert.ToString(idleIndex)); } writer.WriteEndElement(); } directionIndex = 0; foreach (var direction in new[] { "Right", "Down", "Left", "Up" }) { writer.WriteStartElement("Walk" + direction); foreach (var idleIndex in walkIndices[directionIndex++]) { writer.WriteElementString("Frame", XmlConvert.ToString(idleIndex)); } writer.WriteEndElement(); } directionIndex = 0; foreach (var direction in new[] { "Right", "Down", "Left", "Up" }) { writer.WriteStartElement("Attack" + direction); foreach (var idleIndex in attackIndices[directionIndex++]) { writer.WriteElementString("Frame", XmlConvert.ToString(idleIndex)); } writer.WriteEndElement(); } writer.WriteEndElement(); // UnitType writer.WriteEndDocument(); } } }
public static string species(float size, float weirdChance = 0, float dietChance = 0, AttackType attType = AttackType.Null, DefenceType defType = DefenceType.Null, MovementType movType = MovementType.Null, Targets targets = Targets.Null, float speed = 1, int complexity = 0) { //TODO: Come up with a name-generating system. string result = ""; DietType Diet; if(weirdChance == 0){ weirdChance = Random.value; } if(dietChance == 0){ dietChance = Random.value; } result += "Fish "; if(dietChance >= .85){ result += DietType.Omnivore.ToString(); Diet = DietType.Omnivore; } else if(dietChance >= .65){ result += DietType.Carnivore.ToString(); Diet = DietType.Carnivore; } else{ result += DietType.Herbivore.ToString(); Diet = DietType.Herbivore; } result += " "; if(weirdChance >= 0.9f){ if(Random.value >= 0.5){ //Debug.Log("Flounder"); result += (Random.Range(1f, 1.7f)*size + " "); result += (Random.Range(0.3f, 0.6f)*size + " "); result += (Random.Range(1f, 1.7f)*size + " "); } else{ //Debug.Log ("Sunfish"); result += (Random.Range(0.3f, 0.6f)*size + " "); result += (Random.Range(1.6f, 4.5f)*size + " "); result += (Random.Range(0.8f, 1.7f)*size + " "); } } else{ result += (Random.Range(0.8f, 1.2f)*size + " "); result += (Random.Range(0.8f, 1.2f)*size + " "); result += (Random.Range(0.8f, 1.2f)*size + " "); } if(attType==AttackType.Null){ attType = determineAttack(Diet); } result += attType.ToString() + " "; if(defType==DefenceType.Null){ defType = determineDefence(Diet); } result += defType.ToString() + " "; if(movType==MovementType.Null){ movType = determineMovement(); } result += movType.ToString() + " "; if(targets==Targets.Null){ targets = determineTargets(size, Diet, attType); } result += targets.ToString() + " "; //TODO:Generate Speed result += (speed); result += addMods(complexity); return result; }
public MovementType Move(MovementType _movType) { _movType = MovementType.AI; Console.Write("Me muevo a través de " + _movType.ToString()); return(_movType); }
public void ExecuteFixedUpdate(MoveInput moveInput) { StateData currentState; List <ContactPoint> wallPoints; ManageCollisions(contactPoints, moveInput, out currentState, out wallPoints); ManageHeight(currentState); MovementType movementType = GetMovementType(currentState); Vector3 acceleration, gravity; float friction; switch (movementType) { case MovementType.GROUNDED: GroundedMovement(ref currentState, lastState, out acceleration, out gravity, out friction); break; case MovementType.AIRBORNE: AirborneMovement(ref currentState, out acceleration, out gravity, out friction); break; case MovementType.SWIMMING: WaterMovement(ref currentState, out acceleration, out gravity, out friction); break; case MovementType.LADDER: LadderMovement(ref currentState, out acceleration, out gravity, out friction); break; default: throw new UnityException("Unsupported MovementType \"" + movementType.ToString() + "\""); } if (Input.GetKey(KeyCode.R)) { currentState.velocityComesFromMove = true; } ProjectOnAllSolidAndNearSolidObjects(ref acceleration, wallPoints); rb.velocity += (acceleration + gravity) * Time.fixedDeltaTime; currentState.outgoingVelocity = rb.velocity; currentState.outgoingOwnVelocity = GetRelativeVelocity(rb.velocity, currentState.surfacePoint); //TODO refactor to take currentState instead of just surfacePoint col.material.staticFriction = friction; col.material.dynamicFriction = friction; //do it after saving the state to not factor into own velocity and stuff if (movementType == MovementType.GROUNDED && currentState.onValidGround) { float slopeLerpFactor = GetSlopeLerpFactor(currentState); //reminder : 0 = walkable, 1 = not walkable float inputLerpFactor = currentState.moveInput.directionalInput.magnitude; //if input, then no sliding float resultLerpFactor = slopeLerpFactor * (1f - inputLerpFactor); resultLerpFactor = Mathf.Pow(resultLerpFactor, 0.333f); Vector3 slopeAccel = Vector3.ProjectOnPlane(Physics.gravity, currentState.surfacePoint.normal) * resultLerpFactor; rb.velocity += slopeAccel * Time.fixedDeltaTime; } debugInfo = "vFromMove? : " + currentState.velocityComesFromMove.ToString() + "\n"; debugInfo += movementType.ToString() + "\n"; if (currentState.onGround) { debugInfo += currentState.surfacePoint.angle + "°\n"; debugInfo += "valid? : " + currentState.onValidGround; } Quaternion gravityRotation = GetGravityRotation(Physics.gravity, rb.transform.up, rb.transform.forward); Quaternion newRotation = Quaternion.RotateTowards(rb.transform.rotation, gravityRotation, gravityTurnDegreesPerSecond * Time.fixedDeltaTime); rb.MoveRotation(newRotation); //save and/or reset fields lastState = currentState; contactPoints.Clear(); canSwim = false; //needs to be reset as it is done in triggerstay }