/// <summary> /// See <see cref="IEtsInterface.Open"/> /// </summary> public void Open() { Log.Verbose("ETSI: Starting client..."); string etsiLogFile = Log.Instance.FilePath.Replace(".log", " etsi.log"); System.Diagnostics.Process client = new System.Diagnostics.Process(); client.StartInfo.FileName = "py"; client.StartInfo.Arguments = "start_server.py > " + etsiLogFile; client.StartInfo.WorkingDirectory = etsiPath; client.StartInfo.CreateNoWindow = !showConsoleWindow; client.Start(); Log.Verbose("ETSI: Starting server..."); server = new Socket(SocketType.Stream, ProtocolType.Tcp); server.Bind(new IPEndPoint(new IPAddress(Ip), Port)); //server.ReceiveTimeout = TIMEOUT; //server.SendTimeout = TIMEOUT; server.Listen(1); Log.Verbose("ETSI: Waiting for physical interface connection..."); socket = server.Accept(); socket.SendTimeout = Timeout; socket.ReceiveTimeout = Timeout; IsOpen = true; Log.Verbose("ETSI: Physical interface connected."); // query the full physical game state once to ensure no arrays in state are null and to check for technical failures Log.Verbose("ETSI: Querying intial state and checking for technical failures..."); query = new PhysicalStateQuery(true, true, true, true, true, true); PhysicalStateResponse response = SendQuery <PhysicalStateResponse>("get_game_state", query); state = response.@return; }
private void ChangePhysicalState(PhysicalState state) { if (state == m_PhysicalState) { return; } m_PhysicalState = state; if (state == PhysicalState.OnGround) { m_Animator.SetTrigger("IsOnGround"); } else if (state == PhysicalState.InAir) { m_Animator.SetTrigger("IsInAir"); } else if (state == PhysicalState.OnLadder) { m_Animator.SetTrigger("IsOnLadder"); } else { Debug.LogErrorFormat("Unhandled or invalid physical state: {0}", state); } }
void FinishProcessing() { foreach (var affector in Affectors) { processingTarget.Modify(affector); } if (PhysicalConversions.Length > (int)processingTarget.PhysicalState) { PhysicalState conversion = PhysicalConversions[(int)processingTarget.PhysicalState]; if (conversion > 0) { // TODO change sprite based on this processingTarget.PhysicalState = conversion; } } progressBar.gameObject.SetActive(false); processingRender.enabled = true; processingTarget.transform.position = transform.position + new Vector3(1, 0); processingRender.color *= MultiplyColor; currentProcessingProgress = 0; currentState = WAITING; }
public Element( int atomicNumber, string symbol, string name, double atomicMass, string colorHex, ElectronConfiguration electronConfiguration, string electronegativity, string atomicRadius, string ionizationEnergy, string electronAffinity, string oxidationStates, PhysicalState standardState, string meltingPoint, string boilingPoint, string density, ElementType groupBlock, int yearDiscovered, ElementStructure structure) { AtomicNumber = atomicNumber; Symbol = symbol; Name = name; AtomicMass = atomicMass; ColorHex = colorHex; ElectronConfiguration = electronConfiguration; Electronegativity = electronegativity; AtomicRadius = atomicRadius; IonizationEnergy = ionizationEnergy; ElectronAffinity = electronAffinity; OxidationStates = oxidationStates; StandardState = standardState; MeltingPoint = meltingPoint; BoilingPoint = boilingPoint; Density = density; GroupBlock = groupBlock; YearDiscovered = yearDiscovered; Structure = structure; }
void Start() { if (godMode != null) { camera = godMode.GetComponent <Camera>(); } else { Debug.Log("RHS>>> ERROR! No GodMode attached to this script."); } atGO = null; lastGO = null; gmc = godMode.GetComponent <GodModeControl>(); if (tGStatus != null) { toggleFalseStatus = tGStatus.transform.Find("FalseToggle").GetComponent <Toggle>(); toggleTrueStatus = tGStatus.transform.Find("TrueToggle").GetComponent <Toggle>(); tGStatus.gameObject.SetActive(false); } else { Debug.Log("RHS>>> ERROR! tGStatus is Null! Insert a Toggle Group in Inspector."); } status = PhysicalState.noneState; toggleFalseStatus.isOn = true; }
// Update is called once per frame void Update() { if (status == PhysicalState.openState) { if (waterParticles != null && !waterParticles.isPlaying) { waterParticles.Play(); } if (auxAudioSource != null && !auxAudioSource.isPlaying) { auxAudioSource.Play(); } atValue = status; } else { if (waterParticles != null && waterParticles.isPlaying) { waterParticles.Stop(); } if (auxAudioSource != null && auxAudioSource.isPlaying) { auxAudioSource.Stop(); } atValue = status; } }
//Function called when this character is created private void Awake() { //Getting the reference to the physical state component on this object this.currentState = this.GetComponent <PhysicalState>(); //Initializing the empty list of combat effects this.combatEffects = new List <Effect>(); }
//Generates this character's physical stats private void GeneratePhysicalState() { //Getting the reference to this object's PhysicalState component PhysicalState characterStateRef = this.GetComponent <PhysicalState>(); //Gets a random health value using the min and max characterStateRef.maxHealth = Mathf.RoundToInt(Random.Range(this.health.x, this.health.y)); characterStateRef.currentHealth = characterStateRef.maxHealth; }
/// Constructor for the Thing class. The objective is to create a instance of an inanimate object. /// All parameters together defines this object. /// /// public Thing(long objId, string name, string tag, RGBValue color, CartesianPos pos, PhysicalState state, Material mat, string uri) { objectId = objId; this.name = name; tagInfo = tag; this.color = color; this.pos = pos; this.state = state; material = mat; uriId = uri; }
//Function called when this component is enabled public void OnEnable() { //Finding the index of the character that's currently selected this.selectedCharacter = PartyGroup.globalReference.charactersInParty[0]; this.selectedCharacterState = this.selectedCharacter.charPhysState; //Updating the sliders this.UpdateTextAndSliders(new EVTData()); //Telling the EventManager.cs to listen for time passing events EventManager.StartListening(TimePassedEVT.eventNum, this.advanceTimeListener); }
//Function called externally to cycle to the previous character in the player party public void GoToPrevCharacter() { //Telling the character manager to go to the previous character CharacterManager.globalReference.SelectPreviousCharacter(); //Finding the index of the character that's currently selected this.selectedCharacter = CharacterManager.globalReference.selectedCharacter; this.selectedCharacterState = this.selectedCharacter.charPhysState; //Updating the sliders this.UpdateTextAndSliders(new EVTData()); }
//Function called when this character is created private void Awake() { //Setting the references to each of the required components this.charRaceTypes = this.GetComponent <RaceTypes>(); this.charInventory = this.GetComponent <Inventory>(); this.charSkills = this.GetComponent <Skills>(); this.charPhysState = this.GetComponent <PhysicalState>(); this.charCombatStats = this.GetComponent <CombatStats>(); this.charActionList = this.GetComponent <ActionList>(); this.charSprites = this.GetComponent <CharacterSprites>(); this.charPerks = this.GetComponent <PerkList>(); }
private void playPreviousRecord() { if (m_recordedState.Count > 0) { PhysicalState state = m_recordedState.First.Value; m_lastRecordedState = state; m_recordedState.RemoveFirst(); } m_rigidBody.position = m_lastRecordedState.position; m_rigidBody.rotation = m_lastRecordedState.rotation; m_rigidBody.velocity = m_lastRecordedState.velocity; }
/// <summary> /// See <see cref="IEtsInterface.Update()"/>. Sends a request via socket to ETSI to query the /// physical state. Also waits for, receives and parses the response. /// </summary> public void PhysicalUpdate(float deltaTime) { // query state query = new PhysicalStateQuery(true, true, pipes.State == GameState.Initialized || pipes.State == GameState.Running || maintenanceMode.enabled, crane.State == GameState.Initialized || crane.State == GameState.Running || maintenanceMode.enabled, dynamite.State == GameState.Initialized || dynamite.State == GameState.Running || maintenanceMode.enabled, trigger.State == GameState.Initialized || trigger.State == GameState.Running || maintenanceMode.enabled ); PhysicalStateResponse response = SendQuery <PhysicalStateResponse>("get_game_state", query); PhysicalState newState = response.@return; if (query.pipes) { state.pipes = newState.pipes; } if (query.crane) { state.crane = newState.crane; } if (query.dynamite) { state.dynamite = newState.dynamite; } if (query.blasting) { state.blasting = newState.blasting; } if (query.lights) { state.lights = newState.lights; } if (query.control) { state.control = newState.control; } if (OverrideLighting && GetLightStates().Contains(false)) { bool[] lights = new bool[LightsCount]; for (int i = 0; i < lights.Length; i++) { lights[i] = true; } OverrideLighting = false; SetLightStates(lights); OverrideLighting = true; } }
private static void Drown(HealthState healthState, PhysicalState physicalState) { var entityGrid = physicalState.BottomLeftCoordinate; var entityParent = physicalState.ParentEntity; var otherEntitiesInGrid = entityParent.GetState <PhysicalState>().GetEntitiesAtGrid(entityGrid); var enoughLiquid = otherEntitiesInGrid.Any(entityInGrid => entityInGrid.HasState <SubstanceNetworkState>() && (entityInGrid.GetState <SubstanceNetworkState>().GetSubstance(SubstanceType.SeaWater) > DrowningThreshold || entityInGrid.GetState <SubstanceNetworkState>().GetSubstance(SubstanceType.Diesel) > DrowningThreshold)); if (enoughLiquid) { healthState.DoDamage(DrowningDamagePerTick); } }
//Function called externally to go to a character at a designated index public void GoToCharacterAtIndex(int characterIndex_) { //If the index given doesn't have a character, nothing happens if (PartyGroup.globalReference.charactersInParty[characterIndex_] == null) { return; } //Saving the references to the given character this.selectedCharacter = PartyGroup.globalReference.charactersInParty[characterIndex_]; this.selectedCharacterState = this.selectedCharacter.GetComponent <PhysicalState>(); //Updating the sliders for the new character this.UpdateTextAndSliders(new EVTData()); }
//Function called when this character is created private void Awake() { //Setting the references to each of the required components this.charRaceTypes = this.GetComponent <RaceTypes>(); this.charEquipment = this.GetComponent <CharacterEquipment>(); this.charSkills = this.GetComponent <Skills>(); this.charPhysState = this.GetComponent <PhysicalState>(); this.charCombatStats = this.GetComponent <CombatStats>(); this.charActionList = this.GetComponent <ActionList>(); this.charModels = this.GetComponent <CharacterModelObjs>(); this.charPerks = this.GetComponent <PerkList>(); if (this.GetComponent <LevelTracker>()) { this.levelTracker = this.GetComponent <LevelTracker>(); } }
public Entity CreateEntity(List <IState> states, Entity entityToAddItTo, GridCoordinate locationToAddIt) { var newStates = states.DeepClone(); var entity = BuildEntity(newStates); InitEnvironmentEntities(entity); if (entityToAddItTo != null && PhysicalState.AddEntityToEntity(entity, locationToAddIt, entityToAddItTo)) { EntityAdded(entity); return(entity); } if (entityToAddItTo == null) { EntityAdded(entity); return(entity); } return(null); }
//Generates this character's physical stats private void GeneratePhysicalState() { //Getting the reference to this object's PhysicalState component PhysicalState characterStateRef = this.GetComponent <PhysicalState>(); //Gets a random health value using the min and max characterStateRef.maxHealth = Mathf.RoundToInt(Random.Range(this.health.x, this.health.y)); characterStateRef.currentHealth = characterStateRef.maxHealth; //Sets the food, water, and sleep requirements characterStateRef.requiresFood = this.requiresFood; characterStateRef.requiresWater = this.requiresWater; characterStateRef.requiresSleep = this.requiresSleep; characterStateRef.maxFood = this.daysBeforeStarving; characterStateRef.maxWater = this.daysBeforeDehydrated; characterStateRef.maxSleep = this.daysBeforeFatalInsomnia; }
// Update is called once per frame void Update() { atGO = gmc.getHighlightedGObject(); if (atGO != null) { objectText.text = buildPropertiesString(atGO); if (!iFieldPositionX.isFocused && !iFieldPositionY.isFocused && !iFieldPositionZ.isFocused) { Vector3 auxPosition = gmc.getTargetPosition(); if (auxPosition != atGO.transform.position) { setInputPosition(auxPosition); } } if (atGO != lastGO) { setInputPosition(gmc.getTargetPosition()); Status auxStatus = atGO.GetComponent <Status>(); if (auxStatus != null) { tGStatus.gameObject.SetActive(true); status = auxStatus.getStatus(); if (status == PhysicalState.offState || status == PhysicalState.closeState) { toggleFalseStatus.isOn = true; } else { toggleTrueStatus.isOn = true; } } else { tGStatus.gameObject.SetActive(false); } lastGO = atGO; } } else { objectText.text = ""; } }
private static IEnumerable <TimeInterval> GetStressfulSpansForHealthIndicator( IEnumerable <StateRecord> statesOfPerson, Func <StateRecord, float> healthIndicatorExtractor, IndicatorParameters parameters) { DateTime begin = statesOfPerson.First().CreateTime; var normalizedStates = statesOfPerson.Select(state => new PhysicalState { StateIndicator = healthIndicatorExtractor(state), Time = state.CreateTime }).ToArray(); double mean = normalizedStates.Select(state => state.StateIndicator).Average(); double stdev = StandardDeviation(normalizedStates.Select(state => state.StateIndicator)); int abnormalValuesInRow = 0; for (int i = 0; i < normalizedStates.Length; i++) { PhysicalState state = normalizedStates[i]; float indicator = state.StateIndicator; bool isAbnormalValue = indicator - mean >= parameters.SigmaCoefficient * stdev; bool isLastRecord = i == normalizedStates.Length - 1; if (isAbnormalValue && !isLastRecord) { abnormalValuesInRow++; } else if (abnormalValuesInRow > 0) { var interval = new TimeInterval { Begin = normalizedStates[i - abnormalValuesInRow - 1].Time, End = normalizedStates[i].Time }; if (interval.GetDurationInSeconds() >= parameters.MinDurationSeconds) { yield return(interval); } abnormalValuesInRow = 0; } } }
//Function used to get the character info at the given index. Used when setting or changing character positions public void SetCharacterInfo() { //Getting the reference to the character at the given index this.displayedCharacter = PartyGroup.globalReference.charactersInParty[this.characterIndex]; //Sets the stats if the character exists if (this.displayedCharacter != null) { //Displaying the minimizer game object this.minimizer.SetActive(true); //Gets the character state component reference this.characterState = this.displayedCharacter.GetComponent <PhysicalState>(); //Setting the name text to the character's name this.nameText.text = this.displayedCharacter.charName; //Setting the range of the health bar slider this.healthBar.maxValue = this.characterState.maxHealth; this.healthBar.value = this.characterState.currentHealth; } }
public bool trigger() { if (status == PhysicalState.closeState) { status = PhysicalState.openState; } else if (status == PhysicalState.openState) { status = PhysicalState.closeState; } else if (status == PhysicalState.onState) { status = PhysicalState.offState; } else if (status == PhysicalState.offState) { status = PhysicalState.onState; } return(true); }
// Use this for initialization void Start() { atValue = status; waterParticles = GetComponentsInChildren <ParticleSystem>()[0]; auxAudioSource = GetComponent <AudioSource>(); }
// Use this for initialization public bool close() { status = PhysicalState.closeState; return(true); }
public bool on() { status = PhysicalState.onState; return(true); }
//Finding the total health curve modifier for a given character based on their physical state private int FindHealthCurveModFromPhysState(PhysicalState state_) { //The total modifier returned int curveMod = 0; //Finding the starting health curve switch (state_.startingHealthCurve) { case HealthCurveTypes.Strong: curveMod += 7; break; case HealthCurveTypes.Sturdy: curveMod += 6; break; case HealthCurveTypes.Healthy: curveMod += 5; break; case HealthCurveTypes.Average: curveMod += 4; break; case HealthCurveTypes.Weak: curveMod += 3; break; case HealthCurveTypes.Sickly: curveMod += 2; break; case HealthCurveTypes.Feeble: curveMod += 1; break; } //Finding the average health percent for this character float hpAvg = 0; foreach (float hpP in state_.trackingHealthPercents) { hpAvg += hpP; } hpAvg = hpAvg / state_.trackingHealthPercents.Count; //Finding the average food percent for this character float fdAvg = 0; foreach (float fdP in state_.trackingFoodPercents) { fdAvg += fdP; } fdAvg = fdAvg / state_.trackingFoodPercents.Count; //Finding the average water percent for this character float wtAvg = 0; foreach (float wtP in state_.trackingWaterPercents) { wtAvg += wtP; } wtAvg = wtAvg / state_.trackingWaterPercents.Count; //Finding the average sleep percent for this character float slAvg = 0; foreach (float slP in state_.trackingSleepPercents) { slAvg += slP; } slAvg = slAvg / state_.trackingSleepPercents.Count; //If the Health average is too low, the modifier goes down if (hpAvg < this.healthPercentCurveModRange.x) { curveMod -= 1; } //If the Health average is high enough, the modifier goes up else if (hpAvg >= this.healthPercentCurveModRange.y) { curveMod += 1; } //If the Food average is too low, the modifier goes down if (fdAvg < this.foodPercentCurveModRange.x) { curveMod -= 1; } //If the Food average is high enough, the modifier goes up else if (fdAvg >= this.foodPercentCurveModRange.y) { curveMod += 1; } //If the Water average is too low, the modifier goes down if (wtAvg < this.waterPercentCurveModRange.x) { curveMod -= 1; } //If the Water average is high enough, the modifier goes up else if (wtAvg >= this.waterPercentCurveModRange.y) { curveMod += 1; } //If the Sleep average is too low, the modifier goes down if (slAvg < this.sleepPercentCurveModRange.x) { curveMod -= 1; } //If the Sleep average is high enough, the modifier goes up else if (slAvg >= this.sleepPercentCurveModRange.y) { curveMod += 1; } return(curveMod); }
/// Constructor for the Thing class. The objective is to create a instance of an animate agent. /// All the parameter defines this agent in a similar way of the super class Thing. /// There are just an additional parameter, named emotion, that defines the emotion state of the agent. /// public Human(long objId, string name, string tag, RGBValue color, CartesianPos pos, PhysicalState state, Material mat, string uri, EmotionalState emotion) : base(objId, name, tag, color, pos, state, mat, uri) { this.emotion = emotion; }
public bool off() { status = PhysicalState.offState; return(true); }
private void insertVision(GameObject go, DateTime dt) { CartesianPos cPos = new CartesianPos(go.transform.position.x, go.transform.position.y, go.transform.position.z); VisionProperties auxVision = go.GetComponent <VisionProperties>(); Status auxStatus = go.GetComponent <Status>(); RGBValue rgb; OntSenseCSharpAPI.Material material = OntSenseCSharpAPI.Material.unknownMaterial; PhysicalState state = PhysicalState.noneState; string tag = go.tag; string uri = ""; if (auxStatus != null) { state = auxStatus.getStatus(); } if (auxVision != null) { rgb = auxVision.getRGB(); material = auxVision.getMaterial(); if (auxVision == vision) { tag = "SelfRobot"; } uri = auxVision.getURI(); } else { rgb = new RGBValue(0, 0, 0); } EmotionalState emotion = EmotionalState.neutralEmotion; EmotionStatus auxEmotion = go.GetComponent <EmotionStatus>(); if (auxEmotion != null) { emotion = auxEmotion.getEmotion(); } RobotVision rv; switch (go.tag) { case Constants.TAG_ROBOT: Robot auxRobot = new Robot(uIDD.getID(go), go.name, tag, rgb, cPos, state, material, uri); rv = new RobotVision(dt, auxRobot); break; case Constants.TAG_HUMAN: Human auxHuman = new Human(uIDD.getID(go), go.name, tag, rgb, cPos, state, material, uri, emotion); rv = new RobotVision(dt, auxHuman); break; default: Thing auxThing = new Thing(uIDD.getID(go), go.name, tag, rgb, cPos, state, material, uri); rv = new RobotVision(dt, auxThing); break; } try // Try to access a resource. { rv.insert(); // using dotNetRDF library inserts the information in the triple store } catch (Exception e) { Debug.Log("System>>> " + e.Message); // change for your: LogError(e); // Call a custom error logging procedure. } }