コード例 #1
0
ファイル: EggSack.cs プロジェクト: eaclou/Evolution
 // Buffer time for late bloomers to hatch
 private void BeginLifeStageMature()
 {
     curLifeStage = EggLifeStage.Mature;
     lifeStageTransitionTimeStepCounter = 0;
     developmentProgress = 1f;
     UpdateEggSackSize(1f, true);
 }
コード例 #2
0
ファイル: EggSack.cs プロジェクト: eaclou/Evolution
    public void ParentDiedWhilePregnant()
    {
        parentAgent                = null;
        fixedJoint.enabled         = false;
        fixedJoint.enableCollision = false;
        fixedJoint.connectedBody   = null;

        curLifeStage = EggLifeStage.Decaying;
        lifeStageTransitionTimeStepCounter = 0;
    }
コード例 #3
0
ファイル: EggSack.cs プロジェクト: eaclou/Evolution
    private void CheckForLifeStageTransition()
    {
        switch (curLifeStage)
        {
        case EggLifeStage.Growing:
            // Transition from being attached to parent Agent rigidbody, to free-floating:
            // Only happens if this eggSack belongs to a pregnant parent Agent and only starts once
            if (isPregnant && !isBeingBorn && parentAgent)
            {
                CommenceBeingBorn();
            }
            if (lifeStageTransitionTimeStepCounter >= growDurationTimeSteps)
            {
                BeginLifeStageMature();
            }
            if (birthTimeComplete)
            {
                isBeingBorn = false;
            }
            if (!isProtectedByParent && isAttachedBySpring)
            {
                //float distToParent = (parentAgentRef.bodyRigidbody.transform.position - rigidbodyRef.transform.position).magnitude;
                SeverJointAttachment();
            }
            break;

        case EggLifeStage.Mature:
            if (lifeStageTransitionTimeStepCounter >= matureDurationTimeSteps || isOutsideMap)
            {
                curLifeStage = EggLifeStage.Decaying;
                lifeStageTransitionTimeStepCounter = 0;
            }
            break;

        case EggLifeStage.Decaying:
            if (currentBiomass <= 0f)
            {
                //Decay fully!
                currentBiomass = 0f;
                curLifeStage   = EggLifeStage.Null;
                lifeStageTransitionTimeStepCounter = 0;
                isDepleted           = true; // flagged for respawn
                mainCollider.enabled = false;
            }
            break;

        case EggLifeStage.Null:
            healthStructural = 0f;     // temp hack
            break;

        default:
            Debug.LogError($"NO SUCH ENUM ENTRY IMPLEMENTED, YOU FOOL!!! ({curLifeStage})");
            break;
        }
    }
コード例 #4
0
ファイル: EggSack.cs プロジェクト: eaclou/Evolution
    private void BeginLifeStageGrowing(Agent parent, AgentGenome parentGenome, Vector3 startPos)
    {
        curLifeStage = EggLifeStage.Growing;
        lifeStageTransitionTimeStepCounter = 0;
        parentAgent           = parent;
        birthTimeStepsCounter = 0;

        curNumEggs            = maxNumEggs;
        developmentProgress   = 0f;
        growthScaleNormalized = 0.01f;
        decayStatus           = 0f;

        rigidbodyRef.mass            = 5f;
        rigidbodyRef.velocity        = Vector2.zero;
        rigidbodyRef.angularVelocity = 0f;
        rigidbodyRef.drag            = 7.5f;
        rigidbodyRef.angularDrag     = 1.5f;

        isProtectedByParent = parent;
        isAttachedBySpring  = parent;

        if (!parent)
        {
            transform.localPosition = startPos;

            // REVISIT THIS:
            var   parentBoundingBox = parentGenome.bodyGenome.GetFullsizeBoundingBox();
            float parentScale       = (parentBoundingBox.x + parentBoundingBox.y) * 0.5f;
            fullSize.x = parentScale;  // golden ratio? // easter egg for math nerds?
            fullSize.y = parentScale;
        }
        else
        {
            //currentBiomass = 0.05f;
            //parentAgentRef.currentBiomass -= 0.05f; // *** Handled within agent initPregnancy
            rigidbodyRef.transform.position = parent.bodyRigidbody.position;

            fixedJoint.connectedBody = parent.bodyRigidbody;
            fixedJoint.autoConfigureConnectedAnchor = false;
            fixedJoint.anchor          = new Vector2(0f, parent.fullSizeBoundingBox.y * 0.25f);
            fixedJoint.connectedAnchor = new Vector2(0f, parent.fullSizeBoundingBox.y * -0.25f);
            fixedJoint.enableCollision = false;
            fixedJoint.enabled         = true;
            fixedJoint.frequency       = springJointMaxStrength;
        }

        mainCollider.enabled = true;

        isDepleted  = false;
        isBeingBorn = false;
        prevPos     = transform.position;

        UpdateEggSackSize(0.05f, true);
    }
コード例 #5
0
ファイル: EggSack.cs プロジェクト: eaclou/Evolution
    public void ConsumedByPredatorAgent()
    {
        mainCollider.enabled = false;
        curLifeStage         = EggLifeStage.Null;
        isDepleted           = true;
        lifeStageTransitionTimeStepCounter = 0;
        growthScaleNormalized = 0.01f;
        UpdateEggSackSize(growthScaleNormalized, false);

        currentBiomass = 0f;

        fixedJoint.enabled  = false;
        isAttachedBySpring  = false;
        isProtectedByParent = false;
        decayStatus         = 1f;
    }
コード例 #6
0
ファイル: EggSack.cs プロジェクト: eaclou/Evolution
 public void Nullify()
 {
     isDepleted   = true;
     curLifeStage = EggLifeStage.Null;
 }