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;
    }
示例#2
0
        /// <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.");
            }
        }
示例#3
0
    private void Initialize()
    {
        previousEnergyState = EnergyState.Idle;
        currentEnergyState  = EnergyState.Idle;

        currentEnergy    = startingEnergy;
        currentMaxEnergy = initialMaxEnergy;
    }
示例#4
0
 /// <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();
 }
示例#5
0
        IEnumerator regenerateRunEnergy()
        {
            while (m_RunEnergy < m_MaxRunEnergy)
            {
                yield return(new WaitForSeconds(m_RegenRunTime));

                ++m_RunEnergy;
            }
            m_RunEnergyRoutine = null;
            m_RunEnergyState   = EnergyState.idle;
        }
示例#6
0
        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>();
     }
 }
示例#8
0
	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;
		}
	}
示例#9
0
        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;
        }
示例#10
0
    //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;
    }
示例#11
0
    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;
        }
    }
示例#12
0
    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>();
    }
示例#13
0
    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?
        }
    }
示例#14
0
 // Start is called before the first frame update
 void Start()
 {
     energyState = GetComponent <EnergyState>();
     audioSource = GetComponent <AudioSource>();
 }
示例#15
0
        /// <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();
 }
示例#17
0
 /// <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)
 {
 }
示例#18
0
 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>();
 }
示例#20
0
    //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;
        }
    }
示例#21
0
 /// <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();
 }
示例#22
0
 private void OnPauseMenuDisengagedEvent(PauseMenuDisengagedEvent e)
 {
     currentEnergyState = previousEnergyState;
 }
示例#23
0
 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>();
 }
示例#25
0
 // Start is called before the first frame update
 void Start()
 {
     energyState = GetComponent <EnergyState>();
     UpdateScale();
 }
示例#26
0
 /// <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)
 {
 }
示例#27
0
        /// <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.");
            }
        }