public void SetState(EnergyState s) { switch (s) { case EnergyState.Charging: consuptionMultiplier = 5; break; case EnergyState.Consuming: consuptionMultiplier = -0.2f; break; case EnergyState.Dashing: consuptionMultiplier = -5; break; case EnergyState.ChargingDashing: consuptionMultiplier = 2; break; default: consuptionMultiplier = -0.2f; break; } state = s; }
/// <summary> /// <para> /// Returns the amount of energy required to be at the top of a given EnergyState. /// It's recommended that the actual EnergyState property be used to determine /// the current energy bucket a creature is in. /// </para> /// </summary> /// <param name="species">The species for which to calculate</param> /// <param name="energyState">EnergyState enum value for the bucket to get the upper energy bounding for.</param> /// <param name="radius">The radius of the organism to use in calculation</param> /// <returns> /// System.Double representing the amount of energy to be at the top of a given energy state. /// </returns> public static double UpperBoundaryForEnergyState(ISpecies species, EnergyState energyState, int radius) { var energyBuckets = (species.MaximumEnergyPerUnitRadius * (double)radius) / 5; switch (energyState) { case EnergyState.Dead: return(0); case EnergyState.Deterioration: return(energyBuckets * 1); case EnergyState.Hungry: return(energyBuckets * 2); case EnergyState.Normal: return(energyBuckets * 4); case EnergyState.Full: return(species.MaximumEnergyPerUnitRadius * (double)radius); default: throw new ApplicationException("Unknown EnergyState."); } }
private void Initialize() { previousEnergyState = EnergyState.Idle; currentEnergyState = EnergyState.Idle; currentEnergy = startingEnergy; currentMaxEnergy = initialMaxEnergy; }
/// <summary> /// Create a new state object to represent an organism. /// </summary> /// <param name="id">The GUID ID representing this organism in the world.</param> /// <param name="species">The species which defines the basic properties of the organism.</param> /// <param name="generation">The familial generation number.</param> /// <param name="initialEnergyState">The initial EnergyState of the organism.</param> /// <param name="initialRadius">The initial Radius of the organism.</param> internal OrganismState(string id, ISpecies species, int generation, EnergyState initialEnergyState, int initialRadius) { DeathReason = PopulationChangeReason.NotDead; ID = id; Species = species; Generation = generation; SetStoredEnergyInternal(OrganismState.UpperBoundaryForEnergyState(species, initialEnergyState, initialRadius)); Radius = initialRadius; events = new OrganismEventResults(); }
IEnumerator regenerateRunEnergy() { while (m_RunEnergy < m_MaxRunEnergy) { yield return(new WaitForSeconds(m_RegenRunTime)); ++m_RunEnergy; } m_RunEnergyRoutine = null; m_RunEnergyState = EnergyState.idle; }
IEnumerator degenerateRunEnergy() { while (m_RunEnergy > 0) { yield return(new WaitForSeconds(m_DegenRunTime)); --m_RunEnergy; } m_RunEnergyRoutine = null; m_RunEnergyState = EnergyState.idle; }
public void Start() { Age = 0.0f; energyState = GetComponent <EnergyState>(); movementCapability = GetComponent <MovementCapability>(); eater = GetComponent <EatOnCollide>(); edible = GetComponent <EdibleState>(); massMove = GetComponent <MovementBasedOnMass>(); ai = GetComponent <FishAI>(); if (ColorTarget != null) { mesh = ColorTarget.GetComponent <MeshRenderer>(); } }
public override void Update () { base.Update(); float fractionOfMaxEnergy = currentEnergy/maxEnergy; if (fractionOfMaxEnergy <= energyRatioToBeCritical) { this.state = EnergyState.CRITICAL; } else if (fractionOfMaxEnergy <= energyRatioToBeDrained) { this.state = EnergyState.DRAINED; } else { this.state = EnergyState.FULL; } }
void preGroundCheckUpdate() { // Height Adjusting if (m_Input.crouch.IsHeld && m_IsGrounded) { heightState = HeightState.crouched; } else { heightState = HeightState.standing; } if (isChangingHeight && isHeightObstructed(m_HeightState)) { heightState = m_PrevValidHeightState; } // Running if (m_Input.run.PressedDown && m_RunEnergy > m_RqdRunEnergy) { m_StartedValidRun = true; } if (desiresMove && !isCrouched && m_Input.run.IsHeld && m_RunEnergy > 0 && m_StartedValidRun) { runEnergyState = EnergyState.decreasing; } else { if (!m_Input.run.IsHeld || m_RunEnergy == 0) { m_StartedValidRun = false; } runEnergyState = EnergyState.increasing; } // Jumping if (m_Input.jump.PressedDown) { if (m_JumpRequest != null) { StopCoroutine(m_JumpRequest); } m_JumpRequest = StartCoroutine(revokeJumpRequestAfterDelay()); } // Done before groundCheck() to ensure value is not reset when used m_AirbornTime = m_IsGrounded ? 0f : m_AirbornTime + Time.deltaTime; }
//Respawn public void Respawn() { //pausing the game after being hit Time.timeScale = 0f; //Loosing a life Continues -= 1; //Resetting the Energy Bar upon respawning state = EnergyState.IdleState; curEnergy = maxEnergy; //Respawn location Debug.Log(Anchor.rotation); //Anchor.Rotate(Startrotation); Anchor.rotation = Rotation; }
public override void Update() { base.Update(); float fractionOfMaxEnergy = currentEnergy / maxEnergy; if (fractionOfMaxEnergy <= energyRatioToBeCritical) { this.state = EnergyState.CRITICAL; } else if (fractionOfMaxEnergy <= energyRatioToBeDrained) { this.state = EnergyState.DRAINED; } else { this.state = EnergyState.FULL; } }
private void Awake() { Initialize(); EventBus.Subscribe <IntroBootUpTextCompleteEvent>(e => { Initialize(); currentEnergyState = EnergyState.Recharging; }); EventBus.Subscribe <EnterHomeEvent>(e => currentEnergyState = EnergyState.Recharging); EventBus.Subscribe <EnterCityEvent>(e => currentEnergyState = EnergyState.Depleting); EventBus.Subscribe <ExitHomeEvent>(e => currentEnergyState = EnergyState.Idle); EventBus.Subscribe <ExitCityEvent>(e => currentEnergyState = EnergyState.Idle); EventBus.Subscribe <PauseMenuEngagedEvent>(OnPauseMenuEngagedEvent); EventBus.Subscribe <PauseMenuDisengagedEvent>(OnPauseMenuDisengagedEvent); movement = GetComponent <PlayerMovement>(); rb = GetComponent <Rigidbody>(); }
private void CheckState() { if (energyState != EnergyState.SUPER_CHARGE) { if (playerEnergy < 15 && playerEnergy > 3) { energyState = EnergyState.LOW; } else if (playerEnergy <= 3) { energyState = EnergyState.DYING; } else { energyState = EnergyState.OK; } if (playerEnergy <= 0) { if (isGoingToDie) { GameManager.instance.PlayDeathScene(); } else { GameManager.instance.TeleportToMedicalBay(); } } } else { playerEnergy = MAX_ENERGY; } if (timeElapsed >= MAX_TIME_ELAPSED) { //ship has reached final destination? } }
// Start is called before the first frame update void Start() { energyState = GetComponent <EnergyState>(); audioSource = GetComponent <AudioSource>(); }
/// <summary> /// <para> /// Returns the amount of energy required to be at the top of a given EnergyState. /// It's recommended that the actual EnergyState property be used to determine /// the current energy bucket a creature is in. /// </para> /// </summary> /// <param name="energyState"> /// EnergyState enum value for the bucket to get the upper energy bounding for. /// </param> /// <returns> /// System.Double representing the amount of energy to be at the top of a given energy state. /// </returns> public double UpperBoundaryForEnergyState(EnergyState energyState) { double energyBuckets = (species.MaximumEnergyPerUnitRadius * (double) Radius) / (double) 5; switch (energyState) { case EnergyState.Dead: return 0; case EnergyState.Deterioration: return energyBuckets * (double) 1; case EnergyState.Hungry: return energyBuckets * (double) 2; case EnergyState.Normal: return energyBuckets * (double) 4; case EnergyState.Full: return species.MaximumEnergyPerUnitRadius * (double) Radius; default: throw new ApplicationException("Unknown EnergyState."); } }
// Start is called before the first frame update void Start() { mesh = GetComponent<MeshRenderer>(); energyState = GetComponent<EnergyState>(); UpdateMaterial(); }
/// <summary> /// Creates a brand new state object for a plant. /// </summary> /// <internal/> public PlantState(string id, ISpecies species, int generation, EnergyState initialEnergyState, int initialRadius) : base(id, species, generation, initialEnergyState, initialRadius) { }
public void EnergySuperCharge() { ReplenishFullEnergy(true); playerEnergy = MAX_ENERGY; energyState = EnergyState.SUPER_CHARGE; }
// Start is called before the first frame update void Start() { energyState = GetComponent <EnergyState>(); }
//Moving the Player ship void movement() { if (state == EnergyState.IdleState || state == EnergyState.ConsumingState || state == EnergyState.RefreshState) { //Moving right if (Input.GetKey(KeyCode.RightArrow)) { Anchor.Rotate(new Vector3(0, 0, Time.deltaTime * speed)); { //Boosting(using Energy in the process) if (Input.GetKey(KeyCode.LeftShift)) { Debug.Log("Boost"); state = EnergyState.ConsumingState; Anchor.Rotate(new Vector3(0, 0, Time.deltaTime * (speed * boost))); } } } //Moving left if (Input.GetKey(KeyCode.LeftArrow)) { Anchor.Rotate(new Vector3(0, 0, Time.deltaTime * -speed)); { //Boosting(using Energy in the process) if (Input.GetKey(KeyCode.LeftShift)) { Debug.Log("Boost"); state = EnergyState.ConsumingState; Anchor.Rotate(new Vector3(0, 0, Time.deltaTime * (-speed * boost))); } } } } else { //Moving right(throttled) if (Input.GetKey(KeyCode.RightArrow)) { Anchor.Rotate(new Vector3(0, 0, Time.deltaTime * speed * throttle)); } //Moving left(throttled) if (Input.GetKey(KeyCode.LeftArrow)) { Anchor.Rotate(new Vector3(0, 0, Time.deltaTime * -speed * throttle)); } } //Energy usage while boosting if (state == EnergyState.ConsumingState) { curEnergy -= consumeRate; } if (Input.GetKey(KeyCode.LeftShift) == false) { if (curEnergy >= 100) { state = EnergyState.IdleState; } if (state != EnergyState.RechargeState && curEnergy < 100) { state = EnergyState.RefreshState; } } if (curEnergy <= 0) { state = EnergyState.RechargeState; if (curEnergy >= 100) { state = EnergyState.IdleState; } } //Normal Recharge(fast) if (state == EnergyState.RefreshState) { curEnergy += refreshRate; } //Recharge after complete exhaustion of the Player-Ships Energy(slow) if (state == EnergyState.RechargeState && (Input.GetKey(KeyCode.LeftShift) == false)) { curEnergy += rechargeRate; } }
private void OnPauseMenuDisengagedEvent(PauseMenuDisengagedEvent e) { currentEnergyState = previousEnergyState; }
private void OnPauseMenuEngagedEvent(PauseMenuEngagedEvent e) { previousEnergyState = currentEnergyState; currentEnergyState = EnergyState.Idle; }
// Start is called before the first frame update void Start() { energyState = GetComponent <EnergyState>(); parentEnergyState = ParentObject.GetComponent <EnergyState>(); }
// Start is called before the first frame update void Start() { energyState = GetComponent <EnergyState>(); UpdateScale(); }
/// <summary> /// <para> /// Returns the amount of energy required to be at the top of a given EnergyState. /// It's recommended that the actual EnergyState property be used to determine /// the current energy bucket a creature is in. /// </para> /// </summary> /// <param name="species">The species for which to calculate</param> /// <param name="energyState">EnergyState enum value for the bucket to get the upper energy bounding for.</param> /// <param name="radius">The radius of the organism to use in calculation</param> /// <returns> /// System.Double representing the amount of energy to be at the top of a given energy state. /// </returns> public static double UpperBoundaryForEnergyState(ISpecies species, EnergyState energyState, int radius) { var energyBuckets = (species.MaximumEnergyPerUnitRadius*(double) radius)/5; switch (energyState) { case EnergyState.Dead: return 0; case EnergyState.Deterioration: return energyBuckets*1; case EnergyState.Hungry: return energyBuckets*2; case EnergyState.Normal: return energyBuckets*4; case EnergyState.Full: return species.MaximumEnergyPerUnitRadius*(double) radius; default: throw new ApplicationException("Unknown EnergyState."); } }