示例#1
0
 public Trigger( GameWorld world, Texture2D active_texture,
     Texture2D inactive_texture, Vector2 position,
     TriggerableObject triggered_object, TriggerType type,
     float cooldown, float rotation, String name = "Trigger",
     String texture_name = TNames.ground_switch_animate, SharedResourceList<TriggerableObject> t_obj_list = null,
     float scale = 1, float density = DENSITY )
     : base(world, inactive_texture, position, name: name, texture_name: texture_name, density: density)
 {
     m_texture_name = texture_name;
     m_texture_name_helper = texture_name;
     m_active_texture = active_texture;
     m_inactive_texture = inactive_texture;
     m_buffered_position = position;
     m_size_scale = scale;
     m_radius = m_size_scale * ( m_texture.Width ) / ( GameWorld.SCALE * 2 );
     if ( t_obj_list == null ) {
         m_attached_to = new SharedResourceList<TriggerableObject>( world );
     }
     else {
         m_attached_to = t_obj_list;
     }
     if ( triggered_object != null ) {
         m_attached_to.Add( triggered_object );
     }
     m_type = type;
     m_cooldown = cooldown * 60;
     m_cooldown_timer = 0;
     m_deactivated = false;
     m_active = false;
     m_rotation = rotation;
     //m_radius = 0.2f * 5;
 }
示例#2
0
 public TrapTrigger( GameWorld world, Texture2D active_texture,
   Texture2D inactive_texture, Vector2[] points, Vector2 spawn, Vector2 impulse, float boul_radius, TriggerableObject triggered_object = null,
   String t_name = "Trigger", Trap type = Trap.BOULDER )
     : base(world, active_texture,
   inactive_texture, points, type: TriggerType.FLOOR, cooldown: 4, name: t_name,
   texture_name: TNames.ground_switch_inactive)
 {
     m_trap = type;
     m_impulse = impulse;
     m_spawn = spawn;
     obj_radius = boul_radius;
 }
        public PolygonTrigger( GameWorld world, Texture2D active_texture,
            Texture2D inactive_texture, Vector2[] points, TriggerableObject triggered_object = null,
            TriggerType type = TriggerType.FLOOR, float cooldown = -1, float rotation = 0, String name = "Trigger",
            String texture_name = TNames.ground_switch_inactive )
            : base(world, active_texture, inactive_texture, Vector2.Zero, triggered_object, type, cooldown, rotation, name, texture_name)
        {
            Vector2 diff = points[0] - points[(int)Math.Ceiling( points.Length / 2f )];
            float multiplier = Math.Min( Math.Abs( diff.X ), Math.Abs( diff.Y ) );
            m_width_height = new Vector2( multiplier, multiplier ) * 2;

            Vector2 sum = Vector2.Zero;

            foreach ( Vector2 p in points ) {
                sum += p;
            }
            pos = sum / points.Length;
            m_position = pos;

            for ( int i = 0; i < points.Length; i++ ) {
                points[i] -= pos;

            }

            if ( texture_name == TNames.wall && m_is_destructible ) {

                m_texture_name_change = TNames.breakwall;
                //m_texture = GameScreen.GAME_CONTENT.Load<Texture2D>(m_texture_name);
            }
            else if ( texture_name == TNames.tile ) {
                m_texture_name_change = TNames.tile;
                //m_texture = GameScreen.GAME_CONTENT.Load<Texture2D>(m_texture_name);

            }
            m_points = points;

            Vertices verts = new Vertices( points );
            Vertices collinear_simplified = SimplifyTools.CollinearSimplify( verts );
            Vertices merge_simplified = SimplifyTools.MergeIdenticalPoints( collinear_simplified );
            //Since it is a concave polygon, we need to partition it into several smaller convex polygons
            //List<Vertices> vert_list = BayazitDecomposer.ConvexPartition(merge_simplified);

            verts = merge_simplified;
            verts.ForceCounterClockWise();
            m_points = verts.ToArray();
        }
示例#4
0
 public void addTriggerable()
 {
     Vector2 pos = getMouse();
     TriggerableObject adding = new TriggerableObject( screen.m_current_world, TestWorld.door_texture, pos, pos, 0 );
     screen.m_current_world.add_queued_object( adding );
 }