Example #1
0
 public CubeField(Entity parent)
 {
     Position(parent.Position());
     SetParent(parent);
     InitChildren();
     InitAI();
 }
Example #2
0
 public void ApplyGravity(Entity body)
 {
     var r = Position() - body.Position();
     var G = 10.0f;
     var m1 = rigidBody.mass;
     var m2 = body.rigidBody.mass;
     var force = G * m1 * m2 / Mathf.Pow(r.magnitude, 1.6f) * r.normalized;
     force = Vector3.ClampMagnitude(force, 14f * m2);
     body.rigidBody.AddForce(force, ForceMode.Force);
 }
 public List<Fish> SpawnFish(Entity fluid)
 {
     List<Fish> fishes = new List<Fish>();
     Vector3 scale = fluid.Scale();
     float volume = scale.x * scale.y * scale.z;
     float density = 1.5f / 125000f;
     float max = 100;
     float num = Mathf.Min(volume * density, max) * Random.value;
     for (int i = 1; i <= num; i++)
     {
         Vector3 offset = Vector3.Scale(Util.RandomVector(), scale/2);
         Vector3 pos = fluid.Position() + offset;
         float sizeMin = 0.5f;
         float sizeMax = Mathf.Pow(volume, 0.25f);
         float x = Random.value;
         float y = Random.value;
         Vector3 size = (sizeMin + 1f / (1f/sizeMax + x*y)) * Util.RandomVector(1f, 1.5f);
         Fish fish = new Fish(pos, size);
         fish.currentFluid = fluid.Component<Fluid>();
         fishes.Add(fish);
     }
     return fishes;
 }
Example #4
0
    public Entity UseCharacter(string c)
    {
        lastCharacter = character;

        if (c == "Dolphin")
        {
            character = dolphin;
        }
        else if (c == "Mekka")
        {
            character = mekka;
        }

        if (lastCharacter != character)
        {
            // Update character state
            character.Position(lastCharacter.Position());
            character.Velocity(lastCharacter.Velocity());
            character.Rotation(lastCharacter.Rotation());

            // Hide and disable old character
            lastCharacter.gameObject.SetActive(false);
            lastCharacter.spiritMeter.HideMeter();

            // Show and enable new character
            character.gameObject.SetActive(true);

            // Enable gravity
            if (character is Mekka)
                character.Fall();
        }

        return character;
    }