private void cmbBoxObjectForm_SelectedIndexChanged(object sender, EventArgs e) { if (cmbBoxObjectForm.SelectedIndex == 0) { objectShape = ObjectShape.Circle; } else if (cmbBoxObjectForm.SelectedIndex == 1) { objectShape = ObjectShape.Triangle; } else if (cmbBoxObjectForm.SelectedIndex == 2) { objectShape = ObjectShape.Rectangle; } else if (cmbBoxObjectForm.SelectedIndex == 3) { objectShape = ObjectShape.Image; tmrObject.Stop(); using (OpenFileDialog dlg = new OpenFileDialog()) { //dlg.ShowDialog(); if (dlg.ShowDialog() == DialogResult.OK) { img = new Bitmap(dlg.FileName); } } tmrObject.Start(); } }
public static void SafeDestroy(ObjectShape obj) { if (obj != null) { Destroy(obj.gameObject); } }
/// <summary> /// 物理エンジンの処理を行う /// </summary> /// <returns>状態(-1:何らかの不具合)</returns> public static int MainOperation(double spd) { m_world.Step((float)(timeStep * spd), velocityIterations, positionIterations); ObjectShape.Operation(); return(0); }
public static void Init() { ObjectShape.Init(); Physics.Init(); DrawGameMain.Init(); DX.SRand(DateTime.Now.Millisecond); }
public Rope(Rectangle rect, Texture2D tex, ObjectShape Shape, bool IsHazardous, bool gravity) : base(rect, tex, Shape) { isHazardous = IsHazardous; hasGravity = gravity; hasNinja = false; isReleasing = false; }
/// <summary> /// Simple constructor of a motionless platform. /// </summary> /// <param name="rect">Position and size of the platform.</param> /// <param name="Velocity">Vector2: initial velocity of the platform.</param> /// <param name="tex">Texture2D: texture for the platform.</param> /// <param name="Shape">ObjectShape: shape of the platform.</param> /// <param name="IsHazardous">boolean: Platform is hazardous.</param> /// <param name="gravity">boolen: Platform is affected by gravity.</param> public Platform(Rectangle rect, int textureIndex, ObjectShape Shape, bool IsHazardous, bool gravity) : base(rect, textureArray[textureIndex], Shape) { isHazardous = IsHazardous; hasGravity = gravity; base.isTiled = true; patrol = null; suspendRopes = new List<SuspendRope>(); }
public static void Operation() { if (operation.GetKeyFrame(DX.KEY_INPUT_Z) == 1) { main.FuncState = main.GAMEINIT; } if (operation.GetKeyFrame(DX.KEY_INPUT_W) % 2 == 1) { DrawGameMain.PanningScreen(0, -5); } if (operation.GetKeyFrame(DX.KEY_INPUT_S) % 2 == 1) { DrawGameMain.PanningScreen(0, 5); } if (operation.GetKeyFrame(DX.KEY_INPUT_D) % 2 == 1) { DrawGameMain.PanningScreen(5, 0); } if (operation.GetKeyFrame(DX.KEY_INPUT_A) % 2 == 1) { DrawGameMain.PanningScreen(-5, 0); } if (operation.GetKeyState(DX.KEY_INPUT_C) == 1) { GameSpeed = 0.25; } else { GameSpeed = 1; } if (operation.GetKeyFrame(DX.KEY_INPUT_X) == 1) { Vec2[] vec = new Vec2[3 + DX.GetRand(3)]; //vec = new Vec2[4]; for (int i = 0; i < vec.Length; i++) { vec[i] = new Vec2((float)System.Math.Cos(main.Angle(360 / vec.Length * i)), (float)System.Math.Sin(main.Angle(360 / vec.Length * i))); } ObjectShape.BornObject(new Vec2(6.5f, 0.5f), main.Angle(0), new Vec2(), 1, vec); //if (operation.GetFrame() % 60 == 0) // ObjectShape.BornObject(new Vec2(6.5f, 0.5f), main.Angle(45), 1, new Vec2[] { new Vec2(-1, 0), new Vec2(0, -1), new Vec2(1, 0), new Vec2(0, 1) }); //else // ObjectShape.BornObject(new Vec2(6.5f, 0.5f), main.Angle(-90), 1, new Vec2[] { new Vec2(0, (float)-System.Math.Sqrt(3)), new Vec2(0, 0), new Vec2(-1, 0) }); } player.Input input = new player.Input(); player.Player.PlayerOperation(input); Physics.MainOperation(gamespeed); }
public WorldObject(Vector2 Pos, Vector2 Velocity, Vector2 Size, Texture2D tex, ObjectShape Shape) { pos = Pos; velocity = Velocity; size = Size; positionMask = PositionState.NotSet; texture = tex; shape = Shape; rotationAngle = 0.0f; }
public MainForm() { InitializeComponent(); this.polygonForm = new PolygonForm(this); objectShape = ObjectShape.Circle; foreach (Control pan in Menu.Controls) { if (pan is Panel) { foreach (Control lab in pan.Controls) { if (lab is Label) { performSlideDown[(Label)lab] = false; } } menuPanels.Add((Panel)pan); } } pnlStartColor = pnlStart.BackColor; foreach (Panel control in this.Controls) { control.MouseDown += new MouseEventHandler(panel_MouseDown); control.MouseUp += new MouseEventHandler(panel_MouseUp); control.MouseMove += new MouseEventHandler(panel_MouseMove); } fieldHeight = Field.Height; fieldWidth = Field.Width; rnd = new Random(); x = rnd.Next(0, fieldWidth - figureHeight); y = rnd.Next(0, fieldHeight - figureWidth); direction = (Direction)rnd.Next(0, 4); moveDist = 1; Menu.AutoScroll = false; Menu.HorizontalScroll.Enabled = false; Menu.HorizontalScroll.Visible = false; Menu.HorizontalScroll.Maximum = 0; Menu.AutoScroll = true; cmbBoxObjectForm.SelectedIndex = 0; SetDefaultValues(); }
public Enemy(Rectangle rect, Texture2D tex, string name, ObjectShape Shape, int vr) : base(rect, tex, Shape) { shoots = true; visionrange = vr; projectiles = new List<Projectile>(); EnemyName = name; state = LifeState.Alive; actionState = EnemyActionState.Standing; RunTextures = new List<Texture2D>(); AttackTextures = new List<Texture2D>(); }
//private static Texture2D[] textureArray; /// <summary> /// Constructor /// </summary> /// <param name="rect"></param> /// <param name="Velocity"></param> /// <param name="tex"></param> /// <param name="Shape"></param> public Enemy(Rectangle rect, Texture2D tex, string name, ObjectShape Shape) : base(rect, tex, Shape) { shoots = false; projectileTexture = null; EnemyName = name; state = LifeState.Alive; actionState = EnemyActionState.Standing; RunTextures = new List<Texture2D>(); AttackTextures = new List<Texture2D>(); }
private void SetDefaultValues() { pen_R = 0; pen_G = 170; pen_B = 0; brush_R = 11; brush_G = 123; brush_B = 123; figureHeight = 100; figureWidth = 100; trkBarBG_Red.Value = Field.BackColor.R; trkBarBG_Blue.Value = Field.BackColor.B; trkBarBG_Green.Value = Field.BackColor.G; txtBoxBGColor_Red.Text = trkBarBG_Red.Value.ToString(); txtBoxBGColor_Blue.Text = trkBarBG_Blue.Value.ToString(); txtBoxBGColor_Green.Text = trkBarBG_Green.Value.ToString(); trkBarObject_Red.Value = brush_R; trkBarObject_Blue.Value = brush_B; trkBarObject_Green.Value = brush_G; txtBoxObjectColor_Red.Text = brush_R.ToString(); txtBoxObjectColor_Blue.Text = brush_B.ToString(); txtBoxObjectColor_Green.Text = brush_G.ToString(); trkBarObjectBorderColor_Red.Value = pen_R; trkBarObjectBorderColor_Blue.Value = pen_B; trkBarObjectBorderColor_Green.Value = pen_G; txtBoxObjectBorderColor_Red.Text = pen_R.ToString(); txtBoxObjectBorderColor_Blue.Text = pen_B.ToString(); txtBoxObjectBorderColor_Green.Text = pen_G.ToString(); Field.BackColor = Color.FromArgb(25, 87, 128); moveDist = 1; trkBarSpeed.Value = 1; trkBarWidth.Value = figureWidth; trkBarHeight.Value = figureHeight; objectShape = ObjectShape.Circle; points[0] = new Point(x, y); points[1] = new Point(x + figureWidth, y); points[2] = new Point(x + figureWidth / 2, y - figureHeight); }
/// <summary> /// Game World Constructor. /// </summary> /// <param name="rect">Rectangle in which to draw this object.</param> /// <param name="vel">Velocity this object initially moves with.</param> /// <param name="tex">Texture with which to draw this object.</param> /// <param name="shape">Shape of this object for collision purposes.</param> public WorldObject(Rectangle rect, Texture2D tex, ObjectShape newShape) : base(rect, tex) { rotationAngle = 0.0f; lastUpdated = 0; positionMask = PositionState.NotSet; velocity = Vector2.Zero; drawStyle = WorldObjectDrawStyle.StretchToFit; collisionRect = drawRect; shape = newShape; boundObjects = new LinkedList<WorldObject>(); hasGravity = false; }
public Enemy(Rectangle rect, int type, ObjectShape Shape, int vr, int projectileNum) : base(rect, null, Shape) { myType = (EnemyType) type; visionrange = vr; state = LifeState.Alive; actionState = EnemyActionState.Standing; if (vr == 0) { shoots = false; projectileTexture = null; projectiles = null; } else { shoots = true; projectileTexture = ProjectileTextures[0]; projectiles = new List<Projectile>(); } }
public void GenerateMap() { foreach (var grideCell in GrideCells) { Util.SafeDestroy(grideCell.objectShape); } grideCells.Clear(); for (int i = 0; i < horCount; i++) { for (int j = 0; j < verCount; j++) { GrideCell cell = new GrideCell(i, j); cell.pos = startCornor + new Vector3(cell.x * cellUnit, cell.y * cellUnit, 0) + new Vector3((i + 1) * space, (j + 1) * space, 0); GameObject obj = Instantiate(target.gameObject, cell.pos, Quaternion.identity); obj.transform.SetParent(canvasParent); ObjectShape objectShape = obj.GetComponent <ObjectShape>(); objectShape.grideCell = cell; cell.SetObjctShade(objectShape); objectShape.SetValue(Random.Range(1, 5).ToString()); grideCells.Add(cell); } } }
private static void DrawShape() { for (int i = 0; i < ObjectShape.GetCount(); i++) { ObjectShape obj = ObjectShape.GetObject(i); if (obj != null) { Vec2[] vec = obj.GetDrawPos(Scale); for (int j = 0; j < vec.Length; j++) { int p1 = j + 1; if (j == vec.Length - 1) { p1 = 0; } DX.DrawLine((int)vec[j].X, (int)vec[j].Y, (int)vec[p1].X, (int)vec[p1].Y, 0xffffff); DX.DrawString((int)vec[j].X, (int)vec[j].Y, "" + j, 0xffffff); } } } return; }
/// <summary> /// Simple constructor of a motionless platform. /// </summary> /// <param name="rect">Position and size of the platform.</param> /// <param name="Velocity">Vector2: initial velocity of the platform.</param> /// <param name="tex">Texture2D: texture for the platform.</param> /// <param name="Shape">ObjectShape: shape of the platform.</param> /// <param name="IsHazardous">boolean: Platform is hazardous.</param> /// <param name="gravity">boolen: Platform is affected by gravity.</param> public Platform(Rectangle rect, Texture2D drawTex, ObjectShape Shape, bool IsHazardous, bool gravity) : base(rect, drawTex, Shape) { isHazardous = IsHazardous; hasGravity = gravity; patrol = null; suspendRopes = new List<SuspendRope>(); }
public virtual void Select(ObjectShape obj) { }
/// <summary> /// Constructor /// </summary> /// <param name="rect"></param> /// <param name="Velocity"></param> /// <param name="tex"></param> /// <param name="Shape"></param> public Enemy(Rectangle rect, int type, ObjectShape Shape) : this(rect, type, Shape, 0, 0) { }
/// <summary> /// Registers multiple search fields for a given object shape. /// </summary> /// <param name="shape">Object shape.</param> /// <exception cref="System.ArgumentNullException"><paramref name="shape">shape</paramref> is null.</exception> public void RegisterMultipleFields(ObjectShape shape) { if (shape == null) throw new ArgumentNullException("shape"); else RegisterMultipleFieldsInternal(shape, true); }
public abstract void Draw(ObjectShape obj);
void DrawTxtFld(string txt, int x, int y, int width, int height, MprStlTxt stlTxt, ObjectShape shape, MprStlRect stlRect, MprStlEllp stlEllp) { if (shape == ObjectShape.Rectangle) { DrawRect(x, y, width, height, stlRect); } else { DrawEllp(x, y, width, height, stlEllp); } DrawTxt(txt, x, y, width, height, stlTxt); }
/// <summary> /// Registers multiple search fields for a given object shape. /// </summary> /// <param name="shape">Object shape.</param> /// <param name="updateIndexes">Value indicating whether to update indexes.</param> /// <exception cref="System.ArgumentNullException"><paramref name="shape">shape</paramref> is null.</exception> private void RegisterMultipleFieldsInternal(ObjectShape shape, bool updateIndexes) { string[] nameSearchableProperties = { "Id", "Name", "Description" }; if (shape != null) { RegisterMultipleFieldsInternal(shape.Properties, false); foreach (ObjectProperty p in shape.Properties.Where(p => p != null && !string.IsNullOrEmpty(p.Name) && nameSearchableProperties.Any(sp => string.Compare(sp, p.Name, StringComparison.InvariantCultureIgnoreCase) == 0))) { RegisterFieldInternal(p, shape.Name, false); } if (updateIndexes) UpdateIndexes(); } }
public bool CompareValue(ObjectShape other) { return(string.Equals(GetValue(), other.GetValue())); }
/// <summary> /// Game World Constructor. /// </summary> /// <param name="rect">Rectangle in which to draw this object.</param> /// <param name="vel">Velocity this object initially moves with.</param> /// <param name="tex">Texture with which to draw this object.</param> /// <param name="shape">Shape of this object for collision purposes.</param> public WorldObject(Rectangle rect, Texture2D tex, ObjectShape newShape) : base(rect, tex) { defaultInit(); shape = newShape; }
public Doodad(Rectangle rect, int textureIndex, ObjectShape Shape) : base(rect, textureArray[textureIndex], Shape) { }
public SuspendRope(Rectangle rect, Texture2D tex, ObjectShape Shape, bool IsHazardous, bool gravity) : base(rect, tex, Shape) { isHazardous = IsHazardous; hasGravity = gravity; }
public void SetObjctShade(ObjectShape objectShape) { this.objectShape = objectShape; }