public void ApplyStatus(StatusCondition statCondition) { if(statCondition != null) { } }
private StatusCondition MakeStatusCondition(MySqlDataReader reader) { StatusCondition statusCondition = null; String name = reader.GetString(3); double burnDamage = reader.GetDouble(4); double poisonDamage = reader.GetDouble(5); double poisonIncrementer = reader.GetDouble(6); int stunDuration = reader.GetInt32(7); double stunProbability = reader.GetDouble(8); switch (name) { case "BURN": if (burnDamage <= 0) { statusCondition = new Burn(); } else { statusCondition = new Burn(burnDamage); } break; case "POISON": if (poisonDamage <= 0 || poisonDamage <= 0) { statusCondition = new Poison(); } else { statusCondition = new Poison(poisonDamage, poisonIncrementer); } break; case "STUN": if (stunDuration <= 0 || stunProbability <= 0) { statusCondition = new Stun(); } else { statusCondition = new Stun(stunDuration, stunProbability); } break; case "FLINCH": return(new Flinch()); } return(statusCondition); }
private void CreatePartyBtn(Pokemon pokemon, BTLUI_ButtonParty btn) { btn.pokemon = pokemon; btn.nameTxt.text = pokemon.nickname; PokemonGender gender = pokemon.gender; if (gender != PokemonGender.Genderless) { btn.nameTxt.text += (gender == PokemonGender.Male) ? " <color=#8080FF>♂</color>" : " <color=#FF8080>♀</color>"; } btn.lvlTxt.text = "Lv" + pokemon.level; btn.hpTxt.text = pokemon.currentHP + " / " + pokemon.maxHP; StatusCondition condition = pokemon.nonVolatileStatus; if (condition.statusID == "healthy") { btn.statusTxt.text = ""; } else { btn.statusTxt.text = condition.data.shortName; } float hpPercent = pokemon.HPPercent; btn.hpBar.fillAmount = hpPercent; btn.hpBar.color = (hpPercent > 0.5f) ? btn.hpHigh : (hpPercent > 0.25f) ? btn.hpMed : btn.hpLow; // draw icon string drawPath = "pokemonSprites/icon/" + pokemon.data.displayID; btn.icon.sprite = BattleAssetLoader.instance.nullPokemonIconSprite; if (BattleAssetLoader.instance.loadedPokemonSprites.ContainsKey(drawPath)) { btn.icon.sprite = BattleAssetLoader.instance.loadedPokemonSprites[drawPath]; } else { StartCoroutine(BattleAssetLoader.instance.LegacyLoadPokemon( pokemon: pokemon, useicon: true, imagePokemon: btn.icon )); } }
private void CureStatusCondition(Character character) { StatusCondition characterStatusCondition = character.CharacterBattleStatus.StatusCondition; if (characterStatusCondition == null || !characterStatusCondition.GetStatusConditionName().Equals(StatusCure) || !StatusCure.Equals("ALL")) { return; } else { character.CharacterBattleStatus.StatusCondition = null; } }
private void RunExample(int domainId, int sampleCount) { // A DomainParticipant allows an application to begin communicating in // a DDS domain. Typically there is one DomainParticipant per application. // DomainParticipant QoS is configured in USER_QOS_PROFILES.xml DomainParticipant participant = DomainParticipantFactory.Instance .CreateParticipant(domainId); // A Topic has a name and a datatype. Create a Topic named // "ChocolateTemperature" with type Temperature // In this example we use a DynamicType defined in XML, which creates // a DynamicData topic. var provider = new QosProvider("../chocolate_factory.xml"); Topic <DynamicData> topic = participant.CreateTopic( "ChocolateTemperature", provider.GetType("Temperature")); // A Subscriber allows an application to create one or more DataReaders // Subscriber QoS is configured in USER_QOS_PROFILES.xml Subscriber subscriber = participant.CreateSubscriber(); // This DataReader reads data of type Temperature on Topic // "ChocolateTemperature". DataReader QoS is configured in // USER_QOS_PROFILES.xml DataReader <DynamicData> reader = subscriber.CreateDataReader(topic); // Obtain the DataReader's Status Condition StatusCondition statusCondition = reader.StatusCondition; // Enable the 'data available' status. statusCondition.EnabledStatuses = StatusMask.DataAvailable; // Associate an event handler with the status condition. // This will run when the condition is triggered, in the context of // the dispatch call (see below) int samplesRead = 0; statusCondition.Triggered += _ => samplesRead += ProcessData(reader); // Create a WaitSet and attach the StatusCondition var waitset = new WaitSet(); waitset.AttachCondition(statusCondition); while (samplesRead < sampleCount && !shutdownRequested) { // Dispatch will call the handlers associated to the WaitSet // conditions when they activate Console.WriteLine("ChocolateTemperature subscriber sleeping for 4 sec..."); waitset.Dispatch(Duration.FromSeconds(4)); } }
private StatusCondition MakeStatusCondition(String statusConditionName, double burnDamage, double poisonDamage, double poisonIncrementer, int stunDuration, double stunProbability) { StatusCondition statusCondition = null; switch (statusConditionName) { case "BURN": if (burnDamage <= 0) { statusCondition = new Burn(); } else { statusCondition = new Burn(burnDamage); } break; case "POISON": if (poisonDamage <= 0 || poisonIncrementer <= 0) { statusCondition = new Poison(); } else { statusCondition = new Poison(poisonDamage, poisonIncrementer); } break; case "STUN": if (stunDuration <= 0 || stunProbability <= 0) { statusCondition = new Stun(); } else { statusCondition = new Stun(stunDuration, stunProbability); } break; case "FLINCH": statusCondition = new Flinch(); break; default: statusCondition = null; break; } return(statusCondition); }
//Constructors public IndividualPokemon(DexID species, PokemonStats individualValues, List <IndividualPokemonMove> knownMoves, int level) { //Basic constructor for a pokemon encountered in the wild this.species = species; this.individualValues = individualValues; this.knownMoves = knownMoves; this.level = level; effortValues = new PokemonStats(); exp = 0; currentHP = CalculateStat(PokemonStatID.maxHP); currentCondition = StatusCondition.none; }
public void Remove(StatusCondition target) { StatusEffect effect = target.GetComponentInParent <StatusEffect>(); target.transform.SetParent(null); Destroy(target.gameObject); StatusCondition condition = effect.GetComponentInChildren <StatusCondition>(); if (condition == null) { effect.transform.SetParent(null); Destroy(effect.gameObject); this.PostNotification(RemovedNotification, effect); } }
/// <summary> /// Generates the additional move effect expected from a move that can conditionally cause a non-volatile status /// </summary> /// <param name="probability">The probability the move will cause the given non-volatile status.</param> /// <returns></returns> public static Action <Pokémon, Pokémon> StatusCauserAction(StatusCondition condition, decimal probability, Type?immuneType = null) { return((Pokémon attacker, Pokémon defender) => { if (defender.Status == StatusCondition.None) { if (immuneType == null || !defender.Types.Contains((Type)immuneType)) { if (new Random().NextDouble() < (double)probability) { defender.Status = condition; } } } }); }
public void Remove(StatusCondition target) { //unparent before destroying (objects are not destroyed instantly, which could cause ref problems) StatusEffect effect = target.GetComponentInParent<StatusEffect>(); target.transform.SetParent(null); Destroy(target.gameObject); StatusCondition condition = effect.GetComponentInChildren<StatusCondition>(); if (condition == null) { effect.transform.SetParent(null); Destroy(effect.gameObject); this.PostNotification(RemovedNotification, effect); } }
private Move MakeStatusChangingMove(MySqlDataReader reader, Move moveTwo, String name, String description, int level, String archetype, int energyPoints) { // secondary_move_target, secondary_move_accuracy, is_side_effect, status_condition, burn_damage, poison_damage, poison_incrementer, stun_duration, stun_probability String secondaryMoveTarget = MySqlDataReader.GetString("secondary_move_target"); double secondaryMoveAccuracy = MySqlDataReader.GetDouble("secondary_move_accuracy"); bool isSideEffect = MySqlDataReader.GetBoolean("is_side_effect"); String statusConditionText = MySqlDataReader.GetString("status_condition"); double burnDamage = MySqlDataReader.GetDouble("burn_damage"); double poisonDamage = MySqlDataReader.GetDouble("poison_damage"); double poisonIncrementer = MySqlDataReader.GetDouble("poison_incrementer"); int stunDuration = MySqlDataReader.GetInt32("stun_duration"); double stunProbability = MySqlDataReader.GetDouble("stun_probability"); StatusCondition statusCondition = MakeStatusCondition(statusConditionText, burnDamage, poisonDamage, poisonIncrementer, stunDuration, stunProbability); Move move = new StatusChangingMove(name, description, secondaryMoveAccuracy, secondaryMoveTarget, level, energyPoints, energyPoints, statusCondition, isSideEffect); return(null); }
public ShapeWaitSet(ShapeTypeDataReader dataReader, Action <ShapeTypeDataReader> dataAvailableFunc) { _dataAvailableFunc = dataAvailableFunc; _dataReader = dataReader; _waitSet = new WaitSet(); _thread = new Thread(DoThreadActivity) { IsBackground = true }; _cancelCondition = new GuardCondition(); _statusCondition = dataReader.StatusCondition; _waitSet.AttachCondition(_statusCondition); _waitSet.AttachCondition(_cancelCondition); _statusCondition.EnabledStatuses = StatusKind.DataAvailableStatus; _thread.Start(); }
public RTIReader( DataReader <T> reader, ITypeHelper <T> dataType, Parameters arguments) { this.reader = reader; dataTypeHelper = dataType; if (arguments.UseReadThread) { WaitSetProperty property = new WaitSetProperty( (int)arguments.WaitsetEventCount, Duration.FromMilliseconds(arguments.WaitsetDelayUsec / 1000)); waitset = new WaitSet(property); StatusCondition readerStatus = reader.StatusCondition; readerStatus.EnabledStatuses = StatusMask.DataAvailable; waitset.AttachCondition(readerStatus); } }
public StatusChangingMove(String name, String description, double accuracy, String target, int level, int energyPoints, int maxEnergyPoints, StatusCondition statusCondition, bool isSideEffect) { MoveName = name; MoveDescription = description; if (isSideEffect) { SecondaryMoveAccuracy = accuracy; } else { PrimaryMoveAccuracy = accuracy; } MoveTarget = target; MoveLevel = level; MoveEnergyPoints = energyPoints; MoveMaxEnergyPoints = maxEnergyPoints; StatusCondition = statusCondition; IsSideEffect = isSideEffect; MoveType = "STATUS CHANGING"; }
public bool IsImmuneToStatus(StatusCondition status) { return(Type1.Immunity.Contains(status) || (Type2 != null && Type2.Immunity.Contains(status))); }
public static StatusCondition[] Add(StatusCondition n, StatusCondition[] list) { ArrayList tmp = new ArrayList(); foreach(StatusCondition str in list) tmp.Add(str); tmp.Add(n); return tmp.ToArray(typeof(StatusCondition)) as StatusCondition[]; }
private void RunExample(int domainId, string sensorId) { // A DomainParticipant allows an application to begin communicating in // a DDS domain. Typically there is one DomainParticipant per application. // DomainParticipant QoS is configured in USER_QOS_PROFILES.xml DomainParticipant participant = DomainParticipantFactory.Instance .CreateParticipant(domainId); // A Topic has a name and a datatype. Create Topics using the types // defined in chocolate_factory.xml var provider = new QosProvider("../chocolate_factory.xml"); Topic <Temperature> temperatureTopic = participant.CreateTopic( "ChocolateTemperature", types.Temperature); Topic <ChocolateLotState> lotStateTopic = participant.CreateTopic( "ChocolateLotState", types.ChocolateLotState); // A Publisher allows an application to create one or more DataWriters // Publisher QoS is configured in USER_QOS_PROFILES.xml Publisher publisher = participant.CreatePublisher(); // Create DataWriters of Topics "ChocolateTemperature" & "ChocolateLotState" // DataWriter QoS is configured in USER_QOS_PROFILES.xml DataWriter <Temperature> temperatureWriter = publisher.CreateDataWriter(temperatureTopic); DataWriter <ChocolateLotState> lotStateWriter = publisher.CreateDataWriter(lotStateTopic); // A Subscriber allows an application to create one or more DataReaders // Subscriber QoS is configured in USER_QOS_PROFILES.xml Subscriber subscriber = participant.CreateSubscriber(); // This DataReader reads data of type Temperature on Topic // "ChocolateTemperature". DataReader QoS is configured in // USER_QOS_PROFILES.xml DataReader <ChocolateLotState> lotStateReader = subscriber.CreateDataReader(lotStateTopic); // Obtain the DataReader's Status Condition StatusCondition statusCondition = lotStateReader.StatusCondition; // Enable the 'data available' status. statusCondition.EnabledStatuses = StatusMask.DataAvailable; // Associate an event handler with the status condition. // This will run when the condition is triggered, in the context of // the dispatch call (see below) statusCondition.Triggered += _ => ProcessLot(lotStateReader, lotStateWriter); // Create a WaitSet and attach the StatusCondition var waitset = new WaitSet(); waitset.AttachCondition(statusCondition); // Create a thread to periodically publish the temperature Console.WriteLine($"ChocolateTemperature Sensor with ID: {sensorId} starting"); var temperatureTask = Task.Run( () => PublishTemperature(temperatureWriter, sensorId)); while (!shutdownRequested) { // Wait for ChocolateLotState Console.WriteLine("Waiting for lot"); waitset.Dispatch(Duration.FromSeconds(4)); } temperatureTask.Wait(); }
public ClientStatusChangedEventArgs(ClientIdentifier id, StatusCondition status) { Status = status; ID = id; }
static void Main(string[] args) { bool useListener = true; OpenDDSharp.Ace.Init(); ParticipantService participantService = ParticipantService.Instance; DomainParticipantFactory domainFactory = participantService.GetDomainParticipantFactory(args); DomainParticipantQos qos = new DomainParticipantQos(); qos.EntityFactory.AutoenableCreatedEntities = false; qos.UserData.Value = Encoding.UTF8.GetBytes("sometext"); DomainParticipant participant = domainFactory.CreateParticipant(42, qos); if (participant == null) { throw new Exception("Could not create the participant"); } DomainParticipantQos aux = new DomainParticipantQos(); ReturnCode ret = participant.GetQos(aux); aux.EntityFactory.AutoenableCreatedEntities = true; ret = participant.SetQos(aux); if (participant != null) { TestStructTypeSupport support = new TestStructTypeSupport(); string typeName = support.GetTypeName(); ReturnCode result = support.RegisterType(participant, typeName); if (result != ReturnCode.Ok) { throw new Exception("Could not register the type"); } Topic topic = participant.CreateTopic("TopicName", typeName); Publisher publisher = participant.CreatePublisher(); if (publisher == null) { throw new Exception("Could not create the publisher"); } DataWriter dw = publisher.CreateDataWriter(topic); if (dw == null) { throw new Exception("Could not create the datawriter"); } TestStructDataWriter dataWriter = new TestStructDataWriter(dw); Subscriber subscriber = participant.CreateSubscriber(); if (subscriber == null) { throw new Exception("Could not create the subscribre"); } MyDataListener listener = null; if (useListener) { listener = new MyDataListener(); } DataReader dataReader = subscriber.CreateDataReader(topic, listener, StatusKind.DataAvailableStatus); if (dataReader == null) { throw new Exception("Could not create the datareader"); } WaitSet waitSet = null; StatusCondition statusCondition = null; if (!useListener) { waitSet = new WaitSet(); statusCondition = dataReader.StatusCondition; waitSet.AttachCondition(statusCondition); statusCondition.EnabledStatuses = StatusKind.DataAvailableStatus; new System.Threading.Thread(delegate() { ICollection <Condition> conditions = new List <Condition>(); Duration duration = new Duration { Seconds = Duration.InfiniteSeconds }; waitSet.Wait(conditions, duration); foreach (Condition cond in conditions) { if (cond == statusCondition && cond.TriggerValue) { StatusCondition sCond = (StatusCondition)cond; StatusMask mask = sCond.EnabledStatuses; if ((mask & StatusKind.DataAvailableStatus) != 0) { DataAvailable(dataReader); } } } }).Start(); } TestStruct test = new TestStruct { RawData = "Hello, I love you, won't you tell me your name?" }; test.LongSequence.Add(20); test.LongSequence.Add(10); test.LongSequence.Add(0); test.StringSequence.Add("Hello,"); test.StringSequence.Add("I love you"); test.StringSequence.Add("won't you tell me your name?"); test.LongDoubleType = 1.1; test.LongDoubleSequence.Add(1.1); test.LongDoubleSequence.Add(2.2); test.LongDoubleSequence.Add(3.3); test.LongArray[0, 0] = 1; test.LongArray[0, 1] = 2; test.LongArray[0, 2] = 3; test.LongArray[0, 3] = 4; test.LongArray[1, 0] = 1; test.LongArray[1, 1] = 2; test.LongArray[1, 2] = 3; test.LongArray[1, 3] = 4; test.LongArray[2, 0] = 1; test.LongArray[2, 1] = 2; test.LongArray[2, 2] = 3; test.LongArray[2, 3] = 4; test.StringArray[0, 0] = "Hello,"; test.StringArray[0, 1] = "I love you,"; test.StringArray[1, 0] = "won't you tell me"; test.StringArray[1, 1] = "your name?"; test.StructArray[0, 0] = new BasicTestStruct() { Id = 0 }; test.StructArray[0, 1] = new BasicTestStruct() { Id = 1 }; test.StructArray[1, 0] = new BasicTestStruct() { Id = 2 }; test.StructArray[1, 1] = new BasicTestStruct() { Id = 3 }; test.LongDoubleArray[0, 0] = 1.1; test.LongDoubleArray[0, 1] = 2.2; test.LongDoubleArray[1, 0] = 3.3; test.LongDoubleArray[1, 1] = 4.4; test.StructSequence.Add(new BasicTestStruct() { Id = 1 }); test.StructSequence.Add(new BasicTestStruct() { Id = 2 }); test.StructSequence.Add(new BasicTestStruct() { Id = 3 }); result = dataWriter.Write(test); System.Threading.Thread.Sleep(1000); if (!useListener) { waitSet.DetachCondition(statusCondition); } participant.DeleteContainedEntities(); domainFactory.DeleteParticipant(participant); } participantService.Shutdown(); OpenDDSharp.Ace.Fini(); Console.WriteLine("Press ENTER to finish the test."); Console.ReadLine(); }
public void ExecuteMove_ChangingStatusCondition_EventCreatorSetStatusCalled(StatusCondition condition) { var executer = CreateExecuter(); factory.CreateAllPokemon(); ExecuteMoveCommand(executer, target: factory.PlayerID, newCondition: condition); creatorMock.Verify(c => c.SetStatus(It.IsAny<PokemonWrapper>(), condition), Times.Once); }
private void ExecuteMoveCommand(CommandExecuter executer, bool critical = false, float typeModifier = 1, ClientIdentifier target = null, StatusCondition newCondition = StatusCondition.Normal) { if (target == null) target = factory.PlayerID; var command = new MoveCommand(target, target, factory.CreateMove()); calculator.IsCritical = critical; calculator.TypeModifier = typeModifier; calculator.StatusCondition = newCondition; executer.DispatchCommand(command); }
private void RunExample( int domainId = 0, uint lotsToProcess = 10) { // Loads the QoS from the qos_profiles.xml file. var qosProvider = new QosProvider("./qos_profiles.xml"); // A DomainParticipant allows an application to begin communicating in // a DDS domain. Typically there is one DomainParticipant per application. // Load DomainParticipant QoS profile var participantQos = qosProvider.GetDomainParticipantQos( "ChocolateFactoryLibrary::MonitoringControlApplication"); DomainParticipant participant = DomainParticipantFactory.Instance .CreateParticipant(domainId, participantQos); // A Topic has a name and a datatype. Create a Topic with type // ChocolateLotState. Topic name is a constant defined in the IDL file. Topic <ChocolateLotState> lotStateTopic = participant.CreateTopic <ChocolateLotState>("ChocolateLotState"); // Add a Topic for Temperature to this application Topic <Temperature> temperatureTopic = participant.CreateTopic <Temperature>("ChocolateTemperature"); ContentFilteredTopic <Temperature> filteredTemperatureTopic = participant.CreateContentFilteredTopic( name: "FilteredTemperature", relatedTopic: temperatureTopic, filter: new Filter( expression: "degrees > %0 or degrees < %1", parameters: new string[] { "32", "30" })); // A Publisher allows an application to create one or more DataWriters // Publisher QoS is configured in USER_QOS_PROFILES.xml Publisher publisher = participant.CreatePublisher(); // This DataWriter writes data on Topic "ChocolateLotState" var writerQos = qosProvider.GetDataWriterQos( "ChocolateFactoryLibrary::ChocolateLotStateProfile"); DataWriter <ChocolateLotState> lotStateWriter = publisher.CreateDataWriter(lotStateTopic, writerQos); // A Subscriber allows an application to create one or more DataReaders // Subscriber QoS is configured in USER_QOS_PROFILES.xml Subscriber subscriber = participant.CreateSubscriber(); // Create DataReader of Topic "ChocolateLotState". // DataReader QoS is configured in USER_QOS_PROFILES.xml var readerQos = qosProvider.GetDataReaderQos( "ChocolateFactoryLibrary::ChocolateLotStateProfile"); DataReader <ChocolateLotState> lotStateReader = subscriber.CreateDataReader(lotStateTopic, readerQos); // Add a DataReader for Temperature to this application readerQos = qosProvider.GetDataReaderQos( "ChocolateFactoryLibrary::ChocolateTemperatureProfile"); DataReader <Temperature> temperatureReader = subscriber.CreateDataReader(filteredTemperatureTopic, readerQos); // Obtain the DataReader's Status Condition StatusCondition temperatureStatusCondition = temperatureReader.StatusCondition; temperatureStatusCondition.EnabledStatuses = StatusMask.DataAvailable; // Associate a handler with the status condition. This will run when the // condition is triggered, in the context of the dispatch call (see below) temperatureStatusCondition.Triggered += _ => MonitorTemperature(temperatureReader); // Do the same with the lotStateReader's StatusCondition StatusCondition lotStateStatusCondition = lotStateReader.StatusCondition; lotStateStatusCondition.EnabledStatuses = StatusMask.DataAvailable; int lotsProcessed = 0; lotStateStatusCondition.Triggered += _ => lotsProcessed += MonitorLotState(lotStateReader); // Create a WaitSet and attach the StatusCondition var waitset = new WaitSet(); waitset.AttachCondition(lotStateStatusCondition); // Add the new DataReader's StatusCondition to the Waitset waitset.AttachCondition(temperatureStatusCondition); // Start publishing in a separate thread var startLotTask = Task.Run(() => PublishStartLot(lotStateWriter, lotsToProcess)); while (!shutdownRequested && lotsProcessed < lotsToProcess) { waitset.Dispatch(Duration.FromSeconds(4)); } startLotTask.Wait(); }
public SetStatusEvent(IBattleGraphicController graphic, ClientIdentifier id, StatusCondition condition) { this.graphic = graphic; this.id = id; this.condition = condition; }
private void RunExample( int domainId = 0, uint lotsToProcess = 10) { // A DomainParticipant allows an application to begin communicating in // a DDS domain. Typically there is one DomainParticipant per application. // DomainParticipant QoS is configured in USER_QOS_PROFILES.xml DomainParticipant participant = DomainParticipantFactory.Instance .CreateParticipant(domainId); // A Topic has a name and a datatype. Create a Topic named // "ChocolateLotState" with type ChocolateLotState // In this example we use a DynamicType defined in XML, which creates // a DynamicData topic. Topic <ChocolateLotState> lotStateTopic = participant.CreateTopic( "ChocolateLotState", types.ChocolateLotState); // Exercise #4.1: Add a Topic for Temperature to this application Topic <Temperature> temperatureTopic = participant.CreateTopic( "ChocolateTemperature", types.Temperature); // A Publisher allows an application to create one or more DataWriters // Publisher QoS is configured in USER_QOS_PROFILES.xml Publisher publisher = participant.CreatePublisher(); // This DataWriter writes data on Topic "ChocolateLotState" // DataWriter QoS is configured in USER_QOS_PROFILES.xml DataWriter <ChocolateLotState> lotStateWriter = publisher.CreateDataWriter(lotStateTopic); // A Subscriber allows an application to create one or more DataReaders // Subscriber QoS is configured in USER_QOS_PROFILES.xml Subscriber subscriber = participant.CreateSubscriber(); // Create DataReader of Topic "ChocolateLotState". // DataReader QoS is configured in USER_QOS_PROFILES.xml DataReader <ChocolateLotState> lotStateReader = subscriber.CreateDataReader(lotStateTopic); // Exercise #4.2: Add a DataReader for Temperature to this application DataReader <Temperature> temperatureReader = subscriber.CreateDataReader(temperatureTopic); // Obtain the DataReader's Status Condition StatusCondition temperatureStatusCondition = temperatureReader.StatusCondition; temperatureStatusCondition.EnabledStatuses = StatusMask.DataAvailable; // Associate a handler with the status condition. This will run when the // condition is triggered, in the context of the dispatch call (see below) temperatureStatusCondition.Triggered += _ => MonitorTemperature(temperatureReader); // Do the same with the lotStateReader's StatusCondition StatusCondition lotStateStatusCondition = lotStateReader.StatusCondition; lotStateStatusCondition.EnabledStatuses = StatusMask.DataAvailable; int lotsProcessed = 0; lotStateStatusCondition.Triggered += _ => lotsProcessed += MonitorLotState(lotStateReader); // Create a WaitSet and attach the StatusCondition WaitSet waitset = new WaitSet(); waitset.AttachCondition(lotStateStatusCondition); // Exercise #4.3: Add the new DataReader's StatusCondition to the Waitset waitset.AttachCondition(temperatureStatusCondition); var startLotTask = Task.Run(() => PublishStartLot(lotStateWriter, lotsToProcess)); while (!shutdownRequested && lotsProcessed < lotsToProcess) { waitset.Dispatch(Duration.FromSeconds(4)); } startLotTask.Wait(); }
public static StatusCondition[] Remove(int index, StatusCondition[] list) { ArrayList tmp = new ArrayList(); foreach(StatusCondition str in list) tmp.Add(str); tmp.RemoveAt(index); return tmp.ToArray(typeof(StatusCondition)) as StatusCondition[]; }
private void RunExample(int domainId, string sensorId) { // A DomainParticipant allows an application to begin communicating in // a DDS domain. Typically there is one DomainParticipant per application. // Uses TemperingApplication QoS profile to set participant name. var qosProvider = new QosProvider("./qos_profiles.xml"); var participantQos = qosProvider.GetDomainParticipantQos( "ChocolateFactoryLibrary::TemperingApplication"); DomainParticipant participant = DomainParticipantFactory.Instance .CreateParticipant(domainId, participantQos); // Create the topics Topic <Temperature> temperatureTopic = participant.CreateTopic <Temperature>("ChocolateTemperature"); Topic <ChocolateLotState> lotStateTopic = participant.CreateTopic <ChocolateLotState>("ChocolateLotState"); // Exercise #1.1: Create a Content-Filtered Topic that filters out // chocolate lot state unless the next_station = TEMPERING_CONTROLLER // A Publisher allows an application to create one or more DataWriters // Create Publisher with default QoS. Publisher publisher = participant.CreatePublisher(); // Create DataWriter of Topic "ChocolateTemperature" // using ChocolateTemperatureProfile QoS profile for Streaming Data DataWriter <Temperature> temperatureWriter = publisher.CreateDataWriter( temperatureTopic, qos: qosProvider.GetDataWriterQos("ChocolateFactoryLibrary::ChocolateTemperatureProfile")); // Create DataWriter of Topic "ChocolateLotState" // using ChocolateLotStateProfile QoS profile for State Data DataWriter <ChocolateLotState> lotStateWriter = publisher.CreateDataWriter( lotStateTopic, qos: qosProvider.GetDataWriterQos("ChocolateFactoryLibrary::ChocolateLotStateProfile")); // A Subscriber allows an application to create one or more DataReaders Subscriber subscriber = participant.CreateSubscriber(); // Create DataReader of Topic "ChocolateLotState". // using ChocolateLotStateProfile QoS profile for State Data // Exercise #1.2: Change the DataReader's Topic to use a // Content-Filtered Topic DataReader <ChocolateLotState> lotStateReader = subscriber.CreateDataReader( lotStateTopic, qos: qosProvider.GetDataReaderQos("ChocolateFactoryLibrary::ChocolateLotStateProfile"), preEnableAction: reader => reader.RequestedIncompatibleQos += OnRequestedIncompatibleQos); // Obtain the DataReader's Status Condition StatusCondition statusCondition = lotStateReader.StatusCondition; // Enable the 'data available' status. statusCondition.EnabledStatuses = StatusMask.DataAvailable; // Associate an event handler with the status condition. // This will run when the condition is triggered, in the context of // the dispatch call (see below) statusCondition.Triggered += _ => ProcessLot(lotStateReader, lotStateWriter); // Create a WaitSet and attach the StatusCondition var waitset = new WaitSet(); waitset.AttachCondition(statusCondition); // Create a thread to periodically publish the temperature Console.WriteLine($"ChocolateTemperature Sensor with ID: {sensorId} starting"); var temperatureTask = Task.Run( () => PublishTemperature(temperatureWriter, sensorId)); while (!shutdownRequested) { // Wait for ChocolateLotState Console.WriteLine("Waiting for lot"); waitset.Dispatch(Duration.FromSeconds(10)); } temperatureTask.Wait(); }
private void RunExample(int domainId, string stationKind) { if (!Enum.TryParse <StationKind>(stationKind, out var currentStation)) { throw new ArgumentException("Invalid station"); } // A DomainParticipant allows an application to begin communicating in // a DDS domain. Typically there is one DomainParticipant per application. // Uses TemperingApplication QoS profile to set participant name. var qosProvider = new QosProvider("./qos_profiles.xml"); // By specifying a default library, we can later refer to the // profiles without the library name qosProvider.DefaultLibrary = "ChocolateFactoryLibrary"; DomainParticipant participant = DomainParticipantFactory.Instance .CreateParticipant( domainId, qosProvider.GetDomainParticipantQos("IngredientApplication")); Topic <Temperature> temperatureTopic = participant.CreateTopic <Temperature>("ChocolateTemperature"); Topic <ChocolateLotState> lotStateTopic = participant.CreateTopic <ChocolateLotState>("ChocolateLotState"); ContentFilteredTopic <ChocolateLotState> filteredLotStateTopic = participant.CreateContentFilteredTopic( name: "FilteredLot", relatedTopic: lotStateTopic, filter: new Filter( expression: "next_station = %0", parameters: new string[] { $"'{stationKind}'" })); Publisher publisher = participant.CreatePublisher(); // Create DataWriter of Topic "ChocolateLotState" // using ChocolateLotStateProfile QoS profile for State Data DataWriter <ChocolateLotState> lotStateWriter = publisher.CreateDataWriter( lotStateTopic, qosProvider.GetDataWriterQos("ChocolateLotStateProfile")); Subscriber subscriber = participant.CreateSubscriber(); // Create DataReader of Topic "ChocolateLotState", filtered by // next_station, and using ChocolateLotStateProfile QoS profile for // State Data. DataReader <ChocolateLotState> lotStateReader = subscriber.CreateDataReader( filteredLotStateTopic, qosProvider.GetDataReaderQos("ChocolateLotStateProfile")); // Monitor the DataAvailable status StatusCondition statusCondition = lotStateReader.StatusCondition; statusCondition.EnabledStatuses = StatusMask.DataAvailable; statusCondition.Triggered += _ => ProcessLot(currentStation, lotStateReader, lotStateWriter); var waitset = new WaitSet(); waitset.AttachCondition(statusCondition); while (!shutdownRequested) { // Wait for ChocolateLotState Console.WriteLine("Waiting for lot"); waitset.Dispatch(Duration.FromSeconds(10)); } }
public virtual void ResolveConditions() { for (int i = 0; i < conditions.Count; i++) { StatusCondition condition = conditions[i]; switch (condition.type) { case StatusCondition.Type.DoT: DoTCondition dot = (DoTCondition)condition; //float duration = condition.duration; //float tickTimer = dot.tickLength; conditionTicks[i] -= Time.deltaTime; conditionDurations[i] -= Time.deltaTime; if (conditionTicks[i] <= 0) { OnHit(-(dot.strength)); conditionTicks[i] = dot.tickLength; } if (conditionDurations[i] <= 0) { conditions.RemoveAt(i); Destroy(conditionEffects[i]); conditionEffects.RemoveAt(i); conditionDurations.RemoveAt(i); conditionTicks.RemoveAt(i); } break; case StatusCondition.Type.Effect: //float timer = condition.duration; Attributes prev = attributes; conditionDurations[i] -= Time.deltaTime; attributes *= condition.attributeMod; if (conditionDurations[i] <= 0) { attributes = prev; conditions.RemoveAt(i); Destroy(conditionEffects[i]); conditionDurations.RemoveAt(i); conditionEffects.RemoveAt(i); } break; case StatusCondition.Type.Stun: //float stunDuration = condition.duration; conditionDurations[i] -= Time.deltaTime; isStunned = true; if (conditionDurations[i] <= 0) { conditions.RemoveAt(i); Destroy(conditionEffects[i]); conditionDurations.RemoveAt(i); conditionEffects.RemoveAt(i); isStunned = false; } break; } } }
public void SetStatus(PokemonWrapper pokemon, StatusCondition condition) { throw new NotImplementedException(); }
public void ExecuteMove_ChangingStatusCondition_PokemonConditionChanged(StatusCondition condition) { var executer = CreateExecuter(); factory.CreateAllPokemon(); ExecuteMoveCommand(executer, target: factory.PlayerID, newCondition: condition); Assert.AreEqual(condition, factory.GetPlayerPokemon().Condition); }
public StatusRequirementEffect(MoveEffectType type, XmlNode node) : base(type, node) { Status = (StatusCondition)Enum.Parse(typeof(StatusCondition), node.Attributes["status"].Value, true); Who = (Who)Enum.Parse(typeof(Who), node.Attributes["who"].Value, true); }
public static void StatusCondition(ref StatusCondition condition) { condition.apply = EditorGUILayout.Toggle("Apply", condition.apply, GUILayout.Width(mWidth)); if(condition.apply) { condition.stopChange = EditorGUILayout.Toggle("Stop changes", condition.stopChange, GUILayout.Width(mWidth)); if(!condition.stopChange) { condition.value = EditorGUILayout.IntField("Value", condition.value, GUILayout.Width(mWidth)); condition.simpleOperator = (SimpleOperator)EditorTab.EnumToolbar("Operator", (int)condition.simpleOperator, typeof(SimpleOperator)); condition.setter = (ValueSetter)EditorTab.EnumToolbar("Set in", (int)condition.setter, typeof(ValueSetter)); condition.execution = (StatusConditionExecution)EditorTab.EnumToolbar("Set on", (int)condition.execution, typeof(StatusConditionExecution)); if(StatusConditionExecution.TIME.Equals(condition.execution)) { condition.time = EditorGUILayout.IntField("Every (sec)", condition.time, GUILayout.Width(mWidth)); } } } }
/// <summary> /// Adds the items in <c>Values</c> as modifiers to the combat stats in <c>Stats</c> for <paramref name="unit"/>. /// </summary> public override void Apply(Unit unit, StatusCondition status) { ApplyUnitCombatStatModifiers(unit, status.Name, this.Stats, this.Values); }
public bool CanCauseStatus(StatusCondition status, Who who) { StatusEffect[] effs = Effects.Where(e => e is StatusEffect).Cast <StatusEffect>().ToArray(); return(effs.Any(e => e.Status == status && (e.Who == who || e.Who == Who.Both))); }
public void SetPokemonStatus(ClientIdentifier id, StatusCondition condition) { throw new NotImplementedException(); }
public BattleEventArgs(BattleEventType type, ActiveMonster monster, StatusCondition status) { Type = type; Monster = monster; Status = status; }
public Monster(XmlNode node, Generator generator = Generator.Wild) { Species = Species.Spp[node.Attributes["species"].Value]; XmlNode currentStats = node.ChildNodes.Cast <XmlNode>().Where(n => n.Name == "stats" && n.Attributes.Contains("type") && n.Attributes["type"].Value == "current").FirstOrDefault(); XmlNode ivs = node.ChildNodes.Cast <XmlNode>().Where(n => n.Name == "stats" && n.Attributes.Contains("type") && n.Attributes["type"].Value == "iv").FirstOrDefault(); XmlNode evs = node.ChildNodes.Cast <XmlNode>().Where(n => n.Name == "stats" && n.Attributes.Contains("type") && n.Attributes["type"].Value == "ev").FirstOrDefault(); XmlNode moves = node.ChildNodes.Cast <XmlNode>().Where(n => n.Name == "moves").FirstOrDefault(); IV = new Stats(); if (ivs != null) { IV.HP = int.Parse(ivs.Attributes["hp"].Value); IV.Attack = int.Parse(ivs.Attributes["attack"].Value); IV.Defense = int.Parse(ivs.Attributes["defense"].Value); IV.Special = int.Parse(ivs.Attributes["special"].Value); IV.Speed = int.Parse(ivs.Attributes["speed"].Value); } else { GenerateIVs(generator); } EV = new Stats(); if (evs != null) { EV.HP = int.Parse(evs.Attributes["hp"].Value); EV.Attack = int.Parse(evs.Attributes["attack"].Value); EV.Defense = int.Parse(evs.Attributes["defense"].Value); EV.Special = int.Parse(evs.Attributes["special"].Value); EV.Speed = int.Parse(evs.Attributes["speed"].Value); } if (node.Attributes.Contains("experience")) { Experience = int.Parse(node.Attributes["experience"].Value); Level = Species.ExpRequired[Species.ExpGrowthRate].Where(exp => Experience >= exp).Select((exp, lvl) => lvl).Max(); } else if (node.Attributes.Contains("level")) { Level = int.Parse(node.Attributes["level"].Value); Experience = Species.ExpRequired[Species.ExpGrowthRate][Level]; } else { Level = 5; Experience = Species.ExpRequired[Species.ExpGrowthRate][Level]; } Stats = new Stats(); if (currentStats != null) { Stats.HP = int.Parse(currentStats.Attributes["hp"].Value); Stats.Attack = int.Parse(currentStats.Attributes["attack"].Value); Stats.Defense = int.Parse(currentStats.Attributes["defense"].Value); Stats.Special = int.Parse(currentStats.Attributes["special"].Value); Stats.Speed = int.Parse(currentStats.Attributes["speed"].Value); } else { RecalcStats(); } CurrentHP = node.Attributes.Contains("current-hp") ? int.Parse(node.Attributes["current-hp"].Value) : Stats.HP; Status = node.Attributes.Contains("status") ? (StatusCondition)Enum.Parse(typeof(StatusCondition), node.Attributes["status"].Value, true) : StatusCondition.None; SleepCounter = node.Attributes.Contains("sleep-counter") ? int.Parse(node.Attributes["sleep-counter"].Value) : 0; Moves = new Move[4]; CurrentPP = new int[4]; PPUpsUsed = new int[4]; if (moves != null && moves.ChildNodes.Cast <XmlNode>().Count(n => n.Name == "move") > 0) { XmlNode[] moveNodes = moves.ChildNodes.Cast <XmlNode>().Where(n => n.Name == "move").ToArray(); for (int i = 0; i < moveNodes.Length; i++) { Moves[i] = Move.Moves[moveNodes[i].Attributes["name"].Value]; PPUpsUsed[i] = moveNodes[i].Attributes.Contains("pp-ups-used") ? int.Parse(moveNodes[i].Attributes["pp-ups-used"].Value) : 0; CurrentPP[i] = moveNodes[i].Attributes.Contains("pp") ? int.Parse(moveNodes[i].Attributes["pp"].Value) : this.MaxPP(i); } } else { GenerateMoves(generator); for (int i = 0; i < CurrentPP.Length; i++) { CurrentPP[i] = Moves[i] != null ? Moves[i].PP : 0; PPUpsUsed[i] = 0; } } }
public void CreateAIPokemon(StatusCondition statusCondition = StatusCondition.Normal, int HP = 100) { BattleData.GetPokemon(AIID).Pokemon = CreatePokemon(statusCondition, HP); }
public void SetStatus(PokemonWrapper pokemon, StatusCondition condition) { StatusChanged(this, new ClientStatusChangedEventArgs(pokemon.Identifier, condition)); }
public void SetStatus(StatusCondition status) { this.conditions.Add(status); }
public static Pokemon CreatePokemon(StatusCondition statusCondition = StatusCondition.Normal, int HP = 100) { var baseData = new PokemonData(); baseData.BaseStats = new Stats { HP = 100 }; return new Pokemon(baseData, new Stats()) { Condition = statusCondition, HP = HP }; }
public void RaiseStatusChanged(StatusCondition condition) { StatusChanged(this, new ClientStatusChangedEventArgs(id, condition)); }
public void CreateFieldTargetBtn(BattlePosition position, BTLUI_ButtonFieldTarget btn) { btn.position = position; Pokemon pokemon = battleModel.GetPokemonAtPosition(position); if (pokemon != null) { btn.pokemon = pokemon; btn.nameTxt.text = pokemon.nickname; PokemonGender gender = pokemon.gender; if (gender != PokemonGender.Genderless) { btn.nameTxt.text += (gender == PokemonGender.Male) ? " <color=#8080FF>♂</color>" : " <color=#FF8080>♀</color>"; } btn.lvlTxt.text = "Lv" + pokemon.level; StatusCondition condition = pokemon.nonVolatileStatus; if (condition.statusID == "healthy") { btn.statusTxt.text = ""; } else { btn.statusTxt.text = condition.data.shortName; } float hpPercent = pokemon.HPPercent; btn.hpBar.fillAmount = hpPercent; btn.hpBar.color = (hpPercent > 0.5f) ? btn.hpHigh : (hpPercent > 0.25f) ? btn.hpMed : btn.hpLow; // draw icon string drawPath = "pokemonSprites/icon/" + pokemon.data.displayID; btn.icon.sprite = BattleAssetLoader.instance.nullPokemonIconSprite; if (BattleAssetLoader.instance.loadedPokemonSprites.ContainsKey(drawPath)) { btn.icon.sprite = BattleAssetLoader.instance.loadedPokemonSprites[drawPath]; } else { StartCoroutine(BattleAssetLoader.instance.LegacyLoadPokemon( pokemon: pokemon, useicon: true, imagePokemon: btn.icon )); } } else { btn.nameTxt.gameObject.SetActive(false); btn.lvlTxt.gameObject.SetActive(false); btn.statusTxt.gameObject.SetActive(false); btn.hpObj.SetActive(false); btn.icon.gameObject.SetActive(false); } }
protected override void OnApply() { Status status = GetComponentInParent <Status>(); statusCondition = status.Add <T, StatusCondition>(); }
private void RunExample( int domainId = 0, uint lotsToProcess = 10) { // Exercise #1.1: Add QoS provider // A DomainParticipant allows an application to begin communicating in // a DDS domain. Typically there is one DomainParticipant per application. // Exercise #1.2: Load DomainParticipant QoS profile DomainParticipant participant = DomainParticipantFactory.Instance .CreateParticipant(domainId); // A Topic has a name and a datatype. Create a Topic named // "ChocolateLotState" with type ChocolateLotState. Topic <ChocolateLotState> lotStateTopic = participant.CreateTopic <ChocolateLotState>( CHOCOLATE_LOT_STATE_TOPIC.Value); // Add a Topic for Temperature to this application Topic <Temperature> temperatureTopic = participant.CreateTopic <Temperature>( CHOCOLATE_TEMPERATURE_TOPIC.Value); // A Publisher allows an application to create one or more DataWriters // Publisher QoS is configured in USER_QOS_PROFILES.xml Publisher publisher = participant.CreatePublisher(); // This DataWriter writes data on Topic "ChocolateLotState" // Exercise #4.1: Load ChocolateLotState DataWriter QoS profile after // debugging incompatible QoS DataWriter <ChocolateLotState> lotStateWriter = publisher.CreateDataWriter(lotStateTopic); // A Subscriber allows an application to create one or more DataReaders // Subscriber QoS is configured in USER_QOS_PROFILES.xml Subscriber subscriber = participant.CreateSubscriber(); // Create DataReader of Topic "ChocolateLotState". // Exercise #1.3: Update the lotStateReader and temperatureReader // to use correct QoS DataReader <ChocolateLotState> lotStateReader = subscriber.CreateDataReader(lotStateTopic); // Add a DataReader for Temperature to this application DataReader <Temperature> temperatureReader = subscriber.CreateDataReader(temperatureTopic); // Obtain the DataReader's Status Condition StatusCondition temperatureStatusCondition = temperatureReader.StatusCondition; temperatureStatusCondition.EnabledStatuses = StatusMask.DataAvailable; // Associate a handler with the status condition. This will run when the // condition is triggered, in the context of the dispatch call (see below) temperatureStatusCondition.Triggered += _ => MonitorTemperature(temperatureReader); // Do the same with the lotStateReader's StatusCondition StatusCondition lotStateStatusCondition = lotStateReader.StatusCondition; lotStateStatusCondition.EnabledStatuses = StatusMask.DataAvailable; int lotsProcessed = 0; lotStateStatusCondition.Triggered += _ => lotsProcessed += MonitorLotState(lotStateReader); // Create a WaitSet and attach the StatusCondition var waitset = new WaitSet(); waitset.AttachCondition(lotStateStatusCondition); // Add the new DataReader's StatusCondition to the Waitset waitset.AttachCondition(temperatureStatusCondition); // Start publishing in a separate thread var startLotTask = Task.Run(() => PublishStartLot(lotStateWriter, lotsToProcess)); while (!shutdownRequested && lotsProcessed < lotsToProcess) { waitset.Dispatch(Duration.FromSeconds(4)); } startLotTask.Wait(); }