public SymbolsImage ApplyLightLevel(SymbolsImage image, LightLevel lightData) { var result = new SymbolsImage(image.Width, image.Height); for (int x = 0; x < image.Width; x++) { for (int y = 0; y < image.Height; y++) { var originalCell = image[x, y]; var cell = result[x, y]; cell.Symbol = originalCell.Symbol; if (originalCell.Color.HasValue) { cell.Color = ApplyLightLevel(originalCell.Color.Value, lightData); } if (originalCell.BackgroundColor.HasValue) { cell.BackgroundColor = ApplyLightLevel(originalCell.BackgroundColor.Value, lightData); } } } return(result); }
public CachedChunk(WorldServer world, Vector3i position, BinaryReader reader) : this(world, position) { Min = new Vector3i(reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32()); Max = new Vector3i(reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32()); for (var x = Min.X; x <= Max.X; x++) { for (var y = Min.Y; y <= Max.Y; y++) { for (var z = Min.Z; z <= Max.Z; z++) { BlockIds[x, y, z] = reader.ReadUInt16(); LightLevels[x, y, z] = LightLevel.FromBinary(reader.ReadUInt16()); } } } var blockDataCount = reader.ReadInt32(); for (var i = 0; i < blockDataCount; i++) { var blockDataPos = Vector3iChunk.FromBinary(reader.ReadUInt16()); var blockData = BlockData.ReadFromStream(reader); BlockDatas.Add(blockDataPos, blockData); } }
public void SetLightLevel(Vector3i blockPos, LightLevel lightLevel) { NeedsSaving = true; _lightLevels[blockPos.X, blockPos.Y, blockPos.Z] = lightLevel; if (blockPos.X < _min.X) { _min.X = blockPos.X; } if (blockPos.Y < _min.Y) { _min.Y = blockPos.Y; } if (blockPos.Z < _min.Z) { _min.Z = blockPos.Z; } if (blockPos.X > _max.X) { _max.X = blockPos.X; } if (blockPos.Y > _max.Y) { _max.Y = blockPos.Y; } if (blockPos.Z > _max.Z) { _max.Z = blockPos.Z; } }
private void Start() { lightLevel = FindObjectOfType <LightLevel>(); maxPlastic = 0; foreach (Collectable p in FindObjectsOfType <Collectable>()) { maxPlastic += p.score; } }
private IEnumerator lightDamage() { while (possessedBody == null && currentHealth > 0) { float lightLevel = LightLevel.GetLightLevel(transform.position); float damage = damageFromLight.Evaluate(lightLevel) * Time.deltaTime * lightDamageMultiplier; TakeDamage(damage, transform.position, 0f); yield return(null); } }
private Color ApplyLightLevel(Color color, LightLevel lightLevel) { var lightLevelPercent = GetLightLevelPercent(lightLevel); var red = Math.Min((int)(color.R * lightLevelPercent), 255); var green = Math.Min((int)(color.G * lightLevelPercent), 255); var blue = Math.Min((int)(color.B * lightLevelPercent), 255); var darkenedColor = Color.FromArgb(red, green, blue); return(darkenedColor); }
public bool Equals(DestinyPlayer input) { if (input == null) { return(false); } return (( DestinyUserInfo == input.DestinyUserInfo || (DestinyUserInfo != null && DestinyUserInfo.Equals(input.DestinyUserInfo)) ) && ( CharacterClass == input.CharacterClass || (CharacterClass != null && CharacterClass.Equals(input.CharacterClass)) ) && ( ClassHash == input.ClassHash || (ClassHash.Equals(input.ClassHash)) ) && ( RaceHash == input.RaceHash || (RaceHash.Equals(input.RaceHash)) ) && ( GenderHash == input.GenderHash || (GenderHash.Equals(input.GenderHash)) ) && ( CharacterLevel == input.CharacterLevel || (CharacterLevel.Equals(input.CharacterLevel)) ) && ( LightLevel == input.LightLevel || (LightLevel.Equals(input.LightLevel)) ) && ( BungieNetUserInfo == input.BungieNetUserInfo || (BungieNetUserInfo != null && BungieNetUserInfo.Equals(input.BungieNetUserInfo)) ) && ( ClanName == input.ClanName || (ClanName != null && ClanName.Equals(input.ClanName)) ) && ( ClanTag == input.ClanTag || (ClanTag != null && ClanTag.Equals(input.ClanTag)) ) && ( EmblemHash == input.EmblemHash || (EmblemHash.Equals(input.EmblemHash)) )); }
public override LightLevel GetLightLevel(WorldBase world, Vector3i blockPos) { var l = new LightLevel(15, 11, 11); var ks = Keyboard.GetState(); if (ks.IsKeyDown(Key.G)) { l = new LightLevel(11, 15, 11); } if (ks.IsKeyDown(Key.B)) { l = new LightLevel(11, 11, 15); } return(l); }
private void ProcessLightEmitting() { if (!remainingLightTime.HasValue) { return; } if (remainingLightTime.Value < 0) { LightPower = DefaultLightLevel; remainingLightTime = null; return; } remainingLightTime = remainingLightTime.Value - 1; }
private void ActivateBacklight(LightLevel lightLevel) { if (_kcInstance != null) { try { if (_kcInstance.SetKeyboardBackLightStatus((int)lightLevel) == 0) { _hub.PublishAsync(new OnBacklightChangedMessage(this, lightLevel)); } } catch (Exception e) { _logger.Error(e, $"Unable to set backlight level to '{lightLevel}'"); } } }
public void SavePlayerInfo() { string filePath = Application.persistentDataPath + "/Player.xml"; if (!File.Exists(filePath)) { XmlDocument xmlDoc = new XmlDocument(); //头结点 XmlElement root = xmlDoc.CreateElement("Player"); XmlElement locallayer = xmlDoc.CreateElement("LevelLayer"); locallayer.InnerText = LayerCount.ToString(); XmlElement localHp = xmlDoc.CreateElement("Hp"); localHp.InnerText = Hp.ToString(); XmlElement localShootLevel = xmlDoc.CreateElement("ShootLevel"); localShootLevel.InnerText = ShootLevel.ToString(); XmlElement localSpeedLevel = xmlDoc.CreateElement("SpeedLevel"); localSpeedLevel.InnerText = SpeedLevel.ToString(); XmlElement localBulletLevel = xmlDoc.CreateElement("BulletLevel"); localBulletLevel.InnerText = BulletLevel.ToString(); XmlElement localLightlevel = xmlDoc.CreateElement("LightLevel"); localLightlevel.InnerText = LightLevel.ToString(); XmlElement localSpeed = xmlDoc.CreateElement("Speed"); localSpeed.InnerText = Speed.ToString(); XmlElement localShootTimer = xmlDoc.CreateElement("ShootTimer"); localShootTimer.InnerText = ShootTimer.ToString(); XmlElement localMoney = xmlDoc.CreateElement("Money"); localMoney.InnerText = Money.ToString(); XmlElement localSkillIcon = xmlDoc.CreateElement("SkillICon"); localSkillIcon.InnerText = skillIcon.ToString(); root.AppendChild(locallayer); root.AppendChild(localHp); root.AppendChild(localShootLevel); root.AppendChild(localSpeedLevel); root.AppendChild(localBulletLevel); root.AppendChild(localLightlevel); root.AppendChild(localSpeed); root.AppendChild(localShootTimer); root.AppendChild(localMoney); root.AppendChild(localSkillIcon); xmlDoc.AppendChild(root); xmlDoc.Save(filePath); } }
private void ChangeAdjacentLightLevel(float amount) { Vector2 tilePos = new Vector2(Mathf.Round(transform.position.x), Mathf.Round(transform.position.y)); for (int i = 1; i <= radius; i += 1) { Vector2 offset = new Vector2(i, i); Collider2D[] colliders = Physics2D.OverlapAreaAll(tilePos - offset, tilePos + offset); foreach (Collider2D collider in colliders) { LightLevel ll = collider.GetComponent <LightLevel>(); if (ll != null) { ll.ChangeLightLevel(amount); } } } }
private void Awake() { levelGod = GameObject.FindObjectOfType <LevelGod>(); var bases = plantDecalSet.bases; var plantBasePrefab = bases[UnityEngine.Random.Range(0, bases.Length)]; Soil[] randoSoil = (Soil[])System.Enum.GetValues(typeof(Soil)); LightLevel[] randoLight = (LightLevel[])System.Enum.GetValues(typeof(LightLevel)); var requiremenSoil = randoSoil[UnityEngine.Random.Range(0, randoSoil.Length)]; var requiremenLight = randoLight[UnityEngine.Random.Range(0, randoLight.Length)]; soil = requiremenSoil; lightLevel = requiremenLight; if (plantDecalSet == null) { return; } plantBaseInstance = Instantiate(plantBasePrefab); plantBaseInstance.transform.SetParent(this.transform, true); plantBaseInstance.transform.position = this.transform.position; healthyColor = UnityEngine.Random.ColorHSV(0, 1, 0.8f, 0.9f, 0.8f, 1f); // TODO: choose a decal object based on input from elsewhere, not here var set = UnityEngine.Random.Range(0, 2) == 0 ? plantDecalSet.flowers : plantDecalSet.fruits; var decal = set[UnityEngine.Random.Range(0, set.Length)]; var decalColor = UnityEngine.Random.ColorHSV(0, 1, 0.8f, 0.9f, 0.8f, 1f); foreach (var renderer in plantBaseInstance.GetComponentsInChildren <MeshRenderer>()) { renderer.material.color = healthyColor; } foreach (var spawner in GetComponentsInChildren <DecalObjectSpawner>()) { spawner.SpawnObject(decal, decalColor); } }
public List <AITarget> GetSeenTargets(Vector3 position, Vector2 forward) { float effectiveSightRange = sightRange * sightRangeOverDistance.Evaluate(LightLevel.GetLightLevel(position)); List <AITarget> seenTargets = new List <AITarget>(); for (int i = 0; i < targets.Count; ++i) { Vector2 selfToTarget = targets[i].transform.position - position; if (selfToTarget.magnitude < effectiveSightRange && Mathf.Abs(Vector2.Angle(forward, selfToTarget)) < 90 && Physics2D.Raycast(position, selfToTarget).transform == targets[i].transform) { seenTargets.Add(targets[i]); } } return(seenTargets); }
private static void SpreadLightLevel(IAreaMap map, Point position, LightLevel light) { if (light <= LightLevel.Darkness) { return; } var cell = map.TryGetCell(position); if (cell == null) { return; } if ((int)light < (int)cell.LightLevel) { return; } cell.LightLevel = light; if (cell.BlocksEnvironment) { return; } var lightPowerToSpread = (int)light - 1; if (lightPowerToSpread <= (int)LightLevel.Darkness) { return; } var lightToSpread = (LightLevel)lightPowerToSpread; SpreadLightLevel(map, Point.GetPointInDirection(position, Direction.North), lightToSpread); SpreadLightLevel(map, Point.GetPointInDirection(position, Direction.South), lightToSpread); SpreadLightLevel(map, Point.GetPointInDirection(position, Direction.West), lightToSpread); SpreadLightLevel(map, Point.GetPointInDirection(position, Direction.East), lightToSpread); }
public override void SetBlockLightLevel(int x, int y, int z, LightLevel lightLevel) { var chunkInWorld = ChunkInWorld(x, y, z); var blockInChunk = BlockInChunk(x, y, z); if (!LoadedChunks.TryGetValue(chunkInWorld, out var chunk)) { return; } chunk.SetLightLevel(blockInChunk, lightLevel); if (blockInChunk.X == 0) { QueueChunkUpdate(chunkInWorld + new Vector3i(-1, 0, 0), false); } else if (blockInChunk.X == Chunk.Size - 1) { QueueChunkUpdate(chunkInWorld + new Vector3i(+1, 0, 0), false); } if (blockInChunk.Y == 0) { QueueChunkUpdate(chunkInWorld + new Vector3i(0, -1, 0), false); } else if (blockInChunk.Y == Chunk.Size - 1) { QueueChunkUpdate(chunkInWorld + new Vector3i(0, +1, 0), false); } if (blockInChunk.Z == 0) { QueueChunkUpdate(chunkInWorld + new Vector3i(0, 0, -1), false); } else if (blockInChunk.Z == Chunk.Size - 1) { QueueChunkUpdate(chunkInWorld + new Vector3i(0, 0, +1), false); } QueueChunkUpdate(chunk, false); }
public abstract void SetBlockLightLevel(int x, int y, int z, LightLevel lightLevel);
private static int GetLightPowerDistance(LightLevel power) { return((int)power); }
private float GetLightLevelPercent(LightLevel light) { return((int)light * brightness); }
public static bool IsTooDarkToSee(LightLevel level) { return(level == LightLevel.Nothing || level == LightLevel.PitchBlack || level == LightLevel.VeryDark); }
public StaticLightSource(LightLevel lightPower) { LightPower = lightPower; }
public void SetBlockLightLevel(Vector3i blockPos, LightLevel lightLevel) => SetBlockLightLevel(blockPos.X, blockPos.Y, blockPos.Z, lightLevel);
public void SetEmitLight(LightLevel level, int time) { LightPower = level; remainingLightTime = time; }
public OnBacklightChangedMessage(BacklightControls sender, LightLevel lightValue) : base(sender) { LightValue = lightValue; }