public static BoardElement CreateNewElement(BoardElement previousElement, BoardElement.BoardElementTypes type) { int randomNum = random.Next(0, ConstantValues.GetAvailableColors().Length); Vector4 newColor = ConstantValues.GetAvailableColors() [randomNum]; switch (type) { case BoardElement.BoardElementTypes.Cross: previousElement = new CrossBoardElement(previousElement.GetTransformIndex(), previousElement.GetElementValue()); break; case BoardElement.BoardElementTypes.Bomb: previousElement = new BombBoardElement(previousElement.GetTransformIndex()); break; case BoardElement.BoardElementTypes.Bell: previousElement = new BellBoardElement(previousElement.GetTransformIndex()); break; case BoardElement.BoardElementTypes.Default: if (previousElement.GetElementClassType() != typeof(BoardElement)) { previousElement = new BoardElement(previousElement.GetTransformIndex(), newColor); } else { previousElement.OnElementAppearance(newColor); } break; } return(previousElement); }
public TruckVariables() { Lights = new LightValues(); Warnings = new WarningValues(); Current = new CurrentValues(); Damage = new DamageValues(); Constant = new ConstantValues(); }
void Awake() { inst = this; elementsPositions = new BoardElement[ConstantValues.totalCollums, ConstantValues.totalRows]; matchedElemPositions = new bool[ConstantValues.totalCollums, ConstantValues.totalRows]; possibleInput = new bool[ConstantValues.totalCollums, ConstantValues.totalRows]; changedPotitions = new bool[ConstantValues.totalCollums, ConstantValues.totalRows]; // Debug //DebugCheckPanels(); int row = 0; int collum = 0; // Assign elements to the board // foreach gameobject child of gameobject "GamePanel" for (int i = 0; i < ConstantValues.totalCollums * ConstantValues.totalRows; i++) { // if in set bounds if (collum < ConstantValues.totalCollums && row < ConstantValues.totalRows) { // Get a random color int randomNum = random.Next(0, ConstantValues.GetAvailableColors().Length); Vector4 newColor = ConstantValues.GetAvailableColors() [randomNum]; // Create a new BoardElement instance an assign it to positions board elementsPositions[collum, row] = new BoardElement(new int[] { 0, 1, i }, newColor); // new animation to show the default sprite on gameobject currentMessageID += 1; messagesToClient.Add(new Messages.AnimationMessage(currentMessageID, -1, Messages.AnimationMessage.AnimationMessageTypes.ChangeSprite, elementsPositions[collum, row].GetImageTransformIndex(), (int)ConstantValues.AvailableSprites.defaultElement, newColor)); changedPotitions[collum, row] = true; collum++; // fix collum index if (collum == ConstantValues.totalCollums) { row++; collum = 0; } } else { UnityEngine.Debug.LogError("There are more transforms on the board than collums * rows"); } } AddWaitMessage(); SendMessagesToClient(); }
// 在proto的常量池中找常量的索引,从0开始,如果常量没在proto常量池,就加入常量池再返回索引 public int InternConstantValue(object value) { if (value == null) { throw new Exception("Can't put null in constant pool"); } if (InNotAffectMode) { return(0); } if (!ConstantValues.Contains(value)) { ConstantValues.Add(value); } return(ConstantValues.IndexOf(value)); }
///------------------------------------------------------------------------- /// <summary>起動処理</summary> ///------------------------------------------------------------------------- public void Awake() { try { GameObject.DontDestroyOnLoad(this); // モーション情報初期化 ReadPluginPreferences(); ConstantValues.Initialize(); Translation.Initialize(configLanguage); Util.LoadShaders(); } catch (Exception e) { Debug.LogError(e.ToString()); } }
public CommandParser(ICommandMatcher commandMatcher, Func <PlateauArea, ISetPlateauAreaSizeCommand> plateauSizeCommandFactory, Func <Point, Direction, IRoverCreateCommand> roverCreateCommandFactory, Func <IList <Movement>, IRoverDriveCommand> roverDriveCommandFactory) { _commandMatcher = commandMatcher; _plateauSizeCommandFactory = plateauSizeCommandFactory; _roverCreateCommandFactory = roverCreateCommandFactory; _roverDriveCommandFactory = roverDriveCommandFactory; _commandParserDictionary = new Dictionary <CommandType, Func <string, ICommand> > { { CommandType.SetPlateauAreaSizeCommand, ParsePlateauSizeCommand }, { CommandType.RoverCreateCommand, ParseRoverCreateCommand }, { CommandType.RoverDriveCommand, ParseRoverDriveCommand } }; _directionDictionary = ConstantValues.GetDirectoryDictionary(); _movementDictionary = ConstantValues.GetMovementDictionary(); }
public async Task <IActionResult> Index(string?name) { ViewBag.Status = await ValidateStatus(); if (User.Identity.IsAuthenticated && name is null && ViewBag.Status != 3) { name = User.Identity.Name; } var cloudinary = new Cloudinary(ApplicationConstants.cloudinaryAccount); ViewBag.Name = name; ConstantValues model = new ConstantValues(); model.Collections = new List <Collection>(db.Collections.Include(col => col.User).OrderBy(col => col.Items.Count).Take(20)); model.Items = new List <Item>(db.Items.Include(i => i.Collection).ThenInclude(col => col.User).OrderByDescending(i => i.CreationTime).Take(20)); var tags = from tag in db.Tags select tag.Text; model.Tags = String.Join(" ", tags.ToList()); return(View(model)); }
public override void Initialize() { base.Initialize(); ConstantValues.SetSkin(); SetupScene(); }
/// <summary> /// Get Device templates /// </summary> /// <param name="mDeviceInfo">The mDeviceInfo<see cref="Device"/></param> /// <returns>The <see cref="DataTemplate"/></returns> private DataTemplate GetDeviceTemplate(Device mDeviceInfo) { DataTemplate oReturnvalue; if (mDeviceInfo.SwitchTypeVal == 0 && (mDeviceInfo.SwitchType == null)) { if (mDeviceInfo.SubType != null && string.Compare(mDeviceInfo.SubType, ConstantValues.Device.Utility.SubType.SMARTWARES, StringComparison.OrdinalIgnoreCase) == 0) { oReturnvalue = SetButtonTemplate; } else { switch (mDeviceInfo.Type) { case ConstantValues.Device.Scene.Type.GROUP: oReturnvalue = App.AppSettings.ShowSwitches ? OnOffSwitchTemplate : OnOffButtonTemplate; break; case ConstantValues.Device.Scene.Type.SCENE: oReturnvalue = OnButtonTemplate; break; case ConstantValues.Device.Utility.Type.THERMOSTAT: oReturnvalue = SetButtonTemplate; break; case ConstantValues.Device.Utility.Type.HEATING: oReturnvalue = SetButtonTemplate; break; default: oReturnvalue = DefaultTemplate; break; } } } else if ((mDeviceInfo.SwitchType == null)) { oReturnvalue = DefaultTemplate; } else { switch (mDeviceInfo.SwitchTypeVal) { case ConstantValues.Device.Type.Value.ON_OFF: case ConstantValues.Device.Type.Value.MEDIAPLAYER: case ConstantValues.Device.Type.Value.DOORLOCK: case ConstantValues.Device.Type.Value.DOORLOCKINVERTED: case ConstantValues.Device.Type.Value.DOORCONTACT: switch (mDeviceInfo.SwitchType) { case ConstantValues.Device.Type.Name.SECURITY: oReturnvalue = string.Compare(mDeviceInfo.SubType, ConstantValues.Device.SubType.Name.SECURITYPANEL, StringComparison.OrdinalIgnoreCase) == 0 ? SecurityPanelTemplate : DefaultTemplate; break; case ConstantValues.Device.Type.Name.EVOHOME: oReturnvalue = string.Compare(mDeviceInfo.SubType, ConstantValues.Device.SubType.Name.EVOHOME, StringComparison.OrdinalIgnoreCase) == 0 ? ModalButtonTemplate : DefaultTemplate; break; default: oReturnvalue = App.AppSettings.ShowSwitches ? OnOffSwitchTemplate : OnOffButtonTemplate; break; } break; case ConstantValues.Device.Type.Value.X10SIREN: case ConstantValues.Device.Type.Value.MOTION: case ConstantValues.Device.Type.Value.CONTACT: case ConstantValues.Device.Type.Value.DUSKSENSOR: case ConstantValues.Device.Type.Value.SMOKE_DETECTOR: case ConstantValues.Device.Type.Value.DOORBELL: oReturnvalue = OnButtonTemplate; break; case ConstantValues.Device.Type.Value.PUSH_ON_BUTTON: oReturnvalue = OnButtonTemplate; break; case ConstantValues.Device.Type.Value.PUSH_OFF_BUTTON: oReturnvalue = OffButtonTemplate; break; case ConstantValues.Device.Type.Value.DIMMER: case ConstantValues.Device.Type.Value.BLINDPERCENTAGE: case ConstantValues.Device.Type.Value.BLINDPERCENTAGEINVERTED: if (mDeviceInfo.SubType.StartsWith(ConstantValues.Device.SubType.Name.RGB)) { oReturnvalue = App.AppSettings.ShowSwitches ? SwitchDimmerRgbButtonTemplate : DimmerRgbButtonTemplate; } else { oReturnvalue = App.AppSettings.ShowSwitches ? SwitchDimmerTemplate : DimmerButtonTemplate; } break; case ConstantValues.Device.Type.Value.SELECTOR: oReturnvalue = SelectorTemplate; break; case ConstantValues.Device.Type.Value.BLINDS: case ConstantValues.Device.Type.Value.BLINDINVERTED: if (ConstantValues.CanHandleStopButton(mDeviceInfo)) { oReturnvalue = BlindsButtonTemplate; } else { oReturnvalue = App.AppSettings.ShowSwitches ? OnOffSwitchTemplate : OnOffButtonTemplate; } break; case ConstantValues.Device.Type.Value.BLINDVENETIAN: case ConstantValues.Device.Type.Value.BLINDVENETIANUS: oReturnvalue = BlindsButtonTemplate; break; default: oReturnvalue = DefaultTemplate; break; } } return(oReturnvalue); }
public static void Free() { ConstantValues.Clear(); }
public static void ReceiveAnimationMessages(List <Messages.AnimationMessage> messages) { for (int i = 0; i < messages.Count; i++) { switch (messages[i].type) { case Messages.AnimationMessage.AnimationMessageTypes.MoveTo: AddAnimationMoveToPosition(messages[i]); break; case Messages.AnimationMessage.AnimationMessageTypes.Scale: AddAnimationScaleTo(messages[i]); break; case Messages.AnimationMessage.AnimationMessageTypes.ChangeSprite: AddAnimationChangeSprite(messages[i]); break; case Messages.AnimationMessage.AnimationMessageTypes.Scroll: AddAnimationScrollWinHistory(messages[i]); break; case Messages.AnimationMessage.AnimationMessageTypes.MoveToHolder: AddAnimationMoveToPosition(messages[i].messageID, messages[i].dependencyID, GetMessageTransform(messages[i]), messages[i].speed, GetMessageTransform(ConstantValues.GetHolderIndexInHierarchy(messages[i].posCollum)).anchoredPosition); break; case Messages.AnimationMessage.AnimationMessageTypes.PopUpBox: AddAnimationPopUpBox(messages[i]); break; } } }
public ReportComposer() { _directionDictionary = ConstantValues.GetDirectoryDictionaryReverse(); }