public static int SwapperPaintToCount(PaintColor componentPaint) { switch (componentPaint) { default: return(1); case AdvancedCircuits.Paint_Swapper_2: return(2); case AdvancedCircuits.Paint_Swapper_3: return(3); case AdvancedCircuits.Paint_Swapper_4: return(4); case AdvancedCircuits.Paint_Swapper_5: return(5); case AdvancedCircuits.Paint_Swapper_6: return(6); case AdvancedCircuits.Paint_Swapper_7: return(7); } }
static void Main(string[] args) { VolvoC30 myCar = new VolvoC30("Adam Freeman", PaintColor.Black); PaintColor color = PaintColor.Green; switch (color) { case PaintColor.Black: Console.WriteLine("Paint Color is black"); break; case PaintColor.Green: Console.WriteLine("Paint Color is green"); break; case PaintColor.Red: case PaintColor.Silver: Console.WriteLine("Paint Color is red or silver"); break; } if (color == PaintColor.Black) { Console.WriteLine("Paint color is black"); } // wait for input before exiting Console.WriteLine("Press enter to finish"); Console.ReadLine(); }
private void PaintWeapon() { if (Input.GetKeyDown(KeyCode.Space) && hasWeapon == true) { Collider2D[] paintBuckets = Physics2D.OverlapCircleAll(transform.position, 1, 1 << LayerMask.NameToLayer("PaintBucket")); float closestDistance = float.MaxValue; GameObject closestBucket = null; foreach (var bucket in paintBuckets) { float distanceToSoldier = Vector2.Distance(transform.position, bucket.transform.position); if (distanceToSoldier < closestDistance) { closestDistance = distanceToSoldier; closestBucket = bucket.gameObject; } } if (closestBucket == null) { return; } int randomID = UnityEngine.Random.Range(0, PaintClips.Length); AudioSource.PlayClipAtPoint(PaintClips[randomID], Camera.main.transform.position); PaintColor targetColor = closestBucket.GetComponent <PaintBucket>().MyColor; currentItem.GetComponent <Weapon>().TransformWeapon(targetColor); } }
public bool HandleTilePaint(TSPlayer player, DPoint location, PaintColor paint) { if (this.IsDisposed) { return(false); } ITile componentTile = TerrariaUtils.Tiles[location]; int objectStyle; if (componentTile.type == TileID.Statues) { objectStyle = componentTile.frameX / 36; } else if (componentTile.type == TileID.Traps) { objectStyle = componentTile.frameY / 18; } else { objectStyle = 0; } bool hasPermission = this.CheckTilePermission(player, location, componentTile.type, objectStyle, paint); return(!hasPermission); }
public static BaseProcessor CreatePaint(PaintColor color) { BaseProcessor matcher; switch (color) { case PaintColor.Red: matcher = new RedPaintProcessor(); break; case PaintColor.Yellow: matcher = new YellowPaintProcessor(); break; case PaintColor.Blue: matcher = new BluePaintProcessor(); break; default: matcher = null; break; } return(matcher); }
//------------------------------------------------------------------------- // Event //------------------------------------------------------------------------- public void DownTube(string tube) { if (Time.timeScale <= 0) { return; } if (!animator.GetCurrentAnimatorStateInfo(0).IsName("Idle@Tube")) { return; } //ペンを使用不可に MousePainter.isBrushUse = false; //文字列をEnumに if (tube == PaintColor.Red.ToString()) { selectTube = PaintColor.Red; } else if (tube == PaintColor.Green.ToString()) { selectTube = PaintColor.Green; } else if (tube == PaintColor.Blue.ToString()) { selectTube = PaintColor.Blue; } //アニメーション string trigger = "Down" + tube; animator.SetTrigger(trigger); }
public void GetSetTests() { PaintColor paintColor = new PaintColor(); Assert.AreEqual(0, paintColor.A); Assert.AreEqual(0, paintColor.R); Assert.AreEqual(0, paintColor.G); Assert.AreEqual(0, paintColor.B); Color color = paintColor.ToColor(); Assert.AreEqual(0, color.A); Assert.AreEqual(0, color.R); Assert.AreEqual(0, color.G); Assert.AreEqual(0, color.B); paintColor.A = 255; paintColor.R = 100; paintColor.G = 50; paintColor.B = 67; Assert.AreEqual(255, paintColor.A); Assert.AreEqual(100, paintColor.R); Assert.AreEqual(50, paintColor.G); Assert.AreEqual(67, paintColor.B); color = paintColor.ToColor(); Assert.AreEqual(255, color.A); Assert.AreEqual(100, color.R); Assert.AreEqual(50, color.G); Assert.AreEqual(67, color.B); }
public int GetPrice(PaintColor color) { switch (color) { case PaintColor.Red: return(1000); case PaintColor.Green: return(1000); case PaintColor.Blue: return(1000); case PaintColor.Yellow: return(1000); case PaintColor.White: return(4000); case PaintColor.Black: return(8000); case PaintColor.Gray: return(6000); case PaintColor.Magenta: return(1000); default: return(1000); } }
public void Init(EShapeType type, int thickness, PaintColor color) { _newshape = _shape.CreateShape(type); _newshape.Thickness = thickness; _newshape.Color = color; _storage.Add(_newshape); }
public void ChangeFigureColor(PaintBitmap paintBitmap, PaintColor color) { IShape shape = _storage.GetShapeForIndex(Numb); _storage.RemoveAt(Numb); shape.Color = color; _storage.Add(shape); UpdatePicture(paintBitmap); Numb = _storage.GetCount() - 1; }
public ActionResult PaintPrice() { var model = new PaintColor { tradeMarks = _db.TradeMarks.ToList(), Posts = _db.Posts.Where(x => x.Active && x.PostCategory.CategoryName.Contains("Màu sơn")).ToList() }; return(View(model)); }
public void ConstructorPaintColorTest() { PaintColor paintColor = new PaintColor(40, 20, 30, 35); PaintPen paintPen = new PaintPen(paintColor); Pen actualPen = paintPen.ToPen(); Assert.AreEqual(paintColor.A, actualPen.Color.A); Assert.AreEqual(paintColor.R, actualPen.Color.R); Assert.AreEqual(paintColor.G, actualPen.Color.G); Assert.AreEqual(paintColor.B, actualPen.Color.B); }
public void NewShape(EShapeType type, int thickness, PaintColor color, int cornes, ShapeSize size) { _newshape = _shape.CreateShape(type); _newshape.Thickness = thickness; _newshape.Color = color; if (_newshape is Hexagon) { (_newshape as Hexagon).Cornes = cornes; (_newshape as Hexagon).Size = size; } _storage.Add(_newshape); }
private void ColorButton_Click(object sender, EventArgs e) { Button b = (Button)sender; CurrentColorButton.BackColor = b.BackColor; _curentcolor = new PaintColor(CurrentColorButton.BackColor); if (_bl.isBoolCount() && _isSelected) { _currentBitmap = new PaintBitmap(pictureBoxMain.Width, pictureBoxMain.Height); pictureBoxMain.Image = _currentBitmap.ToImage(); _bl.ChangeFigureColor(_currentBitmap, _curentcolor); } }
private void ChangeColorButton_Click(object sender, EventArgs e) { if (colorDialog1.ShowDialog() == DialogResult.OK) { CurrentColorButton.BackColor = colorDialog1.Color; _curentcolor = new PaintColor(colorDialog1.Color); } if (_bl.isBoolCount() && _isSelected) { _currentBitmap = new PaintBitmap(pictureBoxMain.Width, pictureBoxMain.Height); pictureBoxMain.Image = _currentBitmap.ToImage(); _bl.ChangeFigureColor(_currentBitmap, _curentcolor); } }
public void TransformWeapon(PaintColor newColor) { SpriteRenderer spriteRenderer = GetComponent <SpriteRenderer>(); switch (newColor) { case PaintColor.Red: spriteRenderer.color = RedColor; if (WeaponType == WeaponType.Sword) { TransformationType = ESoldierType.RedWarrior; } if (WeaponType == WeaponType.Hat) { TransformationType = ESoldierType.RedMage; } if (WeaponType == WeaponType.Crossbow) { TransformationType = ESoldierType.RedArcher; } break; case PaintColor.Blue: spriteRenderer.color = BlueColor; if (WeaponType == WeaponType.Sword) { TransformationType = ESoldierType.BlueWarrior; } if (WeaponType == WeaponType.Hat) { TransformationType = ESoldierType.BlueMage; } if (WeaponType == WeaponType.Crossbow) { TransformationType = ESoldierType.BlueArcher; } break; } }
public void ConstructorRGBTest() { PaintColor paintColor = new PaintColor(20, 30, 35); Assert.AreEqual(255, paintColor.A); Assert.AreEqual(20, paintColor.R); Assert.AreEqual(30, paintColor.G); Assert.AreEqual(35, paintColor.B); Color color = paintColor.ToColor(); Assert.AreEqual(255, color.A); Assert.AreEqual(20, color.R); Assert.AreEqual(30, color.G); Assert.AreEqual(35, color.B); }
public void ConstructorColorTest() { PaintColor paintColor = new PaintColor(Color.FromArgb(40, 20, 30, 35)); Assert.AreEqual(40, paintColor.A); Assert.AreEqual(20, paintColor.R); Assert.AreEqual(30, paintColor.G); Assert.AreEqual(35, paintColor.B); Color color = paintColor.ToColor(); Assert.AreEqual(40, color.A); Assert.AreEqual(20, color.R); Assert.AreEqual(30, color.G); Assert.AreEqual(35, color.B); }
public Modifications() { OwnedPaintTypes.Add(PaintType.Glossy); SelectedPaintType = PaintType.Glossy; OwnedSpoilers.Add(Spoiler.Disabled); SelectedSpoiler = Spoiler.Disabled; OwnedPaintColors.Add(PaintColor.Red); SelectedPaintColor = PaintColor.Red; OwnedStickers.Add(Sticker.Disabled); SelectedSticker = Sticker.Disabled; OwnedFrontSpoilers.Add(FrontSpoiler.Disabled); SelectedFrontSpoiler = FrontSpoiler.Disabled; OwnedEngines.Add(Engine.V6); SelectedEngine = Engine.V6; }
public static Configuration Read(string filePath) { XmlReaderSettings configReaderSettings = new XmlReaderSettings { ValidationType = ValidationType.Schema, ValidationFlags = XmlSchemaValidationFlags.ProcessIdentityConstraints | XmlSchemaValidationFlags.ReportValidationWarnings }; string configSchemaPath = Path.Combine(Path.GetDirectoryName(filePath), Path.GetFileNameWithoutExtension(filePath) + ".xsd"); configReaderSettings.Schemas.Add(null, configSchemaPath); XmlDocument document = new XmlDocument(); using (XmlReader configReader = XmlReader.Create(filePath, configReaderSettings)) document.Load(configReader); // Before validating using the schema, first check if the configuration file's version matches with the supported version. XmlElement rootElement = document.DocumentElement; string fileVersionRaw; if (rootElement.HasAttribute("Version")) { fileVersionRaw = rootElement.GetAttribute("Version"); } else { fileVersionRaw = "1.0"; } if (fileVersionRaw != Configuration.CurrentVersion) { throw new FormatException(string.Format( "The configuration file is either outdated or too new. Expected version was: {0}. File version is: {1}", Configuration.CurrentVersion, fileVersionRaw )); } Configuration resultingConfig = new Configuration(false); resultingConfig.OverrideVanillaCircuits = BoolEx.ParseEx(rootElement["OverrideVanillaCircuits"].InnerXml); resultingConfig.AdvancedCircuitsEnabled = BoolEx.ParseEx(rootElement["AdvancedCircuitsEnabled"].InnerText); resultingConfig.MaxTrapsPerCircuit = int.Parse(rootElement["MaxTrapsPerCircuit"].InnerText); resultingConfig.MaxStatuesPerCircuit = int.Parse(rootElement["MaxStatuesPerCircuit"].InnerText); resultingConfig.MaxPumpsPerCircuit = int.Parse(rootElement["MaxPumpsPerCircuit"].InnerText); resultingConfig.MaxCircuitLength = int.Parse(rootElement["MaxCircuitLength"].InnerText); if (string.IsNullOrWhiteSpace(rootElement["MaxTimerActivityTime"].InnerText)) { resultingConfig.MaxTimerActivityTime = TimeSpan.Zero; } else { TimeSpan maxTimerActivityTime; if (TimeSpanEx.TryParseShort(rootElement["MaxTimerActivityTime"].InnerText, out maxTimerActivityTime)) { resultingConfig.MaxTimerActivityTime = maxTimerActivityTime; } } resultingConfig.SignConfig = SignConfig.FromXmlElement(rootElement["SignConfig"]); resultingConfig.BlockActivatorConfig = BlockActivatorConfig.FromXmlElement(rootElement["BlockActivatorConfig"]); XmlElement pumpConfigsNode = rootElement["PumpConfigs"]; foreach (XmlNode pumpConfigNode in pumpConfigsNode.ChildNodes) { XmlElement pumpConfigElement = (pumpConfigNode as XmlElement); if (pumpConfigElement == null) { continue; } PaintColor paintColor = (PaintColor)Enum.Parse(typeof(PaintColor), pumpConfigElement.Attributes["Paint"].Value); resultingConfig.PumpConfigs.Add(paintColor, PumpConfig.FromXmlElement(pumpConfigElement)); } XmlElement trapConfigsNode = rootElement["TrapConfigs"]; foreach (XmlNode trapConfigNode in trapConfigsNode.ChildNodes) { XmlElement trapConfigElement = (trapConfigNode as XmlElement); if (trapConfigElement == null) { continue; } TrapStyle trapStyle = (TrapStyle)Enum.Parse(typeof(TrapStyle), trapConfigElement.Attributes["TrapType"].Value); PaintColor paintColor = (PaintColor)Enum.Parse(typeof(PaintColor), trapConfigElement.Attributes["Paint"].Value); resultingConfig.TrapConfigs.Add(new TrapConfigKey(trapStyle, paintColor), TrapConfig.FromXmlElement(trapConfigElement)); } /*XmlElement explosivesConfigsNode = rootElement["ExplosivesConfigs"]; * foreach (XmlNode explosivesConfigNode in explosivesConfigsNode.ChildNodes) { * XmlElement explosivesConfigElement = (explosivesConfigNode as XmlElement); * if (explosivesConfigElement == null) * continue; * * ComponentConfigProfile componentConfigProfile = (ComponentConfigProfile)Enum.Parse(typeof(ComponentConfigProfile), explosivesConfigElement.Attributes["Profile"].Value); * resultingConfig.explosivesConfigs.Add(componentConfigProfile, ExplosivesConfig.FromXmlElement(explosivesConfigElement)); * }*/ XmlElement wirelessTransmitterConfigsNode = rootElement["WirelessTransmitterConfigs"]; foreach (XmlNode wirelessTransmitterConfigNode in wirelessTransmitterConfigsNode.ChildNodes) { XmlElement wirelessTransmitterConfigElement = (wirelessTransmitterConfigNode as XmlElement); if (wirelessTransmitterConfigElement == null) { continue; } PaintColor paintColor = (PaintColor)Enum.Parse(typeof(PaintColor), wirelessTransmitterConfigElement.Attributes["Paint"].Value); resultingConfig.WirelessTransmitterConfigs.Add(paintColor, WirelessTransmitterConfig.FromXmlElement(wirelessTransmitterConfigElement)); } XmlElement statueConfigsNode = rootElement["StatueConfigs"]; foreach (XmlNode statueConfigNode in statueConfigsNode.ChildNodes) { XmlElement statueConfigElement = (statueConfigNode as XmlElement); if (statueConfigElement == null) { continue; } StatueStyle statueStyle = (StatueStyle)Enum.Parse(typeof(StatueStyle), statueConfigElement.Attributes["StatueType"].Value); resultingConfig.StatueConfigs.Add(statueStyle, StatueConfig.FromXmlElement(statueConfigElement)); } return(resultingConfig); }
public RobotState WithPaint(PaintColor color) => new RobotState( this.Position, this.Direction, this.Painted.SetItem(this.Position, color));
private bool HandleWirePlace(TSPlayer player, DPoint location) { if (this.IsDisposed) { return(false); } DPoint[] tilesToCheck = new[] { location, new DPoint(location.X - 1, location.Y), new DPoint(location.X + 1, location.Y), new DPoint(location.X, location.Y - 1), new DPoint(location.X, location.Y + 1), }; foreach (DPoint tileToCheck in tilesToCheck) { ITile tile = TerrariaUtils.Tiles[tileToCheck]; if (!tile.active()) { continue; } if (tileToCheck != location && tile.type != AdvancedCircuits.BlockType_WirelessTransmitter) { continue; } bool hasPermission = true; ObjectMeasureData measureData = TerrariaUtils.Tiles.MeasureObject(tileToCheck); PaintColor componentPaint = (PaintColor)TerrariaUtils.Tiles[measureData.OriginTileLocation].color(); switch (tile.type) { case TileID.Statues: { StatueStyle statueStyle = TerrariaUtils.Tiles.GetStatueStyle(tile); StatueConfig statueConfig; if (!this.Config.StatueConfigs.TryGetValue(statueStyle, out statueConfig)) { return(false); } if (string.IsNullOrEmpty(statueConfig.WirePermission)) { return(false); } hasPermission = player.Group.HasPermission(statueConfig.WirePermission); if (!hasPermission) { this.TellNoStatueWiringPermission(player, statueStyle); player.SendTileSquare(location, 1); return(true); } break; } case TileID.Traps: { TrapConfig trapConfig; TrapConfigKey configKey = new TrapConfigKey(TerrariaUtils.Tiles.GetTrapStyle(TerrariaUtils.Tiles[location].frameY / 18), componentPaint); if (!this.Config.TrapConfigs.TryGetValue(configKey, out trapConfig)) { break; } if (string.IsNullOrEmpty(trapConfig.WirePermission)) { break; } hasPermission = player.Group.HasPermission(trapConfig.WirePermission); break; } case TileID.Boulder: { hasPermission = player.Group.HasPermission(AdvancedCircuitsPlugin.WireBoulder_Permission); break; } case TileID.Signs: { hasPermission = player.Group.HasPermission(AdvancedCircuitsPlugin.WireSign_Permission); break; } case TileID.InletPump: case TileID.OutletPump: { PumpConfig pumpConfig; if (!this.Config.PumpConfigs.TryGetValue(componentPaint, out pumpConfig)) { break; } hasPermission = player.Group.HasPermission(pumpConfig.WirePermission); break; } case AdvancedCircuits.BlockType_WirelessTransmitter: { WirelessTransmitterConfig transmitterConfig; if (!this.Config.WirelessTransmitterConfigs.TryGetValue(componentPaint, out transmitterConfig)) { break; } hasPermission = player.Group.HasPermission(transmitterConfig.WirePermission); break; } case TileID.Teleporter: { hasPermission = player.Group.HasPermission(AdvancedCircuitsPlugin.WireTeleporter_Permission); break; } } if (!hasPermission) { this.TellMissingComponentWiringPermission(player, tile.type); player.SendTileSquare(location, 1); return(true); } } return(false); }
private bool TryExecuteSubCommand(string commandNameLC, CommandArgs args) { switch (commandNameLC) { case "commands": case "cmds": args.Player.SendMessage("Available Sub-Commands:", Color.White); args.Player.SendMessage("/ac blocks", Color.Yellow); args.Player.SendMessage("/ac toggle|switch", Color.Yellow); if (args.Player.Group.HasPermission(AdvancedCircuitsPlugin.ReloadCfg_Permission)) { args.Player.SendMessage("/ac reloadcfg", Color.Yellow); } return(true); case "reloadcfg": if (args.Player.Group.HasPermission(AdvancedCircuitsPlugin.ReloadCfg_Permission)) { this.PluginTrace.WriteLineInfo("Reloading configuration file."); try { this.ReloadConfigurationCallback(); this.PluginTrace.WriteLineInfo("Configuration file successfully reloaded."); if (args.Player != TSPlayer.Server) { args.Player.SendMessage("Configuration file successfully reloaded.", Color.Yellow); } } catch (Exception ex) { this.PluginTrace.WriteLineError( "Reloading the configuration file failed. Keeping old configuration. Exception details:\n{0}", ex ); } } else { args.Player.SendErrorMessage("You do not have the necessary permission to do that."); } return(true); case "blocks": case "ores": case "tiles": int pageNumber; if (!PaginationTools.TryParsePageNumber(args.Parameters, 1, args.Player, out pageNumber)) { return(true); } PaginationTools.SendPage( args.Player, pageNumber, new List <string>() { "Copper Ore - OR-Gate", "Silver Ore - AND-Gate", "Gold Ore - XOR-Gate / XOR-Port", "Obsidian - NOT-Gate / NOT-Port", "Iron Ore - Swapper", "Spike - Crossover Bridge", "Glass - Input Port", "Active Stone - Active Stone and Block Activator", "Adamantite Ore - Wireless Transmitter" }, new PaginationTools.Settings { HeaderFormat = "Advanced Circuits Special Blocks (Page {0} of {1})", HeaderTextColor = Color.Lime, LineTextColor = Color.LightGray, MaxLinesPerPage = 4, } ); return(true); case "toggle": case "switch": args.Player.SendInfoMessage("Place or destroy a wire on the component you want to toggle."); if (args.Parameters.Count > 3) { args.Player.SendErrorMessage("Proper syntax: /ac switch [state] [+p]"); args.Player.SendInfoMessage("Type /ac switch help to get more help to this command."); return(true); } bool persistentMode = false; bool?newState = null; if (args.Parameters.Count > 1) { int newStateRaw; if (int.TryParse(args.Parameters[1], out newStateRaw)) { newState = (newStateRaw == 1); } persistentMode = args.ContainsParameter("+p", StringComparison.InvariantCultureIgnoreCase); } CommandInteraction interaction = this.StartOrResetCommandInteraction(args.Player); interaction.DoesNeverComplete = persistentMode; interaction.TileEditCallback = (player, editType, blockType, location, blockStyle) => { if ( editType != TileEditType.PlaceTile || editType != TileEditType.PlaceWall || editType != TileEditType.DestroyWall || editType != TileEditType.PlaceActuator ) { CommandInteractionResult result = new CommandInteractionResult { IsHandled = true, IsInteractionCompleted = true }; ITile tile = TerrariaUtils.Tiles[location]; if ( !args.Player.HasBuildPermission(location.X, location.Y) || ( this.PluginCooperationHandler.IsProtectorAvailable && this.PluginCooperationHandler.Protector_CheckProtected(args.Player, location, false) )) { player.SendErrorMessage("This object is protected."); player.SendTileSquare(location, 1); return(result); } int hitBlockType = tile.type; if (tile.active() && hitBlockType == TileID.ActiveStoneBlock) { if (newState == null || newState == false) { TerrariaUtils.Tiles.SetBlock(location, TileID.InactiveStoneBlock); } else { args.Player.SendTileSquare(location); } } else if (hitBlockType == TileID.InactiveStoneBlock) { if (tile.active() && newState == null || newState == true) { TerrariaUtils.Tiles.SetBlock(location, TileID.ActiveStoneBlock); } else { args.Player.SendTileSquare(location); } } else if (tile.active() && TerrariaUtils.Tiles.IsMultistateObject(hitBlockType)) { ObjectMeasureData measureData = TerrariaUtils.Tiles.MeasureObject(location); bool currentState = TerrariaUtils.Tiles.ObjectHasActiveState(measureData); if (newState == null) { newState = !TerrariaUtils.Tiles.ObjectHasActiveState(measureData); } if (currentState != newState.Value) { TerrariaUtils.Tiles.SetObjectState(measureData, newState.Value); } else { args.Player.SendTileSquare(location); } } else if ( hitBlockType == AdvancedCircuits.BlockType_ORGate || hitBlockType == AdvancedCircuits.BlockType_ANDGate || hitBlockType == AdvancedCircuits.BlockType_XORGate ) { if ( !args.Player.HasBuildPermission(location.X, location.Y) || ( this.PluginCooperationHandler.IsProtectorAvailable && this.PluginCooperationHandler.Protector_CheckProtected(args.Player, location, false) )) { player.SendErrorMessage("This gate is protected."); player.SendTileSquare(location); return(result); } PaintColor paint = (PaintColor)TerrariaUtils.Tiles[location].color(); if (paint == AdvancedCircuits.Paint_Gate_TemporaryState) { player.SendErrorMessage("The gate is painted {0}, there's no point in initializing it.", AdvancedCircuits.Paint_Gate_TemporaryState); args.Player.SendTileSquare(location); return(result); } GateStateMetadata gateState; if (!this.WorldMetadata.GateStates.TryGetValue(location, out gateState)) { gateState = new GateStateMetadata(); this.WorldMetadata.GateStates.Add(location, gateState); } List <DPoint> gatePortLocations = new List <DPoint>(AdvancedCircuits.EnumerateComponentPortLocations(location, new DPoint(1, 1))); for (int i = 0; i < 4; i++) { ITile gatePort = TerrariaUtils.Tiles[gatePortLocations[i]]; if (!gatePort.active() || gatePort.type != (int)AdvancedCircuits.BlockType_InputPort) { continue; } if (newState == null) { if (gateState.PortStates[i] == null) { gateState.PortStates[i] = true; } else { gateState.PortStates[i] = !gateState.PortStates[i]; } } else { gateState.PortStates[i] = newState.Value; } } player.SendSuccessMessage("The states of this gate's ports are now:"); this.SendGatePortStatesInfo(args.Player, gateState); args.Player.SendTileSquare(location); } else if (tile.active() && tile.type == (int)AdvancedCircuits.BlockType_InputPort) { foreach (DPoint adjacentTileLocation in AdvancedCircuits.EnumerateComponentPortLocations(location, new DPoint(1, 1))) { ITile adjacentTile = TerrariaUtils.Tiles[adjacentTileLocation]; if (!adjacentTile.active() || !AdvancedCircuits.IsLogicalGate(adjacentTile.type)) { continue; } if ( !args.Player.HasBuildPermission(adjacentTileLocation.X, adjacentTileLocation.Y) || ( this.PluginCooperationHandler.IsProtectorAvailable && this.PluginCooperationHandler.Protector_CheckProtected(args.Player, adjacentTileLocation, false) )) { player.SendErrorMessage("This gate is protected."); player.SendTileSquare(location); return(result); } PaintColor paint = (PaintColor)TerrariaUtils.Tiles[location].color(); if (paint == AdvancedCircuits.Paint_Gate_TemporaryState) { player.SendErrorMessage("The gate is painted {0}, there's no point in initializing it.", AdvancedCircuits.Paint_Gate_TemporaryState); args.Player.SendTileSquare(location); return(result); } GateStateMetadata gateState; if (!this.WorldMetadata.GateStates.TryGetValue(adjacentTileLocation, out gateState)) { gateState = new GateStateMetadata(); this.WorldMetadata.GateStates.Add(adjacentTileLocation, gateState); } int portIndex; switch (AdvancedCircuits.DirectionFromTileLocations(adjacentTileLocation, location)) { case Direction.Up: portIndex = 0; break; case Direction.Down: portIndex = 1; break; case Direction.Left: portIndex = 2; break; case Direction.Right: portIndex = 3; break; default: return(result); } if (newState == null) { if (gateState.PortStates[portIndex] == null) { gateState.PortStates[portIndex] = true; } else { gateState.PortStates[portIndex] = !gateState.PortStates[portIndex]; } } else { gateState.PortStates[portIndex] = newState.Value; } player.SendSuccessMessage("The states of this gate's ports are now:"); this.SendGatePortStatesInfo(args.Player, gateState); args.Player.SendTileSquare(location); return(result); } player.SendErrorMessage($"The state of \"{TerrariaUtils.Tiles.GetBlockTypeName(hitBlockType, 0)}\" can not be changed."); player.SendTileSquare(location); } return(result); } return(new CommandInteractionResult { IsHandled = false, IsInteractionCompleted = false }); }; interaction.TimeExpiredCallback = (player) => { player.SendErrorMessage("Waited too long, no component will be toggled."); }; args.Player.SendSuccessMessage("Hit an object to change its state."); return(true); } return(false); }
public FormBase() { this.paintColor = new PaintColor(); }
private bool CheckTilePermission(TSPlayer player, DPoint location, int blockType, int objectStyle, PaintColor paint, bool dropItem = false) { switch (blockType) { case TileID.Statues: { DPoint originTileLocation = new DPoint(location.X - 1, location.Y - 2); if (!TerrariaUtils.Tiles.IsObjectWired(originTileLocation, new DPoint(2, 3))) { break; } StatueStyle statueStyle = TerrariaUtils.Tiles.GetStatueStyle(objectStyle); StatueConfig statueConfig; if (!this.Config.StatueConfigs.TryGetValue(statueStyle, out statueConfig) || statueConfig == null) { break; } if (!player.Group.HasPermission(statueConfig.WirePermission)) { player.SendTileSquareEx(location, 10); if (dropItem) { int itemTypeToDrop; itemTypeToDrop = TerrariaUtils.Tiles.GetItemTypeFromStatueStyle(statueStyle); Item.NewItem(location.X * TerrariaUtils.TileSize, location.Y * TerrariaUtils.TileSize, 0, 0, itemTypeToDrop); } this.TellNoStatueWiringPermission(player, statueStyle); return(false); } break; } case TileID.Traps: { ITile destTile = TerrariaUtils.Tiles[location]; if (!destTile.HasWire()) { break; } TrapConfig trapConfig; TrapStyle trapStyle = TerrariaUtils.Tiles.GetTrapStyle(destTile.frameY / 18); TrapConfigKey configKey = new TrapConfigKey(trapStyle, paint); if (!this.Config.TrapConfigs.TryGetValue(configKey, out trapConfig)) { break; } if (!player.Group.HasPermission(trapConfig.WirePermission)) { player.SendTileSquareEx(location, 10); if (dropItem) { int itemTypeToDrop = TerrariaUtils.Tiles.GetItemTypeFromTrapStyle(trapStyle); Item.NewItem(location.X * TerrariaUtils.TileSize, location.Y * TerrariaUtils.TileSize, 0, 0, itemTypeToDrop); } this.TellMissingComponentWiringPermission(player, blockType); return(false); } break; } case TileID.Boulder: { DPoint originTileLocation = new DPoint(location.X - 1, location.Y - 1); if (!TerrariaUtils.Tiles.IsObjectWired(originTileLocation, new DPoint(2, 2))) { break; } if (!player.Group.HasPermission(AdvancedCircuitsPlugin.WireBoulder_Permission)) { player.SendTileSquareEx(location, 10); if (dropItem) { Item.NewItem(location.X * TerrariaUtils.TileSize, location.Y * TerrariaUtils.TileSize, 0, 0, ItemID.Boulder); } this.TellMissingComponentWiringPermission(player, blockType); return(false); } break; } case TileID.Signs: { if (!TerrariaUtils.Tiles.IsObjectWired(location, new DPoint(2, 2))) { break; } if (!player.Group.HasPermission(AdvancedCircuitsPlugin.WireSign_Permission)) { player.SendTileSquareEx(location, 10); if (dropItem) { Item.NewItem(location.X * TerrariaUtils.TileSize, location.Y * TerrariaUtils.TileSize, 0, 0, ItemID.Sign); } this.TellMissingComponentWiringPermission(player, blockType); return(false); } break; } case TileID.InletPump: case TileID.OutletPump: { DPoint originTileLocation = new DPoint(location.X - 1, location.Y - 1); if (!TerrariaUtils.Tiles.IsObjectWired(originTileLocation, new DPoint(2, 2))) { break; } PumpConfig pumpConfig; if (!this.Config.PumpConfigs.TryGetValue(paint, out pumpConfig)) { break; } if (string.IsNullOrEmpty(pumpConfig.WirePermission)) { break; } if (!player.Group.HasPermission(pumpConfig.WirePermission)) { player.SendTileSquareEx(location, 10); if (dropItem) { int itemTypeToDrop = ItemID.OutletPump; if (blockType == ItemID.InletPump) { itemTypeToDrop = ItemID.InletPump; } Item.NewItem(location.X * TerrariaUtils.TileSize, location.Y * TerrariaUtils.TileSize, 0, 0, itemTypeToDrop); } this.TellMissingComponentWiringPermission(player, blockType); return(false); } break; } case AdvancedCircuits.BlockType_WirelessTransmitter: { if (!AdvancedCircuits.IsComponentWiredByPort(location, new DPoint(1, 1))) { break; } WirelessTransmitterConfig transmitterConfig; if (!this.Config.WirelessTransmitterConfigs.TryGetValue(paint, out transmitterConfig)) { break; } if (!player.Group.HasPermission(transmitterConfig.WirePermission)) { player.SendTileSquareEx(location, 1); if (dropItem) { Item.NewItem(location.X * TerrariaUtils.TileSize, location.Y * TerrariaUtils.TileSize, 0, 0, ItemID.AdamantiteOre); } this.TellMissingComponentWiringPermission(player, blockType); return(false); } break; } case ItemID.Teleporter: { DPoint originTileLocation = new DPoint(location.X - 1, location.Y - 1); if (!TerrariaUtils.Tiles.IsObjectWired(originTileLocation, new DPoint(3, 1))) { break; } if (!player.Group.HasPermission(AdvancedCircuitsPlugin.WireTeleporter_Permission)) { player.SendTileSquareEx(location, 10); if (dropItem) { Item.NewItem(location.X * TerrariaUtils.TileSize, location.Y * TerrariaUtils.TileSize, 0, 0, ItemID.Teleporter); } this.TellMissingComponentWiringPermission(player, blockType); return(false); } break; } } return(true); }
/// <summary> /// Sets the logical paint color association to a spacific .Net library color. /// </summary> /// <param name="whichColor">A logical color association.</param> /// <param name="c">A .Net library color.</param> /// <param name="forceUiUpdate">true if the UI should be forced to update.</param> public static void SetPaintColor(PaintColor whichColor, Color c, bool forceUiUpdate) { int argb = c.ToArgb(); UnsafeNativeMethods.RhColors_SetColor((int)whichColor, argb, forceUiUpdate); }
/// <summary> /// Gets the .Net library color that is currently associated with a paint color. /// </summary> /// <param name="whichColor">A color association.</param> /// <returns>A .Net library color.</returns> public static Color GetPaintColor(PaintColor whichColor) { int abgr = UnsafeNativeMethods.RhColors_GetColor((int)whichColor); return Rhino.Runtime.Interop.ColorFromWin32(abgr); }
private bool CheckTilePermission(TSPlayer player, DPoint location, BlockType blockType, int objectStyle, PaintColor paint, bool dropItem = false) { switch (blockType) { case BlockType.Statue: { DPoint originTileLocation = new DPoint(location.X, location.Y - 2); if (!TerrariaUtils.Tiles.IsObjectWired(originTileLocation, new DPoint(2, 3))) break; StatueStyle statueStyle = TerrariaUtils.Tiles.GetStatueStyle(objectStyle); StatueConfig statueConfig; if (!this.Config.StatueConfigs.TryGetValue(statueStyle, out statueConfig) || statueConfig == null) break; if (!player.Group.HasPermission(statueConfig.WirePermission)) { player.SendTileSquareEx(location, 10); if (dropItem) { ItemType itemTypeToDrop; itemTypeToDrop = TerrariaUtils.Tiles.GetItemTypeFromStatueStyle(statueStyle); Item.NewItem(location.X * TerrariaUtils.TileSize, location.Y * TerrariaUtils.TileSize, 0, 0, (int)itemTypeToDrop); } this.TellNoStatueWiringPermission(player, statueStyle); return false; } break; } case BlockType.DartTrap: { Tile destTile = TerrariaUtils.Tiles[location]; if (!destTile.HasWire()) break; TrapConfig trapConfig; TrapStyle trapStyle = TerrariaUtils.Tiles.GetTrapStyle(destTile.frameY / 18); TrapConfigKey configKey = new TrapConfigKey(trapStyle, paint); if (!this.Config.TrapConfigs.TryGetValue(configKey, out trapConfig)) break; if (!player.Group.HasPermission(trapConfig.WirePermission)) { player.SendTileSquareEx(location, 10); if (dropItem) { ItemType itemTypeToDrop = TerrariaUtils.Tiles.GetItemTypeFromTrapStyle(trapStyle); Item.NewItem(location.X * TerrariaUtils.TileSize, location.Y * TerrariaUtils.TileSize, 0, 0, (int)itemTypeToDrop); } this.TellMissingComponentWiringPermission(player, blockType); return false; } break; } case BlockType.Boulder: { DPoint originTileLocation = new DPoint(location.X - 1, location.Y - 1); if (!TerrariaUtils.Tiles.IsObjectWired(originTileLocation, new DPoint(2, 2))) break; if (!player.Group.HasPermission(AdvancedCircuitsPlugin.WireBoulder_Permission)) { player.SendTileSquareEx(location, 10); if (dropItem) Item.NewItem(location.X * TerrariaUtils.TileSize, location.Y * TerrariaUtils.TileSize, 0, 0, (int)ItemType.Boulder); this.TellMissingComponentWiringPermission(player, blockType); return false; } break; } case BlockType.Sign: { if (!TerrariaUtils.Tiles.IsObjectWired(location, new DPoint(2, 2))) break; if (!player.Group.HasPermission(AdvancedCircuitsPlugin.WireSign_Permission)) { player.SendTileSquareEx(location, 10); if (dropItem) Item.NewItem(location.X * TerrariaUtils.TileSize, location.Y * TerrariaUtils.TileSize, 0, 0, (int)ItemType.Sign); this.TellMissingComponentWiringPermission(player, blockType); return false; } break; } case BlockType.InletPump: case BlockType.OutletPump: { DPoint originTileLocation = new DPoint(location.X - 1, location.Y - 1); if (!TerrariaUtils.Tiles.IsObjectWired(originTileLocation, new DPoint(2, 2))) break; PumpConfig pumpConfig; if (!this.Config.PumpConfigs.TryGetValue(paint, out pumpConfig)) break; if (string.IsNullOrEmpty(pumpConfig.WirePermission)) break; if (!player.Group.HasPermission(pumpConfig.WirePermission)) { player.SendTileSquareEx(location, 10); if (dropItem) { ItemType itemTypeToDrop = ItemType.OutletPump; if (blockType == BlockType.InletPump) itemTypeToDrop = ItemType.InletPump; Item.NewItem(location.X * TerrariaUtils.TileSize, location.Y * TerrariaUtils.TileSize, 0, 0, (int)itemTypeToDrop); } this.TellMissingComponentWiringPermission(player, blockType); return false; } break; } case AdvancedCircuits.BlockType_WirelessTransmitter: { if (!AdvancedCircuits.IsComponentWiredByPort(location, new DPoint(1, 1))) break; WirelessTransmitterConfig transmitterConfig; if (!this.Config.WirelessTransmitterConfigs.TryGetValue(paint, out transmitterConfig)) break; if (!player.Group.HasPermission(transmitterConfig.WirePermission)) { player.SendTileSquareEx(location, 1); if (dropItem) Item.NewItem(location.X * TerrariaUtils.TileSize, location.Y * TerrariaUtils.TileSize, 0, 0, (int)ItemType.AdamantiteOre); this.TellMissingComponentWiringPermission(player, blockType); return false; } break; } case BlockType.Teleporter: { DPoint originTileLocation = new DPoint(location.X - 1, location.Y - 1); if (!TerrariaUtils.Tiles.IsObjectWired(originTileLocation, new DPoint(3, 1))) break; if (!player.Group.HasPermission(AdvancedCircuitsPlugin.WireTeleporter_Permission)) { player.SendTileSquareEx(location, 10); if (dropItem) Item.NewItem(location.X * TerrariaUtils.TileSize, location.Y * TerrariaUtils.TileSize, 0, 0, (int)ItemType.Teleporter); this.TellMissingComponentWiringPermission(player, blockType); return false; } break; } } return true; }
/// <summary> /// Sets the logical paint color association to a spacific .Net library color, without forced UI update. /// </summary> /// <param name="whichColor">A logical color association.</param> /// <param name="c">A .Net library color.</param> public static void SetPaintColor(PaintColor whichColor, Color c) { SetPaintColor(whichColor, c, false); }
public PaintSolidBrush(PaintColor color) { _brush = new SolidBrush(color.ToColor()); }
public PaintPen(PaintColor color, float width) { _pen = new Pen(color.ToColor(), width); }
public PaintPen(PaintColor color) { _pen = new Pen(color.ToColor()); }
public TilePaintEventArgs(TSPlayer player, DPoint location, PaintColor color) : base(player, location) { this.Color = color; }
public bool HandleTilePaint(TSPlayer player, DPoint location, PaintColor paint) { if (this.IsDisposed) return false; Tile componentTile = TerrariaUtils.Tiles[location]; int objectStyle; if (componentTile.type == (int)BlockType.Statue) objectStyle = componentTile.frameX / 36; else if (componentTile.type == (int)BlockType.DartTrap) objectStyle = componentTile.frameY / 18; else objectStyle = 0; bool hasPermission = this.CheckTilePermission(player, location, (BlockType)componentTile.type, objectStyle, paint); return !hasPermission; }
private void Start() { brushColor = PaintColor.Red; }
public static int SwapperPaintToCount(PaintColor componentPaint) { switch (componentPaint) { default: return 1; case AdvancedCircuits.Paint_Swapper_2: return 2; case AdvancedCircuits.Paint_Swapper_3: return 3; case AdvancedCircuits.Paint_Swapper_4: return 4; case AdvancedCircuits.Paint_Swapper_5: return 5; case AdvancedCircuits.Paint_Swapper_6: return 6; case AdvancedCircuits.Paint_Swapper_7: return 7; } }
/// <summary> /// Initializes a new instance of the <see cref="BlockPaintEvent"/> class with the specified /// <paramref name="world"/>, <paramref name="player"/>, coordinates, and block <paramref name="color"/>. /// </summary> /// <param name="world">The world involved in the event.</param> /// <param name="player">The player painting the block, or <see langword="null"/> for none.</param> /// <param name="x">The block's X coordinate.</param> /// <param name="y">The block's Y coordinate.</param> /// <param name="color">The block color being painted.</param> /// <exception cref="ArgumentNullException"><paramref name="world"/> is <see langword="null"/>.</exception> public BlockPaintEvent(IWorld world, IPlayer?player, int x, int y, PaintColor color) : base(world, player, x, y) { Color = color; }
/// <summary> /// Gets the .Net library color that is currently associated with a paint color. /// </summary> /// <param name="whichColor">A color association.</param> /// <returns>A .Net library color.</returns> public static Color GetPaintColor(PaintColor whichColor) { int abgr = UnsafeNativeMethods.RhColors_GetColor((int)whichColor); return ColorTranslator.FromWin32(abgr); }
public TrapConfigKey(TrapStyle trapStyle, PaintColor paint) : this() { this.TrapStyle = trapStyle; this.Paint = paint; }
public TrapConfigKey(TrapStyle trapStyle, PaintColor paint): this() { this.TrapStyle = trapStyle; this.Paint = paint; }