Beispiel #1
0
        //method to fill the scene
        public void FillScene()
        {
            //add lights to the scene
            Light light1   = new Light(new Vector3(-2, -2, 1), new Vector3(1, 0, 0), 10);
            Light light2   = new Light(new Vector3(2, -2, 7), new Vector3(0, 1, 0), 10);
            Light bigLight = new Light(new Vector3(0, -3, 2), new Vector3(1, 1, 1), 25);

            Lights.Add(bigLight);
            Lights.Add(light1);
            Lights.Add(light2);

            //add primitives to the scene
            Floor   = new Plane("Floor", new Vector3(0, 1, 0), -1, new Vector3(50, 50, 50), "Specular");    //gray floor plane
            Sphere1 = new Sphere("Sphere1", new Vector3(-2, 0, 4), 1, new Vector3(255, 0, 0), "Specular");  //left sphere
            Sphere2 = new Sphere("Sphere2", new Vector3(0, 0, 5), 1, new Vector3(255, 255, 255), "Mirror"); //middle sphere

            Sphere3 = new Sphere("Sphere3", new Vector3(3, 0, 5), 1, new Vector3(0, 0, 255), "Specular");   //right sphere

            Triangle Triangle1 = new Triangle("Triangle1", new Vector3(0, 1, 3), new Vector3(1, -2, 4), new Vector3(2, 1, 3), new Vector3(0, 0, 255), "Diffuse");


            sceneObjects.Add(Floor); //add the primitives

            sceneObjects.Add(Sphere1);

            sceneObjects.Add(Sphere2);

            sceneObjects.Add(Sphere3);

            sceneObjects.Add(Triangle1);
        }
Beispiel #2
0
        // Sorts scene node into correct list.
        protected void AddNode(SceneNode node)
        {
            if (node is DecalNode)
            {
                DecalNodes.Add(node);
            }
            else if (node is LightNode)
            {
                Lights.Add(node);
            }
            else if (node is LensFlareNode)
            {
                LensFlareNodes.Add(node);
            }
            else if (node is SkyNode)
            {
                SkyNodes.Add(node);
            }
            else if (node is FogNode)
            {
                FogNodes.Add(node);
            }
            else if (node.IsRenderable)
            {
                RenderableNodes.Add(node);
            }

            // Unsupported types are simply ignored.
        }
Beispiel #3
0
        public async Task <IHttpActionResult> PutLights(int id, Lights lights)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != lights.Id)
            {
                return(BadRequest());
            }

            db.Entry(lights).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LightsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #4
0
        private void renderedControl1_Rendered(object sender, RenderEventArgs e)
        {
            int   tickCount = Environment.TickCount;
            float deltaTime = (tickCount - _previousTickCount) / 1000f;

            _previousTickCount = tickCount;

            _simulator.Update(deltaTime);
            _framesCount++;
            int secondsCount = (tickCount - _startTickCount) / 1000;

            if (secondsCount != 0)
            {
                label.Text = String.Format("FPS: {0}", _framesCount / secondsCount);
            }

            //draw scene
            var render = e.Render;

            render.BeginScene();

            render.Draw(() =>
            {
                _simulator.ActorsFactory.AcceptVisit(_renderingVisitor);
            },
                        Lights.Point(new Vector3(0, 5, -6), new Vector3(1, 1, 1)),
                        Cameras.LookAt(new Vector3(0, 15, -30), new Vector3(0, 0, 0), new Vector3(0, 1, 0)),
                        Cameras.Perspective(render.GetAspectRatio()),
                        Buffers.Clear(0.2f, 0.2f, 0.4f, 1),
                        Buffers.ClearDepth(),
                        Shaders.Phong
                        );
            render.EndScene();
            renderedControl1.Invalidate();
        }
Beispiel #5
0
 // Основной принцип программирования: Don't Repeat Yourself.
 // Не повторять один и тот же код дважды.
 // Если при создании программы вы нажимали Ctrl-C + Ctrl-V - в ней что-то не так.
 private static void SwitchTo(Lights color)
 {
     LightOff(Lights.Red);
     LightOff(Lights.Yellow);
     LightOff(Lights.Green);
     LightOn(color);
 }
Beispiel #6
0
 public void ReadChildData(BinaryReader reader)
 {
     _model.ReadString(reader);
     _animation_graph.ReadString(reader);
     _indoorFogScreen.ReadString(reader);
     for (int x = 0; x < _shaderFunctions.Count; x++)
     {
         ShaderFunctions.AddNew();
         ShaderFunctions[x].Read(reader);
     }
     for (int x = 0; x < _shaderFunctions.Count; x++)
     {
         ShaderFunctions[x].ReadChildData(reader);
     }
     for (int x = 0; x < _animations.Count; x++)
     {
         Animations.AddNew();
         Animations[x].Read(reader);
     }
     for (int x = 0; x < _animations.Count; x++)
     {
         Animations[x].ReadChildData(reader);
     }
     for (int x = 0; x < _lights.Count; x++)
     {
         Lights.AddNew();
         Lights[x].Read(reader);
     }
     for (int x = 0; x < _lights.Count; x++)
     {
         Lights[x].ReadChildData(reader);
     }
 }
Beispiel #7
0
    private static void MoveLeft(Player player, Player otherPlayer, Lights lights)
    {
        if (lights.IsFirst(player.currentLight))
        {
            return;
        }

        var nextIndex = player.currentLight.positionIndex - 1;

        // var otherPlayerIndex = otherPlayer.currentLight.positionIndex;

        // if (otherPlayerIndex == nextIndex)
        // {
        //     if (lights.IsFirst(otherPlayer.currentLight))
        //     {
        //         return;
        //     }
        //     else
        //     {
        //         nextIndex -= 1;
        //     }
        // }

        player.currentLight = lights.Get(nextIndex);
    }
Beispiel #8
0
        public void Dispose()
        {
            if (Layers != null)
            {
                foreach (var layer in Layers)
                {
                    if (layer.Value != null)
                    {
                        layer.Value.Dispose();
                    }
                }
            }

            if (LBranch != null)
            {
                LBranchSprite.Dispose();
            }
            LBranch = null;

            if (Layers != null)
            {
                Layers.Clear();
            }

            if (Lights != null)
            {
                Lights.Clear();
            }
        }
Beispiel #9
0
        private void CalculateLighting()
        {
            //Setup lights for NEE
            this.Lights = new List <Shape>();
            foreach (Shape S in Shapes)
            {
                if (S.Material.HasProperty("emission") && !(S is Plane)) //Infinite planes not included
                {
                    Lights.Add(S);
                }
            }

            //Setup light probabiltiies
            this.LightProbabilityTable = new double[Lights.Count];
            double TotalLightWeight = 0;

            for (int i = 0; i < Lights.Count; i++)
            {
                double LightWeight = Lights[i].Material.GetProperty("emission", Vector2.Zero).Color.SumComponents() * Lights[i].Area();
                TotalLightWeight        += LightWeight;
                LightProbabilityTable[i] = TotalLightWeight;
            }
            for (int i = 0; i < Lights.Count; i++)
            {
                LightProbabilityTable[i] /= TotalLightWeight;
            }
        }
Beispiel #10
0
        public SceneSettings()
        {
            var lights = new Lights
            {
                Light0 = new Light
                {
                    Ambient   = new Vector3(0.3f, 0.3f, 0.3f),
                    Direction = Vector3.Normalize(new Vector3(-0.3f, 0.2f, -0.8f)),
                    Color     = new Vector3(0.7f, 0.7f, 0.8f)
                }
            };

            LightingConfigurations = new Dictionary <TimeOfDay, LightSettings>
            {
                {
                    TimeOfDay.Morning,
                    new LightSettings
                    {
                        TerrainLights = lights,
                        ObjectLights  = lights
                    }
                }
            };

            TimeOfDay = TimeOfDay.Morning;

            Waypoints     = new WaypointCollection(new Waypoint[0]);
            WaypointPaths = new Dictionary <string, WaypointPath>();
        }
Beispiel #11
0
 public Fencer(byte score, Cards cards, Lights lights, bool priority)
 {
     Score    = score;
     Cards    = cards;
     Lights   = lights;
     Priority = priority;
 }
        protected override YAMLMappingNode ExportYAMLRoot(IExportContainer container)
        {
            YAMLMappingNode node = base.ExportYAMLRoot(container);

            node.AddSerializedVersion(GetSerializedVersion(container.ExportVersion));
            node.Add(SceneName, Scene.ExportYAML(container));
            node.Add(LightmapsName, Lightmaps.ExportYAML(container));
            if (IsReadAOTextures(container.ExportVersion))
            {
                node.Add(AOTexturesName, GetAOTextures(container.Version).ExportYAML(container));
            }
            if (IsReadLightmapsCacheFiles(container.Version))
            {
                node.Add(LightmapsCacheFilesName, GetLightmapsCacheFiles(container.Version).ExportYAML());
            }
            node.Add(LightProbesName, LightProbes.ExportYAML(container));
            node.Add(LightmapsModeName, LightmapsMode);
            node.Add(BakedAmbientProbeInLinearName, BakedAmbientProbeInLinear.ExportYAML(container));
            node.Add(LightmappedRendererDataName, LightmappedRendererData.ExportYAML(container));
            node.Add(LightmappedRendererDataIDsName, LightmappedRendererDataIDs.ExportYAML(container));
            node.Add(EnlightenSceneMappingName, EnlightenSceneMapping.ExportYAML(container));
            node.Add(EnlightenSceneMappingRendererIDsName, EnlightenSceneMappingRendererIDs.ExportYAML(container));
            node.Add(LightsName, Lights.ExportYAML(container));
            node.Add(LightBakingOutputsName, LightBakingOutputs.ExportYAML(container));
            if (IsReadBakedReflectionProbeCubemapCacheFiles(container.ExportVersion))
            {
                node.Add(BakedReflectionProbeCubemapCacheFilesName, GetBakedReflectionProbeCubemapCacheFiles(container.Version).ExportYAML());
            }
            node.Add(BakedReflectionProbeCubemapsName, BakedReflectionProbeCubemaps.ExportYAML(container));
            node.Add(BakedReflectionProbesName, BakedReflectionProbes.ExportYAML(container));
            node.Add(EnlightenDataName, EnlightenData.ExportYAML());
            node.Add(EnlightenDataVersionName, EnlightenDataVersion);
            return(node);
        }
Beispiel #13
0
        public async Task Setup()
        {
            string ip = await GetBridgeIp();

            hueClient = new LocalHueClient(ip, Secrets.HueUsername);

            var lights = await hueClient.GetLightsAsync();

            foreach (var light in lights)
            {
                lightToId.Add(light.Name, light.Id);
                Lights.Add(light.Name);
            }

            var groups = await hueClient.GetGroupsAsync();

            foreach (var group in groups)
            {
                var name = group.Name;
                if (name.Contains("Group for"))
                {
                    continue;
                }
                if (Lights.Contains(name))
                {
                    name = $"{name} (group)";
                }
                groupToId.Add(name, group.Id);
                Lights.Add(name);
            }
        }
        private async Task <bool> InitaliseRooms()
        {
            Rooms.Clear();
            IMobileServiceTableQuery <RoomItem> roomQuery;

            roomQuery = RoomTable.RoomSyncTable.Where(p => p.HomeId == SelectedHomeId);
            await RoomTable.Read(roomQuery);

            foreach (RoomItem RoomItem in RoomTable.RoomItems)
            {
                Room room = RoomConverter.CreateFrom(RoomItem);
                IMobileServiceTableQuery <DeviceItem> deviceQuery;
                deviceQuery = DeviceTable.deviceTable.Where(p => p.RoomId == room.Id);
                await DeviceTable.Read(deviceQuery);

                foreach (DeviceItem DeviceItem in DeviceTable.deviceItems)
                {
                    Device device = DeviceConverter.CreateFrom(DeviceItem);
                    try
                    {
                        device = await Lights.GetLightState(device);
                    }
                    catch (Exception e)
                    {
                        device.HasAccess = false;
                    }
                }
                Rooms.Add(room);
            }
            return(true);
        }
Beispiel #15
0
    /* PleaseWork(lightsGO);//
     * public static Lights PleaseWork(GameObject lightsGO)
     * {
     *   return lightsGO.GetComponent<Lights>();
     * }//*/

    void Start()
    {
        masterLightsTableStatic = masterLightsTable;
        lightsGO     = transform.gameObject;                 //THIS MAKES IT VERY IMPORTANT THAT Lights.cs ONLY BE APPLIED TO THE LIGHTS GO (I think...things become ambiguous in the UpdateLights function otherwise)
        lightsScript = lightsGO.GetComponent <Lights>();     //Similarly important to above

        lightsDict = new Dictionary <string, GLight>();      //GenLightsDict();// Generates a base lights dictionary

        foreach (var item in lightsScript.masterLightsTable) //Populates lights dictionary
        {
            lightsDict.Add(item.color, new GLight(true, 0f));
        }
        foreach (var item in lightsDict.Values)//Sets all of the "has" values to true (since Lights tracks all lights)
        {
            item.has = true;
        }

        foreach (Transform child in transform)//Manually "Start()"'s each hinge's HingeScript.cs
        //I do it this way so I know that necessary references in Lights.cs are already good to go before Hinges start trying to do shit (and because Unity kept yelling at me...)
        {
            child.GetComponent <HingeScript>().Initialize();
        }

        UpdateLights();
    }
    public void SetLight(Lights light)
    {
        if (_changing)
        {
            return;
        }
        _changing = true;
        switch (light)
        {
        case Lights.Green:
            radioGreen.Checked  = true;
            radioOrange.Checked = false;
            radioRed.Checked    = false;
            break;

        case Lights.Orange:
            radioOrange.Checked = true;
            radioGreen.Checked  = false;
            radioRed.Checked    = false;
            break;

        case Lights.Red:
            radioRed.Checked    = true;
            radioGreen.Checked  = false;
            radioOrange.Checked = false;
            break;
        }
        OnChanged(light);
        _changing = false;
    }
 protected virtual void OnChanged(Lights light)
 {
     if (LightChanged != null)
     {
         LightChanged(this, light);
     }
 }
Beispiel #18
0
        protected override void ReadData(DataBuffer buf, FileFormat fmt)
        {
            WheelDamageEffect = buf.ReadFloat();
            Engine            = buf.ReadByte();
            Wheels            = buf.ReadArray <WheelStatus>(NumWheels);
            Doors             = buf.ReadArray <DoorStatus>(NumDoors);
            buf.Skip(1);
            int lightStatus = buf.ReadInt32();
            int panelStatus = buf.ReadInt32();

            Field24h = buf.ReadInt32();

            Lights.Clear();
            for (int i = 0; i < NumLights; i++)
            {
                Lights.Add((LightStatus)(lightStatus & 0x3));
                lightStatus >>= 2;
            }

            Panels.Clear();
            for (int i = 0; i < NumPanels; i++)
            {
                Panels.Add((PanelStatus)(panelStatus & 0xF));
                panelStatus >>= 4;
            }

            Debug.Assert(buf.Offset == SizeOfType <DamageManager>());
        }
Beispiel #19
0
 public HomeTheaterFacade(DVDPlayer dvdPlayer, Lights lights, MusicPlayer musicPlayer, Projector projector)
 {
     _dvdPlayer   = dvdPlayer;
     _lights      = lights;
     _musicPlayer = musicPlayer;
     _projector   = projector;
 }
Beispiel #20
0
    // Use this for initialization, called by
    public void Initialize()
    {
        //Dictionary<string, Lights.GLight> lightsDict = new Dictionary<string, Lights.GLight>();//initialize the dictionary of lights for this door
        //This is the active dictionary that actually changes during gameplay, vs. the "static" one that's set in the inspector

        foreach (var item in Lights.MasterLightsTable())//Populates lights dictionary
        {
            lightsDict.Add(item.color, new Lights.GLight(false, 0f));
        }

        foreach (var item in doorLights)//Let the door know which lights it actually has, and what their timers are
        {
            lightsDict[item.color].has   = true;
            lightsDict[item.color].timer = item.timer;
        }
        PlaceLights();//Add light GO's to the scene, where they belong both in space and in the hierarchy
        if (closeSpeed == 0)
        {
            closeSpeed = openSpeed;
        }



        //FOR TESTING
        //test = true;
    }
Beispiel #21
0
        public void CopySectorColors()
        {
            // Only make this action possible if a map is actually opened and the we are in sectors mode
            if (General.Editing.Mode == null || General.Editing.Mode.Attributes.SwitchAction != "sectorsmode")
            {
                return;
            }

            // Make sure a sector is highlighted
            if (!(General.Editing.Mode.HighlightedObject is Sector))
            {
                // Show a warning in the status bar
                General.Interface.DisplayStatus(StatusType.Warning, "Please highlight a sector to copy the colors from");
                return;
            }

            // Copy the properties from the sector
            Sector s = (Sector)General.Editing.Mode.HighlightedObject;

            ceilColor  = s.CeilColor;   // villsa
            floorColor = s.FloorColor;  // villsa
            thingColor = s.ThingColor;  // villsa
            upperColor = s.TopColor;    // villsa
            lowerColor = s.LowerColor;  // villsa

            // Remember that we copied the colors
            didCopyColors = true;

            // Let the user know that copying worked
            General.Interface.DisplayStatus(StatusType.Action, "Copied sector colors.");
        }
Beispiel #22
0
    public void UpdateLights() //Checks current status of all lights and updates their on/offness appropriately.
                               //Should yield if opening or timers still running, then continue with the check once door is free again
                               //At the end of this function, call Open- or CloseSesame() depending on state of lights
    {
        bool open = true;

        foreach (var item in lightsDict)
        {
            print("Item key, value: " + item.Key + ", " + item.Value);
            if (item.Value.has)
            {
                print("Item has: " + item.Key + ", " + item.Value);

                if (!Lights.LightLit(item.Key))
                {
                    print("Light not lit: " + item.Key + ", " + item.Value);

                    open = false;
                }
            }
        }

        if (open)
        {
            //StartTimer();
            OpenSesame();
        }
        else
        {
            CloseSesame();
        }
    }
Beispiel #23
0
            /// <summary>
            /// Adds an event to the appropriate list for its type; returns the event.
            /// </summary>
            public Event Add(Event evnt)
            {
                switch (evnt)
                {
                case Event.Light e: Lights.Add(e); break;

                case Event.Sound e: Sounds.Add(e); break;

                case Event.SFX e: SFX.Add(e); break;

                case Event.Wind e: Wind.Add(e); break;

                case Event.Treasure e: Treasures.Add(e); break;

                case Event.Generator e: Generators.Add(e); break;

                case Event.Message e: Messages.Add(e); break;

                case Event.ObjAct e: ObjActs.Add(e); break;

                case Event.SpawnPoint e: SpawnPoints.Add(e); break;

                case Event.MapOffset e: MapOffsets.Add(e); break;

                case Event.Navmesh e: Navmeshes.Add(e); break;

                case Event.Environment e: Environments.Add(e); break;

                case Event.PseudoMultiplayer e: PseudoMultiplayers.Add(e); break;

                default:
                    throw new ArgumentException($"Unrecognized type {evnt.GetType()}.", nameof(evnt));
                }
                return(evnt);
            }
Beispiel #24
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public virtual bool Equals(Material other)
 {
     if (other == null)
     {
         return(false);
     }
     return(AlphaTest.Equals(other.AlphaTest) &&
            Blending.Equals(other.Blending) &&
            ClipIntersections.Equals(other.ClipIntersections) &&
            ClipShadows.Equals(other.ClipShadows) &&
            ColorWrite.Equals(other.ColorWrite) &&
            DepthTest.Equals(other.DepthTest) &&
            DepthWrite.Equals(other.DepthWrite) &&
            Dithering.Equals(other.Dithering) &&
            FlatShading.Equals(other.FlatShading) &&
            Fog.Equals(other.Fog) &&
            Lights.Equals(other.Lights) &&
            Opacity.Equals(other.Opacity) &&
            Overdraw.Equals(other.Overdraw) &&
            PremultipliedAlpha.Equals(other.PremultipliedAlpha) &&
            Side.Equals(other.Side) &&
            Transparent.Equals(other.Transparent) &&
            VertexColors.Equals(other.VertexColors) &&
            Visible.Equals(other.Visible) &&
            UserData == other.UserData &&
            ClippingPlanes == other.ClippingPlanes &&
            string.Equals(Precision, other.Precision));
 }
Beispiel #25
0
    private Crosshair cs;// = new Crosshair();

    public MyGame() : base(1920, 1080, false)
    {
        gd          = new GunDude();
        gm          = new GameManager();
        border      = new Border();
        background  = new Background();
        smoke       = new Smoke();
        lights      = new Lights();
        cs          = new Crosshair();
        hud         = new HUD();
        player      = new Player();
        builder     = new WaveBuilder();
        topBuilder  = new TopWaveBuilder();
        startScreen = new StartScreen();
        gameOver    = new GameOver();


        gameObjs.Add(border);
        gameObjs.Add(background);
        gameObjs.Add(smoke);
        gameObjs.Add(lights);
        gameObjs.Add(cs);
        gameObjs.Add(hud);
        gameObjs.Add(player);
        gameObjs.Add(gd);

        builder.WaveSpawner();
        topBuilder.WaveSpawner();
    }
Beispiel #26
0
            public virtual void ReadChildData(BinaryReader reader)
            {
                int x = 0;

                _model.ReadString(reader);
                _animationgraph.ReadString(reader);
                _indoorFogScreen.ReadString(reader);
                for (x = 0; (x < _shaderFunctions.Count); x = (x + 1))
                {
                    ShaderFunctions.Add(new SkyShaderFunctionBlock());
                    ShaderFunctions[x].Read(reader);
                }
                for (x = 0; (x < _shaderFunctions.Count); x = (x + 1))
                {
                    ShaderFunctions[x].ReadChildData(reader);
                }
                for (x = 0; (x < _animations.Count); x = (x + 1))
                {
                    Animations.Add(new SkyAnimationBlock());
                    Animations[x].Read(reader);
                }
                for (x = 0; (x < _animations.Count); x = (x + 1))
                {
                    Animations[x].ReadChildData(reader);
                }
                for (x = 0; (x < _lights.Count); x = (x + 1))
                {
                    Lights.Add(new SkyLightBlock());
                    Lights[x].Read(reader);
                }
                for (x = 0; (x < _lights.Count); x = (x + 1))
                {
                    Lights[x].ReadChildData(reader);
                }
            }
Beispiel #27
0
        public void Read(System.IO.BinaryReader r)
        {
            TileWidth  = r.ReadInt32();
            TileHeight = r.ReadInt32();
            int lc = r.ReadInt32();

            for (int i = 0; i < lc; i++)
            {
                var l = new Vivid.Scene.GraphLight();
                l.Read(r);
                Lights.Add(l);
            }
            int mc = r.ReadInt32();

            for (int i = 0; i < mc; i++)
            {
                var m = new Vivid.Scene.GraphMarker();
                m.Read(r);
                Markers.Add(m);
            }
            int layc = r.ReadInt32();

            Layers = new List <MapLayer>();
            for (int l = 0; l < layc; l++)
            {
                var ml = new MapLayer(1, 1, this);
                ml.Read(r);
                Layers.Add(ml);
            }
        }
Beispiel #28
0
            internal override Region ReadEntry(BinaryReaderEx br)
            {
                RegionType type = br.GetEnum8 <RegionType>(br.Position + br.VarintSize + 2);

                switch (type)
                {
                case RegionType.Region0:
                    return(Region0s.EchoAdd(new Region.Region0(br)));

                case RegionType.Light:
                    return(Lights.EchoAdd(new Region.Light(br)));

                case RegionType.StartPoint:
                    return(StartPoints.EchoAdd(new Region.StartPoint(br)));

                case RegionType.Sound:
                    return(Sounds.EchoAdd(new Region.Sound(br)));

                case RegionType.SFX:
                    return(SFXs.EchoAdd(new Region.SFX(br)));

                case RegionType.Wind:
                    return(Winds.EchoAdd(new Region.Wind(br)));

                case RegionType.EnvLight:
                    return(EnvLights.EchoAdd(new Region.EnvLight(br)));

                case RegionType.Fog:
                    return(Fogs.EchoAdd(new Region.Fog(br)));

                default:
                    throw new NotImplementedException($"Unimplemented region type: {type}");
                }
            }
Beispiel #29
0
            /// <summary>
            /// Adds a region to the appropriate list for its type; returns the region.
            /// </summary>
            public Region Add(Region region)
            {
                switch (region)
                {
                case Region.Region0 r: Region0s.Add(r); break;

                case Region.Light r: Lights.Add(r); break;

                case Region.StartPoint r: StartPoints.Add(r); break;

                case Region.Sound r: Sounds.Add(r); break;

                case Region.SFX r: SFXs.Add(r); break;

                case Region.Wind r: Winds.Add(r); break;

                case Region.EnvLight r: EnvLights.Add(r); break;

                case Region.Fog r: Fogs.Add(r); break;

                default:
                    throw new ArgumentException($"Unrecognized type {region.GetType()}.", nameof(region));
                }
                return(region);
            }
Beispiel #30
0
            public IEnumerable <string> Validate()
            {
                if (!File.Exists(Path))
                {
                    yield return("Path does not exist.");
                }

                var image = Image.Load(Path);

                if (image.Height < Lights.Count())
                {
                    yield return($"Sequence can't handle more than {image.Height} light(s).");
                }

                if (RepeatCount.HasValue && RepeatSeconds.HasValue)
                {
                    yield return("Repeat count and repeat seconds can't both be specified.");
                }

                if (FramesPerSecond <= 0m || FramesPerSecond > 100m)
                {
                    yield return("FPS must be greater than 0 and less than or equal to 100.");
                }

                foreach (string light in Lights)
                {
                    if (!IPAddress.TryParse(light, out _))
                    {
                        yield return($"{light} is not a valid IP address.");
                    }
                }
            }
Beispiel #31
0
 void Start()
 {
     SetMaxHealth(maxHealth);
     levelLights = GetComponentInParent<Lights>();
 }
Beispiel #32
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            _spr = Content.Load<SpriteFont>("spritefont");
            _tank1 = Content.Load<Texture2D>("tank1");
            _tank2 = Content.Load<Texture2D>("tank2");
            _cannon1 = Content.Load<Texture2D>("cannon1");
            _cannon2 = Content.Load<Texture2D>("cannon2");
            _cannonball1 = Content.Load<Texture2D>("cannonball1");
            _cannonball2 = Content.Load<Texture2D>("cannonball2");
            _back = Content.Load<Texture2D>("test1");
            _textureNormal = Content.Load<Texture2D>("test1_map");

            _deferred = Content.Load<Effect>("deferred");

            _tankmodel1 = new Tank(_tank1, _cannon1, _cannonball1, new Vector2(50, 550), 1,_spr);
            _tankmodel2 = new Tank(_tank2, _cannon2, _cannonball2, new Vector2(750, 50), 2,_spr);
            _lights = new Lights(_back, _textureNormal, _deferred);
        }
Beispiel #33
0
 public void LightOn(Lights light)
 {
     lights[(int)light]=true;
     BeginInvoke(new Action(Invalidate));
 }
Beispiel #34
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            var kb = Keyboard.GetState();
            if (kb.IsKeyDown(Keys.Q) && _flag == 0)
                this.Exit();
            if (kb.IsKeyDown(Keys.Escape))
            {
                _flag = 0;
                _tankmodel1 = new Tank(_tank1, _cannon1, _cannonball1, new Vector2(50, 500), 1, _spr);
                _tankmodel2 = new Tank(_tank2, _cannon2, _cannonball2, new Vector2(750, 100), 2,_spr);
                _lights = new Lights(_back, _textureNormal, _deferred);
            }
            if (kb.IsKeyDown(Keys.Space))
                _flag = 1;

            // TODO: Add your update logic here
            if (_flag==1)
            {
                _tankmodel1.Update(kb, _tankmodel2.pos, 1, gameTime);
                _tankmodel2.Update(kb, _tankmodel1.pos, 2, gameTime);
                _lights.Update(_tankmodel1.pos, _tankmodel2.pos);
            }

            base.Update(gameTime);
        }
Beispiel #35
0
 public virtual int Add(Lights.Light value)
 {
     return List.Add(value);
 }
Beispiel #36
0
 public virtual void Remove(Lights.Light value)
 {
     List.Remove(value);
 }
Beispiel #37
0
 public void LightOff(Lights light)
 {
     lights[(int)light]=false;
     BeginInvoke(new Action(Invalidate));
 }
Beispiel #38
0
 /// <summary>
 /// This automatically creates a camera that see's what a light see's.
 /// </summary>
 /// <param name="light">The source light.</param>
 public CameraPerspective(Lights.Light light)
 {
     Translate = light.Translate;
     Target = Translate + light.Direction;
 }