public void RandomA(ScriptThread thread)
 {
     thread.SetReturnValue(MathMethods.Random(thread.GetFloatParameter(0), thread.GetFloatParameter(1)));
 }
Example #2
0
 public void CheckForCollisionB(ScriptThread thread)
 {
     thread.SetReturnValue(CollisionManager.HitTest(new CollisionRectangle(new Transformation(thread.GetFloatParameter(0), thread.GetFloatParameter(1), 0, 0, 0, 0, 1.0f, 1.0f, 1.0f), thread.GetFloatParameter(2), thread.GetFloatParameter(3))));
 }
Example #3
0
 public void NodeAtPoint(ScriptThread thread)
 {
     CollisionPolygon polygon = CollisionManager.PolygonAtPoint((int)thread.GetFloatParameter(0), (int)thread.GetFloatParameter(1));
     if (polygon == null || polygon.MetaData == null) return;
     thread.SetReturnValue(new SceneNodeScriptObject(polygon.MetaData as SceneNode));
 }
Example #4
0
 public void SetChannelVolume(ScriptThread thread)
 {
     ISampleBuffer sound = ((NativeObject)thread.GetObjectParameter(0)).Object as ISampleBuffer;
     if (sound == null)
     {
         DebugLogger.WriteLog((thread.Process.Url != null && thread.Process.Url != "" ? thread.Process.Url : "A script") + " called SetChannelVolume with an invalid object.", LogAlertLevel.Error);
         return;
     }
     sound.Volume = thread.GetFloatParameter(1);
 }
Example #5
0
 public void StreamWriteF(ScriptThread thread)
 {
     ScriptStream stream = ((NativeObject)thread.GetObjectParameter(0)).Object as ScriptStream;
     if (stream == null)
     {
         DebugLogger.WriteLog((thread.Process.Url != null && thread.Process.Url != "" ? thread.Process.Url : "A script") + " called StreamWrite with an invalid object.", LogAlertLevel.Error);
         return;
     }
     stream.Writer.Write(thread.GetFloatParameter(1));
 }
Example #6
0
 public void RotateEntity(ScriptThread thread)
 {
     EntityNode entity = ((NativeObject)thread.GetObjectParameter(0)).Object as EntityNode;
     if (entity == null)
     {
         DebugLogger.WriteLog((thread.Process.Url != null && thread.Process.Url != "" ? thread.Process.Url : "A script") + " called RotateEntity with an invalid object.", LogAlertLevel.Error);
         return;
     }
     entity.Rotate(thread.GetFloatParameter(1), thread.GetFloatParameter(2), thread.GetFloatParameter(3));
 }
Example #7
0
        public void MoveEntityTowardsPoint(ScriptThread thread)
        {
            EntityNode entity = ((NativeObject)thread.GetObjectParameter(0)).Object as EntityNode;
            float x = thread.GetFloatParameter(1);
            float y = thread.GetFloatParameter(2);
            float speed = thread.GetFloatParameter(3);
            if (entity == null)
            {
                DebugLogger.WriteLog((thread.Process.Url != null && thread.Process.Url != "" ? thread.Process.Url : "A script") + " called MoveEntityTowardsPoint with an invalid object.", LogAlertLevel.Error);
                return;
            }

            // Work out the central points.
            Transformation entityTransform = entity.CalculateTransformation();

            // If its a camera then we need to invert the coordinates as it uses
            // slightly different ones from normal entities.
            if (entity is CameraNode)
            {
                entityTransform.X = -entityTransform.X;
                entityTransform.Y = -entityTransform.Y;
            }

            // Are we at the correct place? If so why bother with the below code :P.
            if (entityTransform.X == x && entityTransform.Y == y)
                return;

            float entityTransformCenterX = entityTransform.X + ((entity.BoundingRectangle.Width / 2) * entityTransform.ScaleX);
            float entityTransformCenterY = entityTransform.Y + ((entity.BoundingRectangle.Height / 2) * entityTransform.ScaleY);
            float vectorX = entityTransformCenterX - x;
            float vectorY = entityTransformCenterY - y;
            float distance = (float)Math.Sqrt(vectorX * vectorX + vectorY * vectorY);
            vectorX /= distance;
            vectorY /= distance;

            if (float.IsNaN(vectorX * speed) || float.IsNaN(vectorY * speed)) return;

            // Work out vector towards entity.
            entity.Move(-(vectorX * speed),-(vectorY * speed), 0.0f);
        }
 public void CreateShakingProcess(ScriptThread thread)
 {
     EntityNode entity = ((NativeObject)thread.GetObjectParameter(0)).Object as EntityNode;
     if (entity == null)
     {
         DebugLogger.WriteLog((thread.Process.Url != null && thread.Process.Url != "" ? thread.Process.Url : "A script") + " called CreateShakingProcess with an invalid object.", LogAlertLevel.Error);
         return;
     }
     thread.SetReturnValue(new ProcessScriptObject(new EntityShakeProcess(entity, thread.GetFloatParameter(1))));
 }
 public void CreateMoveToProcessB(ScriptThread thread)
 {
     EntityNode entity = ((NativeObject)thread.GetObjectParameter(0)).Object as EntityNode;
     EntityNode moveEntity = ((NativeObject)thread.GetObjectParameter(3)).Object as EntityNode;
     if (entity == null || moveEntity == null)
     {
         DebugLogger.WriteLog((thread.Process.Url != null && thread.Process.Url != "" ? thread.Process.Url : "A script") + " called CreateMoveToProcess with an invalid object.", LogAlertLevel.Error);
         return;
     }
     thread.SetReturnValue(new ProcessScriptObject(new EntityMoveToProcess(entity, moveEntity.Transformation.X + ((moveEntity.BoundingRectangle.Width / 2.0f) * moveEntity.Transformation.ScaleX), moveEntity.Transformation.Y + ((moveEntity.BoundingRectangle.Height / 2.0f) * moveEntity.Transformation.ScaleY), new StartFinishF(thread.GetFloatParameter(1), thread.GetFloatParameter(2)))));
 }
Example #10
0
 public void CreateChannelFadeProcess(ScriptThread thread)
 {
     Audio.ISampleBuffer sound = ((NativeObject)thread.GetObjectParameter(0)).Object as ISampleBuffer;
     if (sound == null)
     {
         DebugLogger.WriteLog((thread.Process.Url != null && thread.Process.Url != "" ? thread.Process.Url : "A script") + " called CreateChannelFadeProcess with an invalid object.", LogAlertLevel.Error);
         return;
     }
     thread.SetReturnValue(new ProcessScriptObject(new ChannelFadeProcess(sound, thread.GetFloatParameter(1), thread.GetFloatParameter(2), thread.GetIntegerParameter(3))));
 }