Exemple #1
0
    void AbsorbStress(GameObject gameObject)
    {
        StressorController stressor = (StressorController)gameObject.GetComponent <StressorController> ();

        if (stressor.creator == this.gameObject)
        {
            return;
        }

        StressLevel += stressor.stressLevel;
        Destroy(gameObject);
    }
    void Update()
    {
        if (ShouldGenerate())
        {
            float angle       = ComputeAngle();
            float stressLevel = ComputeStressLevel();

            Quaternion quaternion = Quaternion.AngleAxis(angle, Vector3.up);

            float   generationRadius = mainCamera.MaxDistanceOutsideOfCamera;
            Vector3 spawnPoint       = quaternion * new Vector3(generationRadius, 0, generationRadius);

            StressorController stressor = (StressorController)Instantiate(stressorTemplate, spawnPoint, Quaternion.identity);

            stressor.applyForce(spawnPoint.normalized * -1 * ComputeInitialForce());
            stressor.setStressLevel(stressLevel);

            nextGeneratedTime = ComputeNextGenerationTime();
        }
    }
Exemple #3
0
    private void TriggerOutburst()
    {
        const float increament          = 360f / NumberStressorsProducedDuringOutburst;
        float       outburstStressLevel = (float)MaxStressLevel / 8;

        if (initialAngle < 0)
        {
            initialAngle = Random.Range(0f, increament);
        }

        for (int i = 0; i < NumberStressorsProducedDuringOutburst; i++)
        {
            float      angle      = initialAngle + increament * i;
            Quaternion quaternion = Quaternion.AngleAxis(angle, Vector3.up);

            Vector3 forceUnitVector = quaternion * new Vector3(1, 0, 1);

            StressorController stressor = (StressorController)
                                          Instantiate(stressorTemplate, this.transform.position, Quaternion.identity);
            stressor.applyForce(forceUnitVector * 220);              // TODO replace hard coded force scalor
            stressor.creator = this.gameObject;
            stressor.setStressLevel(2 * outburstStressLevel);

            // TODO have an out-of-bounds area to cleanup stressors instead
            Destroy(stressor.gameObject, 1);
        }

        // this should probably just be part of the breathingController
        this.transform.localScale = Vector3.one * BreathingController.baseFactor * (1 + BreathingController.fluctuation);
        StressLevel -= outburstStressLevel;

        if (StressLevel < MaxStressLevel / 2)
        {
            EndLashout();
        }
    }