public void ExpireOverTime() { // find all buffs on target and remove them when timer expires Data[] buffs = GetComponents <Data>(); foreach (Data d in buffs) { // // find variables that match (by name) // Data[] attributes = GetRecipient().GetComponents <Data>(); foreach (Data attrib in attributes) { if (attrib.name == d.name) { IntData id = (attrib as IntData); if (id) { (id as IntData).Set(-(d as IntData).Get()); } FloatData fd = (attrib as FloatData); if (fd) { (fd as FloatData).Set(-(d as FloatData).Get()); } } } } Destroy(this.gameObject); }
//server responded with connection success public void OnSocketConnect(SocketIOEvent e) { IntData data = JsonUtility.FromJson<IntData>(e.data.ToString()); //special case: the server restarted, restart client if (Net.connected) { SceneManager.LoadScene(SceneManager.GetActiveScene().name); ServerMessage("SERVER RESTARTED..."); print("Attention: attempt to reconnect after the server went down, reloading the scene."); return; } else { ServerMessage("Connected. Players online: " + data.num); //if no game menu generate random nickname and send the data if (gameMenu == null) { AvatarData d = new AvatarData(); d.nickName = "user"+UnityEngine.Random.Range(0, 10000); SendAvatarData(d); } Net.connected = true; } }
public void TestPartB_Example1() { int[] inputData = new int[] { 16 , 10 , 15 , 5 , 1 , 11 , 7 , 19 , 6 , 12 , 4 }; int expectedOutput = 8; var data = new IntData(inputData); Day10 day = new Day10(data); var actualOutut = day.Puzzle2Solution(); Assert.AreEqual(expectedOutput, actualOutut); }
public void Apply() { foreach (Data d in buffs) { // // find variables that match (by name) // Data[] attributes = GetRecipient().GetComponents <Data>(); foreach (Data attrib in attributes) { if (attrib.name == d.name) { IntData id = (attrib as IntData); if (id) { (id as IntData).Add((d as IntData).Get()); } FloatData fd = (attrib as FloatData); if (fd) { (fd as FloatData).Add((d as FloatData).Get()); } } } } }
public void CompareValue(IntData data) { if (value == data.value) { compareTrueEvent.Invoke(); } }
public void AddScore(IntData score) { if (value <= 0) { lessThanZeroEvent2.Invoke(); } }
private void Start() { var netId = Channel.ChannelIds[SubscribeType.Network]; MessageBus.SendMessage(NetBroadcastMessage.Get(Network.API.Messages.CREATE_CHARACTER_REPLICANT, QosType.Reliable, netId, IntData.GetIntData(netId))); }
public override int GetHashCode() { int hash = 1; if (FloatData != 0F) { hash ^= FloatData.GetHashCode(); } if (DoubleData != 0D) { hash ^= DoubleData.GetHashCode(); } if (IntData != 0) { hash ^= IntData.GetHashCode(); } if (LongData != 0L) { hash ^= LongData.GetHashCode(); } if (BoolData != false) { hash ^= BoolData.GetHashCode(); } if (StringData.Length != 0) { hash ^= StringData.GetHashCode(); } hash ^= list_.GetHashCode(); return(hash); }
public void SetVals(IntData health, IntData numOfHearts, List <Image> hearts, Sprite fullHeart, Sprite emptyHeart) { this.health = health; this.numOfHearts = numOfHearts; this.hearts = hearts; this.fullHeart = fullHeart; this.emptyHeart = emptyHeart; }
public void UpdateRangeObj(IntData newRange) { if (!useRangeCheck) { return; } rangeCheck = newRange; }
public void AddToValue(IntData intData) { if (lockValue) { return; } value += intData.value; ClampValue(); }
private static void SolveDay10() { var data = new IntData(".\\Data\\Day10a.txt"); var day = new Day10(data); Console.WriteLine("Day10"); day.SolveToConsole(); Console.WriteLine("Press any key to continue"); Console.ReadKey(); }
public IEnumerator StartAction() { yield return(new WaitForSeconds(2)); MessageBus.SendMessage(CommonMessage.Get(Network.API.Messages.CREATE_CHARACTER.ToString(), IntData.GetIntData(1))); MessageBus.SendMessage(CommonMessage.Get(Network.API.Messages.CREATE_AIM_TARGET.ToString(), AimTarget.API.InstanceData.GetData("UnarmedAimTarget", 2, 1))); }
/// <summary> /// 기본값을 씁니다. /// </summary> public void DefaultValue() { // 내부 데이터를 클리어 한다. ByteData.Clear(); BoolData.Clear(); IntData.Clear(); FloatData.Clear(); DoubleData.Clear(); StringData.Clear(); }
public override void Set(ScriptableObject obj) { IntData intdata = obj as IntData; if (intdata == null) { return; } value = intdata.value; maxVal = intdata.maxVal; minVal = intdata.minVal; }
public void TestPartB() { int[] numbers = new int[] { 1721, 979, 366, 299, 675, 1456 }; var data = new IntData(numbers); int expectedOutput = 241861950; Day1 day1 = new Day1(data); var actualOutut = day1.Puzzle2Solution(); Assert.AreEqual(expectedOutput, actualOutut); }
private void NewClient(Message msg) { var clientNetId = ((IntData)msg.Data).Value; var replicantNetId = Channel.ChannelIds[SubscribeType.Network]; if (clientNetId == replicantNetId) { return; } MessageBus.SendMessage(NetAddressedMessage.Get(Network.API.Messages.CREATE_CHARACTER_REPLICANT, QosType.Reliable, clientNetId, IntData.GetIntData(replicantNetId))); }
private void ReadyForCharacter(int connectionId) { var netId = GetNetId(connectionId); MessageBus.SendMessage(NetAddressedMessage.Get(Messages.CREATE_CHARACTER, QosType.Reliable, netId, IntData.GetIntData(netId))); var aimTargetnetId = GetNetId(connectionId); MessageBus.SendMessage(NetAddressedMessage.Get(Messages.CREATE_AIM_TARGET, QosType.Reliable, aimTargetnetId, AimTarget.API.InstanceData.GetData("UnarmedAimTarget", aimTargetnetId, netId))); MessageBus.SendMessage(CommonMessage.Get(Messages.NEW_CLIENT, IntData.GetIntData(netId))); }
private void SendRoomGameStatus(UpdateRoomGameStatusEvent e) { var hallRoomId = LongData.Allocate(); hallRoomId.Value = e.HallRoomId; var rStatus = IntData.Allocate(); rStatus.Value = e.Status; var canEnter = IntData.Allocate(); canEnter.Value = e.CanEnter; SendAndReleaseMessage(RpcMessageType.UpdateRoomGameState, hallRoomId, rStatus, canEnter); }
public void OnNameError(SocketIOEvent e) { IntData data = JsonUtility.FromJson<IntData>(e.data.ToString()); if(data.num == 4) ServerMessage("Invalid admin password"); if (data.num == 5) ServerMessage("You can't have a blank name"); if (data.num == 0) ServerMessage("Sorry, the name is reserved or already in use"); if (data.num == 3) ServerMessage("Sorry, only Western Latin character allowed"); }
private void SendJoinRoomFail(JoinRoomResponseEvent e) { _logger.ErrorFormat("JoinRoom Error ... Code:{0}", e.JoinRoomResponseInfo.ErrCode); var rCode = IntData.Allocate(); rCode.Value = (int)e.JoinRoomResponseInfo.ErrCode; var rHallRoomId = LongData.Allocate(); rHallRoomId.Value = e.HallRoomId; var loginPlayer = LoginPlayer.Allocate(); loginPlayer.Id = e.JoinRoomResponseInfo.PlayerId; loginPlayer.Token = ""; SendAndReleaseMessage(RpcMessageType.ResponseJoinRoom, rCode, rHallRoomId, loginPlayer); }
private void UpdateHp(Message msg) { Debug.Log("Update network hit points!"); _hitPoints = ((IntData)msg.Data).Value; var chan = GetComponent <Channel>(); MessageBus.SendMessage(SubscribeType.Channel, chan.ChannelIds[SubscribeType.Channel], CommonMessage.Get(Messages.UPDATE_HIT_POINTS, IntData.GetIntData(_hitPoints))); if (_hitPoints <= 0) { Destroy(gameObject); } }
private void SendJoinRoomSuccess(JoinRoomResponseEvent e) { _logger.InfoFormat("JoinRoom Successfully Player Id {0} Token {1}", e.JoinRoomResponseInfo.PlayerId, e.JoinRoomResponseInfo.Token); var loginPlayer = LoginPlayer.Allocate(); loginPlayer.Id = e.JoinRoomResponseInfo.PlayerId; loginPlayer.Token = e.JoinRoomResponseInfo.Token; var rCode = IntData.Allocate(); rCode.Value = e.RetCode; var rHallRoomId = LongData.Allocate(); rHallRoomId.Value = e.HallRoomId; SendAndReleaseMessage(RpcMessageType.ResponseJoinRoom, rCode, rHallRoomId, loginPlayer); }
public void TestPartA_Example2() { int[] inputData = new int[] { 28 , 33 , 18 , 42 , 31 , 14 , 46 , 20 , 48 , 47 , 24 , 23 , 49 , 45 , 19 , 38 , 39 , 11 , 1 , 32 , 25 , 35 , 8 , 17 , 7 , 9 , 4 , 2 , 34 , 10 , 3 }; int expectedOutput = 220; var data = new IntData(inputData); Day10 day = new Day10(data); var actualOutut = day.Puzzle1Solution(); Assert.AreEqual(expectedOutput, actualOutut); }
private void SendMandateLogOutMessage(MandatoryLogOutEvent e) { _logger.InfoFormat("Mandatory Logout Message HallRoom Id {0} Room Id {1} PlayerEntityId {2}", e.HallRoomId, e.RoomId, e.PlayerId); LongData hallRoomId = LongData.Allocate(); hallRoomId.Value = e.HallRoomId; IntData roomId = IntData.Allocate(); roomId.Value = e.RoomId; LongData playerId = LongData.Allocate(); playerId.Value = e.PlayerId; SendAndReleaseMessage(RpcMessageType.MandateLogOut, hallRoomId, roomId, playerId); if (e.LogOutReason == MandatoryLogOutEvent.Reason.GameExit) { _statistic.IsGameOverMandateLogOutSend = true; } }
private void Start() { player = GameObject.FindObjectOfType <Player>(); IntData[] datas = player.GetComponents <IntData>(); powerSlider = GetComponent <Slider>(); powerText = GetComponentInChildren <Text>(); foreach (IntData d in datas) { if (d.Name == "Power") { powerData = d; break; } } if (powerData != null && powerSlider != null) { powerSlider.minValue = 0; powerSlider.maxValue = player.maxPower; } }
// ------------------------------------------------------------------------- public void ActionCompareToTarget(IntData value) { ActionCompareToTarget(value.GetCurrentValue()); }
public void UpdateValue(IntData data) { Value += data.Value; }
public static void GetCompensation(SimpleScore out_comp, CardsDistribution cd, IntData fig, ZoneSwitcher zone, bool useReletivePair, PairSwitcher pair, int type_of_compens) { if (out_comp == null) return; // Определить тип компенсации и соотв. функцию TypeOfCompensation comp_type = (TypeOfCompensation)type_of_compens; CompensFunction comp_f; switch (comp_type) { case TypeOfCompensation.Chicago: comp_f = Compens_Chicago; break; case TypeOfCompensation.Moscow: comp_f = Compens_Moscow; break; case TypeOfCompensation.Milton_York: comp_f = Compens_MiltonYork; break; default: throw new Exception("Не могу определить тип компесации: " + type_of_compens.ToString()); } if (zone != null && zone.IsDefined() && cd != null && cd.IsDefined()) //распределение приоритетнее, чем поле "фигуры" { int NS_figs, EW_figs; NS_figs = CountFigurs(cd, Pairs.NS); EW_figs = 40 - NS_figs; int iNS_comp = comp_f(NS_figs, ZoneSwitcher.IsPairInZone(Pairs.NS, zone.Zone)); int iEW_comp = comp_f(EW_figs, ZoneSwitcher.IsPairInZone(Pairs.EW, zone.Zone)); out_comp.SetScore(iEW_comp, iNS_comp); } else if (zone != null && zone.IsDefined() && fig != null && fig.IsDefined() && (pair != null && pair.IsDefined() || useReletivePair)) { int NS_figs, EW_figs; if (!useReletivePair && pair.Pair == Pairs.NS || useReletivePair && RelativePair == Pairs.NS) //!!!! { NS_figs = fig.Value; EW_figs = 40 - NS_figs; } else { EW_figs = fig.Value; NS_figs = 40 - EW_figs; } int iNS_comp = comp_f(NS_figs, ZoneSwitcher.IsPairInZone(Pairs.NS, zone.Zone)); int iEW_comp = comp_f(EW_figs, ZoneSwitcher.IsPairInZone(Pairs.EW, zone.Zone)); out_comp.SetScore(iEW_comp, iNS_comp); } else { out_comp.Born = false; } }
//Компенсация !!!!! С ФИТАМИ !!!!! public static void GetCompensation_WithFits(SimpleScore out_comp, CardsDistribution cd, IntData fig, ZoneSwitcher zone, bool useReletivePair, PairSwitcher pair, /*fits:*/ FitsSwitcher fits, BoolData strongest, bool TenCardsIsTwoFits, bool LessCompFor2Fits23PC) { if (out_comp == null) return; if (zone != null && zone.IsDefined() && cd != null && cd.IsDefined()) //распределение приоритетнее, чем поле "фигуры" и "фиты" { Pairs pairStrongest = Pairs.NotDefinedYet; int figs_NS = CountFigurs(cd, Pairs.NS); int figs_EW = 40 - figs_NS; if(figs_NS > figs_EW) pairStrongest = Pairs.NS; else if(figs_NS < figs_EW) pairStrongest = Pairs.EW; else pairStrongest = DefineStrongest(cd); int fitsOfStrongPair = CountFits(cd, pairStrongest, TenCardsIsTwoFits); int iNS_comp = 0, iEW_comp = 0; if(pairStrongest == Pairs.NS) iNS_comp = Compens_Europe(figs_NS, fitsOfStrongPair, ZoneSwitcher.IsPairInZone(Pairs.NS, zone.Zone), LessCompFor2Fits23PC); else iEW_comp = Compens_Europe(figs_EW, fitsOfStrongPair, ZoneSwitcher.IsPairInZone(Pairs.EW, zone.Zone), LessCompFor2Fits23PC); out_comp.SetScore(iEW_comp, iNS_comp); } else if (zone != null && zone.IsDefined() && fig != null && fig.IsDefined() && (pair != null && pair.IsDefined() || useReletivePair) && fits != null && fits.IsDefined() && (fig.Value != 20 || fig.Value == 20 && strongest != null && strongest.IsDefined())) { int NS_figs, EW_figs; if (!useReletivePair && pair.Pair == Pairs.NS || useReletivePair && RelativePair == Pairs.NS) //!!!! { NS_figs = fig.Value; EW_figs = 40 - NS_figs; } else { EW_figs = fig.Value; NS_figs = 40 - EW_figs; } Pairs pairStrongest = Pairs.NotDefinedYet; if(NS_figs > EW_figs) pairStrongest = Pairs.NS; else if(NS_figs < EW_figs) pairStrongest = Pairs.EW; else pairStrongest = (strongest.Value ? Pairs.NS : Pairs.EW); int fitsOfStrongPair = fits.Choise; int iNS_comp = 0, iEW_comp = 0; if(pairStrongest == Pairs.NS) iNS_comp = Compens_Europe(NS_figs, fitsOfStrongPair, ZoneSwitcher.IsPairInZone(Pairs.NS, zone.Zone), LessCompFor2Fits23PC); else iEW_comp = Compens_Europe(EW_figs, fitsOfStrongPair, ZoneSwitcher.IsPairInZone(Pairs.EW, zone.Zone), LessCompFor2Fits23PC); out_comp.SetScore(iEW_comp, iNS_comp); } else { out_comp.Born = false; } }
// Простые действия для IntData public static void IntData_Equal(IntData data, int i) { data.Value = i; }
public static void IntData_Sum(IntData data, int a, int b) { data.Value = a + b; }
public void ChangeText(IntData obj) { textObj.text = obj.value.ToString(); }
// Сколько очков за фигуры? public static void FiguresPoints(IntData out_figs, CardsDistribution cd, bool useReletivePair, PairSwitcher pair) { if (out_figs == null) return; if (!useReletivePair) //использовать pair { // Если пара неизвестна, то не принимать введенные фигуры if (pair == null || !pair.IsDefined()) { out_figs.Born = false; } else { // Если известно распределение карт, то заблокировать кол-во фигур на полученное из распределения if (cd != null && cd.IsDefined()) { out_figs.Value = CountFigurs(cd, pair.Pair); } else { } } } else //использовать RelativePair !!!!! { if (cd != null && cd.IsDefined()) { out_figs.Value = CountFigurs(cd, RelativePair); } else { } } }
/*Cant use this in event system!*/ public void UpdateText(IntData intDataObj) { textObj.text = intDataObj.value.ToString(); }
// Если 20 фигур - спросить, какая пара сильнее? public static void WhoIsStrongest20(BoolData out_strongest, IntData figs, CardsDistribution cd, bool loading_from_db) { // Если известно распределение карт, то определить по картам сильную пару if (cd != null && cd.IsDefined()) { int figs_NS = CountFigurs(cd, Pairs.NS); if (figs_NS == 20) { Pairs pairStrongest = DefineStrongest(cd); if (pairStrongest == Pairs.NS || pairStrongest == Pairs.NotDefinedYet) out_strongest.Value = true; else out_strongest.Value = false; } else { out_strongest.Born = false; } } // Иначе спросить у юзера else if (!loading_from_db) // ЕСЛИ ИДЕТ ЗАГРУЗКА ИЗ БД - НЕ СПРАШИВАТЬ!!! САМО ЗАГРУЗИТ!!! !!!!!!!!!!!!!!!!!!!!!!!!!! { if (figs != null && figs.IsDefined() && figs.Value == 20) { if (out_strongest.Born == false) // ВАЖНО!!! СПРАШИВАТЬ ТОЛЬКО ПРИ ИЗМЕНЕНИИ ФИГУР С XX НА 20 { if (MessageBox.Show("Какая пара сильнее?\nNS - да, EW - нет", "Фигур 20", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes) out_strongest.Value = true; else out_strongest.Value = false; } } else { out_strongest.Born = false; } } }