public override void SkillCastBehaviour(CastInfo cast_info) { cast_info.origin_pos += Vector3.up * 1.5f; cast_info.dir = cast_info.end_pos - cast_info.origin_pos; cast_info.dir.Normalize(); GameObject display = Instantiate(skill_display, cast_info.origin_pos + cast_info.dir, Quaternion.identity); SkillInstance instance = display.AddComponent <SkillInstance>(); instance.InitInstance(SkillBehaviour, cast_info); //test Collider[] hit_colliders = Physics.OverlapSphere(instance.transform.position, 2); for (int i = 0; i < hit_colliders.Length; i++) { if (hit_colliders[i].gameObject.tag == "Enemy") { hit_colliders[i].GetComponent <EnemySimple>().Hurt(weapon_dmg.Buffed_value * skill_dmg_mult); } } Destroy(display, 2.5f); }
public override void SkillBehaviour(ref CastInfo cast_info, GameObject instance) { instance.transform.Translate(cast_info.dir * projectile_speed, Space.World); Collider[] hit_colliders = Physics.OverlapSphere(instance.transform.position, effect_area * effect_area_mult); for (int i = 0; i < hit_colliders.Length; i++) { if (hit_colliders[i].gameObject.tag == "Enemy" && !cast_info.hitted_colliders.Contains(hit_colliders[i])) { hit_colliders[i].GetComponent <EnemySimple>().Hurt(weapon_dmg.Buffed_value * skill_dmg_mult); hit_colliders[i].GetComponent <EnemySimple>().PushTowards(cast_info.dir, push_force); cast_info.hitted_colliders.Add(hit_colliders[i]); } } if (Vector3.Distance(cast_info.origin_pos, instance.transform.position) >= (projectile_range * projectile_range_mult)) { Destroy(instance); } }
public override void SkillCastBehaviour(CastInfo cast_info) { GameObject display = Instantiate(skill_display, cast_info.origin_pos, Quaternion.identity); SkillInstance instance = display.AddComponent <SkillInstance>(); instance.transform.localScale = new Vector3(effect_area * effect_area_mult, effect_area * effect_area_mult, effect_area * effect_area_mult); instance.InitInstance(SkillBehaviour, cast_info); //test Collider[] hit_colliders = Physics.OverlapSphere(cast_info.end_pos, effect_area * effect_area_mult); Debug.Log("doing Explosion damage"); for (int i = 0; i < hit_colliders.Length; i++) { if (hit_colliders[i].gameObject.tag == "Enemy") { hit_colliders[i].GetComponent <EnemySimple>().Hurt(weapon_dmg.Buffed_value * skill_dmg_mult); } } Destroy(display, 3); }
public override void SkillBehaviour(ref CastInfo cast_info, GameObject instance) { curr_duration += Time.deltaTime; instance.transform.position = CharacterController.instance.GetPlayerTransform().position; Collider[] hit_colliders = Physics.OverlapSphere(instance.transform.position, effect_area * effect_area_mult); for (int i = 0; i < hit_colliders.Length; i++) { if (hit_colliders[i].gameObject.tag == "Enemy") { hit_colliders[i].GetComponent <EnemySimple>().Hurt((weapon_dmg.Buffed_value * skill_dmg_mult) * Time.deltaTime); hit_colliders[i].GetComponent <EnemySimple>().ApplySlow(slow_magnitude, slow_duration); } } if (curr_duration >= (duration * duration_mult)) { armor.Sum_value -= armor_add_augment; Destroy(instance); is_active = false; } }
public override void SkillCastBehaviour(CastInfo cast_info) { GameObject display = Instantiate(skill_display, cast_info.origin_pos + cast_info.dir, Quaternion.identity); SkillInstance instance = display.AddComponent <SkillInstance>(); instance.transform.localScale = new Vector3(effect_area * effect_area_mult, effect_area * effect_area_mult, effect_area * effect_area_mult); instance.InitInstance(SkillBehaviour, cast_info); //test Collider[] hit_colliders = Physics.OverlapSphere(instance.transform.position, effect_area * effect_area_mult); for (int i = 0; i < hit_colliders.Length; i++) { if (hit_colliders[i].gameObject.tag == "Enemy") { hit_colliders[i].GetComponent <EnemySimple>().Hurt(weapon_dmg.Buffed_value * skill_dmg_mult); hit_colliders[i].GetComponent <EnemySimple>().PushTowards(cast_info.dir, push_force); hit_colliders[i].GetComponent <EnemySimple>().Stun(stun_duration); } } Destroy(display, 2.5f); }
protected override void ReadBody(ByteReader reader) { this.Position = reader.ReadVector3(); this.CasterPosition = reader.ReadVector3(); this.Direction = reader.ReadVector3(); this.Velocity = reader.ReadVector3(); this.StartPoint = reader.ReadVector3(); this.EndPoint = reader.ReadVector3(); this.UnitPosition = reader.ReadVector3(); this.TimeFromCreation = reader.ReadFloat(); this.Speed = reader.ReadFloat(); this.LifePercentage = reader.ReadFloat(); this.TimedSpeedDelta = reader.ReadFloat(); this.TimedSpeedDeltaTime = reader.ReadFloat(); byte bitfield = reader.ReadByte(); this.Bounced = (bitfield & 1) != 0; this.CastInfo = reader.ReadCastInfo(); //TODO: read pad bytes if any(should be 512 byte buffer)? }
public void DoCast() { // There will be no member info if this is an object // tree node (not an object type tree node) CastDialog cd = new CastDialog(_castInfo, ObjectInfo.ObjMemberInfo, _objInfo.Obj); // Returns true if it worked if (!cd.DoShowDialog()) { return; } _castInfo = cd.CastInfo; // Reapply the cast if it exists, since the object is // refreshed whenever the tree if (_castInfo != null && _objInfo.Obj != null) { _castObject = _castInfo.DoCast(_objInfo.Obj); } ObjectValueChanged(); // Reset the detail panel if the cast information changed DetailPanel.Clear(); GetDetailText(); }
public override void SkillCastBehaviour(CastInfo cast_info) { cast_info.end_pos -= Vector3.up * 1.5f; cast_info.dir = cast_info.end_pos - cast_info.origin_pos; cast_info.dir.Normalize(); if (Vector3.Distance(cast_info.end_pos, cast_info.origin_pos) > range) { cast_info.end_pos = cast_info.origin_pos + (cast_info.dir * range); } GameObject display = Instantiate(skill_display, cast_info.origin_pos, Quaternion.identity); SkillInstance instance = display.AddComponent <SkillInstance>(); instance.InitInstance(SkillBehaviour, cast_info); if (!CharacterController.instance.move_controller.StartJump(instance.gameObject)) { Debug.Log("Dash failed"); CharacterController.instance.SpendResource(-cost); Destroy(display); return; } Collider[] hit_colliders = Physics.OverlapCapsule(cast_info.origin_pos, cast_info.end_pos, 1); for (int i = 0; i < hit_colliders.Length; i++) { if (hit_colliders[i].gameObject.tag == "Enemy") { hit_colliders[i].GetComponent <EnemySimple>().Hurt(weapon_dmg.Buffed_value * skill_dmg_mult); } } GameObject trail = Instantiate(dash_trail, cast_info.origin_pos + cast_info.dir, Quaternion.LookRotation(cast_info.dir, Vector3.up)); Destroy(trail, 5); }
/// <summary> /// Convert symbol array/scalar to float or integer constant. /// </summary> /// <param name="item"></param> /// <param name="castInfo"></param> /// <returns></returns> private AType ConvertSymbolConstantToNumber(AType item, CastInfo castInfo) { AType result = AArray.Create(castInfo.ResultingType); string temp = item.asString.PadRight(castInfo.LongestSymbolLength); foreach (char character in temp) { result.AddWithNoUpdate(ConvertToNumber(character, castInfo)); } result.Length = temp.Length; result.Shape = new List<int>() { temp.Length }; result.Rank = 1; return result; }
/// <summary> /// Find the longest symbol in the symbol array. /// </summary> /// <param name="argument"></param> /// <param name="castInfo"></param> private void DetectLongestSymbol(AType argument, CastInfo castInfo) { if (argument.IsArray) { foreach (AType item in argument) { DetectLongestSymbol(item, castInfo); } } else { castInfo.LongestSymbolLength = Math.Max(argument.asString.Length, castInfo.LongestSymbolLength); } }
public void SkillCastBehaviourMod(CastInfo cast_info) { skill_modified.cd_timer = 0; }
internal bool DoShowDialog() { while (true) { if (ShowDialog() != DialogResult.OK) return false; if (_removed) { _castInfo = null; return true; } Type castType = null; try { castType = ReflectionHelper.GetType(_textBox.Text); } catch (Exception ex) { ErrorDialog.Show(ex, StringParser.Parse("${res:ComponentInspector.CastDialog.DetermineTypeOfCastFailedMessage}"), MessageBoxIcon.Error); continue; } if (castType == null) { ErrorDialog.Show(String.Format(StringParser.Parse("${res:ComponentInspector.CastDialog.CannotFindTypeInAssembliesMessage}"), _textBox.Text), StringParser.Parse("${res:ComponentInspector.CastDialog.CannotFindType} ") + _textBox.Text, MessageBoxIcon.Error); continue; } // This throws if there is a problem with casting the // current object try { if (_memberInfo != null) { _castInfo = CastInfo.AddCast(_memberInfo, castType, _rememberCheck.Checked, _currentObj); } else { _castInfo = CastInfo.AddCast(null, castType, false, _currentObj); } } catch (Exception ex) { ErrorDialog.Show(ex, StringParser.Parse("${res:ComponentInspector.CastDialog.TypeIncompatibleMessage}"), MessageBoxIcon.Error); continue; } return true; } }
public override void SkillBehaviour(ref CastInfo cast_info, GameObject instance) { //Instant cast/damage spell void behaviour to prevent warnings }
/// <summary> /// Walk argument array/scalar and convert each item /// with the converter function. /// </summary> /// <param name="argument"></param> /// <param name="castInfo"></param> /// <returns></returns> private AType Walker(AType argument, CastInfo castInfo) { AType result; if (argument.IsArray) { if (argument.Rank == 1 && castInfo.ResultingType == ATypes.ASymbol) { result = castInfo.Converter(argument, castInfo); } else { result = AArray.Create(castInfo.ResultingType); foreach (AType item in argument) { result.Add(Walker(item, castInfo)); } } } else { result = castInfo.Converter(argument, castInfo); } return result; }
/// <summary> /// Convert char constant to float or integer constant. /// </summary> /// <param name="item"></param> /// <param name="castInfo"></param> /// <returns></returns> private static AType ConvertCharacterToNumber(AType item, CastInfo castInfo) { return ConvertToNumber(item.asChar, castInfo); }
public override void SkillBehaviour(ref CastInfo cast_info, GameObject instance) { //Override to aviod default function }
public ScrollGump(CSpellbook book, CSpellInfo info, string textHue, Mobile sender) : base(485, 175) { if (info == null || book == null || !CSS.Running) { return; } m_Info = info; m_Book = book; m_TextHue = textHue; m_CastInfo = new CastInfo(info.Type, info.School); Closable = true; Disposable = true; Dragable = true; Resizable = false; AddPage(0); AddBackground(0, 0, 200, 265, 9380); if (info.Name != null) { AddHtml(30, 3, 140, 20, String.Format("<basefont color=#{0}><center>{1}</center></font>", textHue, info.Name), false, false); } AddButton(30, 40, info.Icon, info.Icon, 3, GumpButtonType.Reply, 0); AddButton(90, 40, 2331, 2338, 1, GumpButtonType.Reply, 0); //Cast AddLabel(120, 38, 0, "Cast"); //AddButton( 90, 65, 2338, 2331, 2, GumpButtonType.Reply, 0 ); //Scribe //AddLabel( 120, 63, 0, "Scribe" ); //Info string InfoString = ""; if (info.Desc != null) { InfoString += String.Format("<basefont color=black>{0}</font><br><br>", info.Desc); } if (info.Regs != null) { string[] Regs = info.Regs.Split(';'); InfoString += String.Format("<basefont color=black>Reagents :</font><br><basefont color=#{0}>", textHue); foreach (string r in Regs) { InfoString += String.Format("-{0}<br>", r.TrimStart()); } InfoString += "</font><br>"; } if (info.Info != null) { string[] Info = info.Info.Split(';'); InfoString += String.Format("<basefont color=#{0}>", textHue); foreach (string s in Info) { InfoString += String.Format("{0}<br>", s.TrimStart()); } InfoString += "</font><br>"; } AddHtml(30, 95, 140, 130, InfoString, false, true); //End Info #region CastInfo if (CentralMemory.Running) { m_CastCommandModule = (CastCommandsModule)CentralMemory.GetModule(sender.Serial, typeof(CastCommandsModule)); AddLabel(25, 242, 0, "Key :"); if (m_CastCommandModule == null) { AddTextEntry(70, 242, 100, 20, 0, 5, ""); //Key } else { AddTextEntry(70, 242, 100, 20, 0, 5, m_CastCommandModule.GetCommandForInfo(m_CastInfo)); //Key } AddButton(175, 247, 2103, 2104, 4, GumpButtonType.Reply, 0); //KeyButton } #endregion //CastInfo }
/// <summary> /// Convert char constant to float or integer constant. /// </summary> /// <param name="item"></param> /// <param name="castInfo"></param> /// <returns></returns> private static AType ConvertCharacterToNumber(AType item, CastInfo castInfo) { return(ConvertToNumber(item.asChar, castInfo)); }
/// <summary> /// Convert integer constant to float constant. /// </summary> /// <param name="item"></param> /// <param name="castInfo"></param> /// <returns></returns> private static AType ConvertIntegerToFloat(AType item, CastInfo castInfo) { return(AFloat.Create(item.asInteger)); }
/// <summary> /// Convert number to char constant. /// </summary> /// <param name="item"></param> /// <param name="castInfo"></param> /// <returns></returns> private AType ConvertNumberToCharacter(AType item, CastInfo castInfo) { return(AChar.Create(ConvertNumberConstantToChar(item))); }
public abstract bool OnUse(CastInfo info);
internal override void ReadBody(ByteReader reader) { this.CasterPositionSyncID = reader.ReadInt32(); this.CastInfo = reader.ReadCastInfo(); }
/// <summary> /// Convert float constant to integer constant. /// </summary> /// <param name="item"></param> /// <param name="castInfo"></param> /// <returns></returns> private AType ConvertToInteger(AType item, CastInfo castInfo) { double value = Math.Round(item.asFloat, MidpointRounding.AwayFromZero); if (!(int.MinValue <= value && value <= int.MaxValue && value % 1 == 0)) { throw new Error.Domain(DomainErrorText); } return AInteger.Create((int)value); }
/// <summary> /// Convert integer constant to float constant. /// </summary> /// <param name="item"></param> /// <param name="castInfo"></param> /// <returns></returns> private static AType ConvertIntegerToFloat(AType item, CastInfo castInfo) { return AFloat.Create(item.asInteger); }
public void Update(Vector2 dimensions, Direction facingDir) { const float EPSILON = 0.1f; //the extra amount to cast -> higher values make snapping more noticeable but provide more reliability and better adhesion to moving platforms. var position = transform.position.ToV2(); float heightOffset = dimensions.y / 3; //gives our cast more room to detect the ground (guards cases where we overshoot cuz we are falling quickly) float castLength = dimensions.x * Mathf.Tan(MAX_SLOPE_RADIANS) + heightOffset + EPSILON; //detect slopes of up to the maxDetectionAngle var xOffset = dimensions.x / 2f; var centerPoint = position; var leftPoint = new Vector2(position.x - xOffset, position.y); var rightPoint = new Vector2(position.x + xOffset, position.y); var centerRay = new Ray2D(position + Vector2.up * heightOffset, Vector2.down); var leftRay = new Ray2D(leftPoint + Vector2.up * heightOffset, Vector2.down); var rightRay = new Ray2D(rightPoint + Vector2.up * heightOffset, Vector2.down); CastInfo centerCast = RaycastUtils.Raycast(centerRay, castLength, GameUtils.Layers.GroundMask); CastInfo leftCast = RaycastUtils.Raycast(leftRay, castLength, GameUtils.Layers.GroundMask); CastInfo rightCast = RaycastUtils.Raycast(rightRay, castLength, GameUtils.Layers.GroundMask); CastInfo castInfo = centerCast.didHit ? centerCast : (leftCast.didHit ? leftCast : rightCast); SetGroundedInfo(castInfo, heightOffset + EPSILON, facingDir); CheckForStateChange(); if (followMovingObjects) { ///Cover the case of moving platforms! if (IsGrounded && castInfo.didHit) { position.y = castInfo.hitInfo.point.y; transform.position = position.ToV3(); } ///TODO -> still need handling for horizontal movement of platforms; that is a bit more /// involved though so ill leave it for now until some level design decisions are sorted } #if DEBUG_MODE ///bottom positions on collider DebugUtils.DrawSquare(centerPoint, 0.035f, Color.yellow); DebugUtils.DrawSquare(leftPoint, 0.035f, Color.yellow); DebugUtils.DrawSquare(rightPoint, 0.035f, Color.yellow); if (centerCast.didHit) { DebugUtils.DrawSquare(centerCast.hitInfo.point, 0.05f, Color.blue); } if (leftCast.didHit && rightCast.didHit) { DebugUtils.DrawConnection(leftCast.hitInfo.point, rightCast.hitInfo.point, Color.blue, Color.blue, 0.05f); } else if (leftCast.didHit) { DebugUtils.DrawSquare(leftCast.hitInfo.point, 0.05f, Color.blue); } else if (rightCast.didHit) { DebugUtils.DrawSquare(rightCast.hitInfo.point, 0.05f, Color.blue); } DebugUtils.DrawArrow(centerRay.origin, centerRay.GetPoint(castLength), Color.red, 0.1f); DebugUtils.DrawArrow(leftRay.origin, leftRay.GetPoint(castLength), Color.red, 0.1f); DebugUtils.DrawArrow(rightRay.origin, rightRay.GetPoint(castLength), Color.red, 0.1f); DebugUtils.DrawArrow(position, position + GroundSlope * xOffset * 1.5f, Color.green, 0.1f); if (castInfo.didHit) { DebugUtils.DrawSquare(castInfo.hitInfo.point, 0.1f, Color.magenta); } #endif }
/// <summary> /// Convert char to float or integer constant. /// </summary> /// <param name="character"></param> /// <param name="castInfo"></param> /// <returns></returns> private static AType ConvertToNumber(char character, CastInfo castInfo) { int number = (int)character; AType result = (castInfo.ResultingType == ATypes.AInteger) ? result = AInteger.Create(number) : result = AFloat.Create(number); return result; }
public void DoCast() { // There will be no member info if this is an object // tree node (not an object type tree node) CastDialog cd = new CastDialog(_castInfo, ObjectInfo.ObjMemberInfo, _objInfo.Obj); // Returns true if it worked if (!cd.DoShowDialog()) return; _castInfo = cd.CastInfo; // Reapply the cast if it exists, since the object is // refreshed whenever the tree if (_castInfo != null && _objInfo.Obj != null) { _castObject = _castInfo.DoCast(_objInfo.Obj); } ObjectValueChanged(); // Reset the detail panel if the cast information changed DetailPanel.Clear(); GetDetailText(); }
// castInfo is an existing CastInfo if any, currentObj is // the current value to be cast. We will try the cast with // this value to make sure its possible before accepting the // new cast. internal CastDialog(CastInfo castInfo, MemberInfo member, Object currentObj) : base(!INCLUDE_BUTTONS) { _memberInfo = member; _castInfo = castInfo; _currentObj = currentObj; Activated += new EventHandler(ActivateHandler); if (_memberInfo != null) Text = StringParser.Parse("${res:ComponentInspector.CastDialog.CastForTitle} ") + _memberInfo.ToString(); else Text = StringParser.Parse("${res:ComponentInspector.CastDialog.CastTitle}"); Width = 400; Height = 170; // Panel for dialog contents Panel panel = new Panel(); panel.Dock = DockStyle.Top; Controls.Add(panel); if (_memberInfo != null) { _rememberCheck = new CheckBox(); _rememberCheck.Dock = DockStyle.Top; _rememberCheck.Text = StringParser.Parse("${res:ComponentInspector.CastDialog.RememberCastCheckBox}"); if (_castInfo != null) _rememberCheck.Checked = _castInfo.Perm; else _rememberCheck.Checked = true; panel.Controls.Add(_rememberCheck); } // Spacing Label l = new Label(); l.Dock = DockStyle.Top; panel.Controls.Add(l); // Panel for textbox Panel textPanel = new Panel(); textPanel.Dock = DockStyle.Top; panel.Controls.Add(textPanel); _textBox = new TextBox(); _textBox.Dock = DockStyle.Fill; if (_castInfo != null) _textBox.Text = _castInfo.CastType.FullName; textPanel.Controls.Add(_textBox); l = new Label(); l.Dock = DockStyle.Left; l.Text = StringParser.Parse("${res:ComponentInspector.CastDialog.CastToLabel} "); l.AutoSize = true; textPanel.Controls.Add(l); textPanel.Height = _textBox.Height; Panel bp = new Panel(); bp.Dock = DockStyle.Bottom; l = new Label(); l.Dock = DockStyle.Fill; bp.Controls.Add(l); Button ok = Utils.MakeButton(StringParser.Parse("${res:Global.OKButtonText}")); ok.Dock = DockStyle.Right; ok.DialogResult = DialogResult.OK; AcceptButton = ok; bp.Controls.Add(ok); if (_castInfo != null) { Button b = Utils.MakeButton(StringParser.Parse("${res:Global.RemoveButtonText}")); b.Dock = DockStyle.Right; b.DialogResult = DialogResult.OK; b.Click += new EventHandler(RemoveClick); bp.Controls.Add(b); } Button cancel = Utils.MakeButton(StringParser.Parse("${res:Global.CancelButtonText}")); cancel.Dock = DockStyle.Right; cancel.DialogResult = DialogResult.Cancel; bp.Controls.Add(cancel); bp.Height = Utils.BUTTON_HEIGHT; Controls.Add(bp); }
/// <summary> /// If argument is: /// - char we clone it. /// - null then we return char null. /// - symbol then we use Unpack nonscalar function. /// - null or symbol we just clone it. /// - float or integer we use ConvertToCharConstant function. /// </summary> /// <param name="argument"></param> /// <returns></returns> private AType CharCase(AType argument) { AType result; CastInfo castInfo = new CastInfo(ATypes.AChar); switch (argument.Type) { case ATypes.AChar: result = argument.Clone(); break; case ATypes.ANull: result = Utils.ANull(ATypes.AChar); break; case ATypes.ASymbol: result = MonadicFunctionInstance.Unpack.Execute(argument); break; case ATypes.AInteger: case ATypes.AFloat: castInfo.Converter = new Converter(ConvertNumberToCharacter); result = Walker(argument, castInfo); break; default: throw new Error.Domain(DomainErrorText); } return result; }
// this mode will also ignore the hits only option and just act as if it is true protected void ProcessRCDataConsolidateTo2DMesh(CheckerInfo checkerInfo) { // get the max number of verts // max number of verts will be the number of horizontal casts multiplied by the vertical casts plus 1 more vert for the origin vertex int maxNumberOfVerts = (checkerInfo.horizontalCasts * checkerInfo.verticalCasts) + 1; Vector3[] finalVerts = new Vector3[maxNumberOfVerts]; int[] finalTris = new int[0]; Color[] finalColors = new Color[maxNumberOfVerts]; // bring the vertex position back to the origin instead of being built from the position of the raycast checker // this is done as the view mesh generator is parented to the raycast checker which moves with the attached player // when creating a mesh it will be built around the origin so moving it requires building around the origin and not an world position //Vector3 offsetPosition = this.transform.position; Vector3 offsetPosition = Vector3.zero; // create a list of complete triangles to convert to the final triangles array List <TriangleData> listOfCompleteTriangles = new List <TriangleData>(); // go through all the checker cast infos and add them to the verts // current vertex index will be increased before adding to each vertex id in the array of vertex int currentVertexIndex = 0; // add the origin point vert finalVerts[0] = checkerInfo.castOrigin - offsetPosition; finalColors[0] = toolUserSettings.VertexColorModeDefaultColor; // used for only showing collider hits LastVertInfo lastCheckedVert = new LastVertInfo(); lastCheckedVert.wasHit = false; lastCheckedVert.vertID = 0; // move all the the same height as the cast origin float consolidateHeight = checkerInfo.castOrigin.y; // add all cast hit points as vertexs for (int verticalCastCount = 0; verticalCastCount < checkerInfo.verticalCasts; verticalCastCount++) { for (int horizontalCastCount = 0; horizontalCastCount < checkerInfo.horizontalCasts; horizontalCastCount++) { // check that not passed the end of the max number of verts if (currentVertexIndex >= maxNumberOfVerts) { //Debug.Log("Current vert id is larger than max number of Verts: " + maxNumberOfVerts); break; } // get the cast info that we are checking CastInfo checkingInfo = checkerInfo.castInfos[horizontalCastCount, verticalCastCount]; // if point was a hit if (checkingInfo.HitID != HitID.Miss) { // increase vertex index before updating vert information currentVertexIndex++; // adjust the position by the offset position Vector3 adjustedPosition = checkingInfo.HitPosition - offsetPosition; // move all positions to the same y height adjustedPosition.y = consolidateHeight; // add new vert to the array of verts finalVerts[currentVertexIndex] = adjustedPosition; // set vertex color according to if the cast info was a hit or not // hit player if (checkingInfo.HitID == HitID.HitPlayer) { finalColors[currentVertexIndex] = toolUserSettings.VertexColorModeHitPlayerColor; } // hit object else if (checkingInfo.HitID == HitID.HitObject) { finalColors[currentVertexIndex] = toolUserSettings.VertexColorModeHitObjectColor; } // if there are atleast 3 vertexes already in the list of verts // and the vert checked before this was also a hit // and is atleast the second horizontal cast if (currentVertexIndex >= 2 && lastCheckedVert.wasHit && horizontalCastCount > 0) { // create new triangle data to fill TriangleData newTriangle = new TriangleData(); newTriangle.FirstVertID = 0; newTriangle.SecondVertID = currentVertexIndex - 1; newTriangle.ThirdVertID = currentVertexIndex; // add the new triangle to the list of triangles listOfCompleteTriangles.Add(newTriangle); } // set last checked vert info lastCheckedVert.wasHit = true; lastCheckedVert.vertID = currentVertexIndex; } // point checking was not a hit else { // set the last checked vert info lastCheckedVert.wasHit = false; lastCheckedVert.vertID = 0; // there isnt a vertex created for the miss so will just be set as the origin } } } // check if needing to resize the vertex array // checking the current vertex index will show which was the last array element edited (+1 as arrays start at 0) // if the last array element edited wasnt the end of the array then resize it if (currentVertexIndex < finalVerts.Length) { //Debug.Log("Resizing the final vert array"); // resize to the size of the current vertex index plus 1 Array.Resize(ref finalVerts, currentVertexIndex + 1); Array.Resize(ref finalColors, currentVertexIndex + 1); } // convert complete triangles to the final tris array finalTris = new int[listOfCompleteTriangles.Count * 3]; int currentBaseTriID = 0; foreach (TriangleData triData in listOfCompleteTriangles) { // add all the triangle data to the final tri array finalTris[currentBaseTriID + 0] = triData.FirstVertID; finalTris[currentBaseTriID + 1] = triData.SecondVertID; finalTris[currentBaseTriID + 2] = triData.ThirdVertID; // increase the base tri id currentBaseTriID += 3; } // finally update the mesh UpdateMesh(finalVerts, finalTris, finalColors); }
/// <summary> /// Convert number to char constant. /// </summary> /// <param name="item"></param> /// <param name="castInfo"></param> /// <returns></returns> private AType ConvertNumberToCharacter(AType item, CastInfo castInfo) { return AChar.Create(ConvertNumberConstantToChar(item)); }
// castInfo is an existing CastInfo if any, currentObj is // the current value to be cast. We will try the cast with // this value to make sure its possible before accepting the // new cast. internal CastDialog(CastInfo castInfo, MemberInfo member, Object currentObj) : base(!INCLUDE_BUTTONS) { _memberInfo = member; _castInfo = castInfo; _currentObj = currentObj; Activated += new EventHandler(ActivateHandler); if (_memberInfo != null) { Text = StringParser.Parse("${res:ComponentInspector.CastDialog.CastForTitle} ") + _memberInfo.ToString(); } else { Text = StringParser.Parse("${res:ComponentInspector.CastDialog.CastTitle}"); } Width = 400; Height = 170; // Panel for dialog contents Panel panel = new Panel(); panel.Dock = DockStyle.Top; Controls.Add(panel); if (_memberInfo != null) { _rememberCheck = new CheckBox(); _rememberCheck.Dock = DockStyle.Top; _rememberCheck.Text = StringParser.Parse("${res:ComponentInspector.CastDialog.RememberCastCheckBox}"); if (_castInfo != null) { _rememberCheck.Checked = _castInfo.Perm; } else { _rememberCheck.Checked = true; } panel.Controls.Add(_rememberCheck); } // Spacing Label l = new Label(); l.Dock = DockStyle.Top; panel.Controls.Add(l); // Panel for textbox Panel textPanel = new Panel(); textPanel.Dock = DockStyle.Top; panel.Controls.Add(textPanel); _textBox = new TextBox(); _textBox.Dock = DockStyle.Fill; if (_castInfo != null) { _textBox.Text = _castInfo.CastType.FullName; } textPanel.Controls.Add(_textBox); l = new Label(); l.Dock = DockStyle.Left; l.Text = StringParser.Parse("${res:ComponentInspector.CastDialog.CastToLabel} "); l.AutoSize = true; textPanel.Controls.Add(l); textPanel.Height = _textBox.Height; Panel bp = new Panel(); bp.Dock = DockStyle.Bottom; l = new Label(); l.Dock = DockStyle.Fill; bp.Controls.Add(l); Button ok = Utils.MakeButton(StringParser.Parse("${res:Global.OKButtonText}")); ok.Dock = DockStyle.Right; ok.DialogResult = DialogResult.OK; AcceptButton = ok; bp.Controls.Add(ok); if (_castInfo != null) { Button b = Utils.MakeButton(StringParser.Parse("${res:Global.RemoveButtonText}")); b.Dock = DockStyle.Right; b.DialogResult = DialogResult.OK; b.Click += new EventHandler(RemoveClick); bp.Controls.Add(b); } Button cancel = Utils.MakeButton(StringParser.Parse("${res:Global.CancelButtonText}")); cancel.Dock = DockStyle.Right; cancel.DialogResult = DialogResult.Cancel; bp.Controls.Add(cancel); bp.Height = Utils.BUTTON_HEIGHT; Controls.Add(bp); }
/// <summary> /// If argument is: /// - integer then we clone it. /// - null we return integer null. /// - float then we use ConvertFloatConstantToIntegerConstant function. /// - char we call ConvertCharConstantToNumberConstant function. /// - symbol then we use ConvertSymbolConstantToNumber function. /// </summary> /// <param name="argument"></param> /// <param name="arguments"></param> /// <returns></returns> private AType IntegerCase(AType argument) { AType result; CastInfo castInfo = new CastInfo(ATypes.AInteger); switch (argument.Type) { case ATypes.AInteger: result = argument.Clone(); break; case ATypes.ANull: result = Utils.ANull(ATypes.AInteger); break; case ATypes.AFloat: castInfo.Converter = new Converter(ConvertToInteger); result = Walker(argument, castInfo); break; case ATypes.AChar: castInfo.Converter = new Converter(ConvertCharacterToNumber); result = Walker(argument, castInfo); break; case ATypes.ASymbol: if (!argument.SimpleSymbolArray()) { throw new Error.Type(TypeErrorText); } DetectLongestSymbol(argument, castInfo); castInfo.Converter = new Converter(ConvertSymbolConstantToNumber); result = Walker(argument, castInfo); break; default: throw new Error.Domain(DomainErrorText); } return result; }
private async Task SpeakCastInfo(CastInfo ci) { await SpeechSynthesisService.SpeakOutLoud(ci.Title); }
/// <summary> /// Convert number array/scalar to symbol constant. /// </summary> /// <param name="argument"></param> /// <param name="castInfo"></param> /// <returns></returns> private AType ConvertNumberConstantToSymbolConstant(AType argument, CastInfo castInfo) { StringBuilder builder = new StringBuilder(); if (argument.IsArray) { foreach (AType item in argument) { builder.Append(ConvertNumberConstantToChar(item)); } } else { builder.Append(ConvertNumberConstantToChar(argument)); } return ASymbol.Create(builder.ToString()); }