-
-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathSampleObject.cs
More file actions
96 lines (83 loc) · 3.38 KB
/
Copy pathSampleObject.cs
File metadata and controls
96 lines (83 loc) · 3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.PerformanceData;
using System.Runtime.CompilerServices;
using System.Text;
using System.Windows.Forms;
using System.Xml.Serialization;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using MonoGame.Extended.Sprites;
using MonoGame.Extended.TextureAtlases;
using SimplexCore;
using SimplexIde;
using SimplexResources.Rooms;
using static SimplexCore.Sgml;
using static SimplexCore.GlobalScripts;
using Keys = Microsoft.Xna.Framework.Input.Keys;
using MouseButtons = SimplexCore.Sgml.MouseButtons;
namespace SimplexResources.Objects
{
public class SampleObject : GameObject
{
private float lineThickness = 0;
private float time = 0;
private float alpha = 0;
public SampleObject()
{
Sprite.TextureSource = "texture";
Sprite.ImageRectangle = new Rectangle(0, 0, 64, 64);
EditorPath = "Actors";
}
public override void EvtContextMenuSelected(ToolStripItem e)
{
if (e.Text == "Oh you can overload this?")
{
Debug.WriteLine(is_string("Kokot"));
Debug.WriteLine(is_string(123));
}
}
public override void OnCreate()
{
}
public override void EvtDraw()
{
time++;
ImageAlpha = Math.Abs((float)Math.Sin(MathHelper.ToRadians(time)));
draw_set_alpha(ImageAlpha);
draw_rectangle(Position, new Vector2(64, 64), false, 0);
draw_set_alpha(1);
// Almost like in GMS, insted of mb_left buttons are now enumerated in MouseButtons (two extra buttons x1 and x2 are defined)
if (mouse_check_button_pressed(MouseButtons.Middle))
{
/* Differencies from GMS2:
* Two main things are that instance_create outputs a GameObject type as it doesn't know which type to return before args are passed
* also object to be created needs to be referenced within typeof() rather than with a native class name
*
* 1 - Object3, GameObject, var, object or dynamic - all these are possible
* 2 - We need to convert output - GameObject to desired class
* 3 - Class name needs to be enclosed in typeof()
*/
/* 1 */ /* 2 */ /* 3 */
// Object3 myObject = (Object3)instance_create(new Vector2(100, 100), typeof(Object3), "Object layer 1");
// Just some sample code changing position of myObject
// myObject.Position = new Vector2(200, 200);
if (irandom(2) == 1)
{
//instance_destroy(myObject);
}
// This will return a list of instances that have their blend_color set to Aqua and whose position is equal to vec2(10, 10)
List<Object3> lookHowCoolIsThis = instance_find<Object3>(x => x.color == Color.White);
if (currentRoom.GetType() == typeof(Room2))
{
room_goto(typeof(Room1));
}
else
{
room_goto(typeof(Room2));
}
}
}
}
}