Beispiel #1
0
    public bool Split(float c)
    {
        if (ULife == 0)
        {
            //Step 1, initialize

            ULife = RandomFloat.Range(0.5f, 1f);
            BLife = 0;
        }

        float BNext = BLife + h(c, 0.0025f, 0.002f) * (1 - BLife); //Step 2

        if (BNext > ULife)
        {
            //Tumble and return to step 1
            ULife = 0;
            BLife = 0;
            return(true);
        }
        else
        {
            //Keep running, and return to step 2
            BLife = BNext;
            return(false);
        }
    }
Beispiel #2
0
 public static Vector3 GetRandomVector(float xRangeMin, float yRangeMin, float zRangeMin, float xRangeMax, float yRangeMax, float zRangeMax)
 {
     return(new Vector3
            (
                RandomFloat.Range(xRangeMin, xRangeMin),
                RandomFloat.Range(yRangeMin, yRangeMax),
                RandomFloat.Range(zRangeMin, zRangeMax)
            ));
 }
Beispiel #3
0
 public static Vector3 GetRandomVector(float xRange, float yRange, float zRange)
 {
     return(new Vector3
            (
                RandomFloat.Range(-xRange, xRange),
                RandomFloat.Range(-yRange, yRange),
                RandomFloat.Range(-zRange, zRange)
            ));
 }
Beispiel #4
0
    internal static Vector3 GetRandomPosition(this BoxCollider2D self, PositionSpace space = PositionSpace.World)
    {
        Vector3 pos = (space == PositionSpace.Local) ?
                      self.transform.localPosition
                                        : self.transform.position;

        pos += (Vector3)self.offset + new Vector3(RandomFloat.Range(-self.size.x, self.size.x) / 2, RandomFloat.Range(-self.size.y, self.size.y) / 2, 0);

        return(pos);
    }
    //Simulates numCells many cells with iterations many steps each
    public void CreateCells(int numCells)
    {
        cells[0] = new List <Cell>();
        for (int i = 0; i < numCells; i++)
        {
            float x = RandomFloat.Range(-12f, 12f);
            float z = RandomFloat.Range(-12f, 12f);

            Cell cell = BacteriaFactory.CreateNewCell(x, z, RandomFloat.Range(0, 2 * MathFloat.PI), false);
            cells[0].Add(cell);
            allCells.Add(cell);
        }
    }
Beispiel #6
0
    public static Vector3 GetRandomPointInVolume(this Bounds self)
    {
        Vector3 point   = self.center;
        Vector3 extents = self.extents;

        point += new Vector3
                 (
            RandomFloat.Range(-extents.x, extents.x),
            RandomFloat.Range(-extents.y, extents.y),
            RandomFloat.Range(-extents.z, extents.z)
                 );
        return(point);
    }
Beispiel #7
0
    public static Color GetRandomHueColor(float saturation, float lightness)
    {
        ColorHSL hsl = new ColorHSL()
        {
            h = RandomFloat.Range(0, 360),
            s = saturation,
            l = lightness
        };
        Color rgb;

        hslToRgb(hsl, out rgb);
        return(rgb);
    }
Beispiel #8
0
    internal static Vector3 GetRandomPosition(this CircleCollider2D self, PositionSpace space = PositionSpace.World)
    {
        Vector3 pos = (space == PositionSpace.Local) ?
                      self.transform.localPosition
                                        : self.transform.position;

        Vector3 point = new Vector3(RandomFloat.Range(-self.radius, self.radius), 0, 0);

        point = point.RotateZ(RandomFloat.Range(0, 360));

        pos += (Vector3)self.offset + point;

        return(pos);
    }
    protected float CalculateTumbleAngle()
    {
        //Tumble angle based on article (Edgington)
        float newAngle = RandomFloat.Range(18f, 98f);
        float rand     = RandomFloat.Range(0.0f, 1.0f);

        if (rand > 0.5)
        {
            newAngle *= -1;
        }
        newAngle *= MathFloat.PI / 180;
        newAngle += this.angle;
        return(newAngle);
    }
Beispiel #10
0
    public bool DecideState(float c)
    {
        SolveStiff(c);
        double r = RandomFloat.NextFloat();

        if (S > U)
        {
            S = 0.0f;
            U = RandomFloat.Range(0f, 0.8f);
            return(false); //Tumbling
        }
        else
        {
            return(true); //Running
        }
    }
Beispiel #11
0
    internal virtual void TakeDamage()
    {
        if (state == MonsterState.Living)
        {
            Vector3 splashVector = (transform.position - Player.Instance.transform.position).normalized;

            life -= 1;
            if (life == 0)
            {
                ApplySound();
                state = MonsterState.Dying;

                GoTweenChain chain = new GoTweenChain();
                chain.insert(0,
                             transform
                             .scaleTo(0.5f, 0.75f, true)
                             .eases(GoEaseType.QuartOut)
                             );
                chain.insert(0,
                             transform
                             .localEularAnglesTo(0.5f, new Vector3(0, 0, RandomFloat.Range(-180, 180)))
                             .eases(GoEaseType.QuadOut)
                             );
                chain.insert(0.25f,
                             gameObject
                             .alphaTo(0.25f, 0, GoEaseType.QuartOut)
                             );
                chain.setOnCompleteHandler(c => gameObject.DestroySelf());
                chain.Start();
            }

            transform.position += splashVector * 25;

//          bool isDying = ( life == 0 );
//          transform.position += splashVector * ( isDying ? 100 : 25 );
        }
    }