예제 #1
0
    public virtual void Draw()
    {
        if (Multimesh != null)
        {
            int visibleParticles = 0;
            foreach (Particle particle in particles)
            {
                if (particle.alive)
                {
                    Transform t = particle.transform;

                    if (!local)
                    {
                        t = GlobalTransform.AffineInverse() * t;
                    }

                    Multimesh.SetInstanceTransform(visibleParticles, t);
                    Multimesh.SetInstanceColor(visibleParticles, particle.color);
                    visibleParticles++;
                }
            }

            Multimesh.VisibleInstanceCount = visibleParticles;
        }
    }
예제 #2
0
    public void SelectInstance(int instanceNum)
    {
        if (SimultaneousSelection == 1 && _selected != -1 && instanceNum != _selected)
        {
            UnselectInstance(_selected);
        }

        _selected = instanceNum;
        float selectionWidht = 0.55f;

        Multimesh.SetInstanceColor(instanceNum, new Color(selectionWidht, selectionWidht, selectionWidht));
    }
예제 #3
0
    public override void _Ready()
    {
        // Init vars
        random = new RandomNumberGenerator();

        Color grass = Color.Color8(100, 200, 25);
        Color water = Color.Color8(0, 130, 200);

        // Set meshes count
        Multimesh.InstanceCount = Width * Length * Height;

        // Create map
        Mesh    mesh     = Multimesh.Mesh;
        Vector3 meshSize = mesh.GetAabb().Size;
        int     instance = 0;

        Console.WriteLine(meshSize);

        for (int h = 0; h < Height; h++)
        {
            for (int l = 0; l < Length; l++)
            {
                for (int w = 0; w < Width; w++)
                {
                    Color currentColor;

                    if (h <= Height - 2)
                    {
                        currentColor = grass;
                    }
                    else
                    {
                        int color = random.RandiRange(0, 1);

                        currentColor = color == 0 ? grass : water;
                    }
                    Multimesh.SetInstanceColor(instance, currentColor);

                    Transform position = Transform.Identity.Translated(new Vector3(w * meshSize.x, h * meshSize.y, l * meshSize.z));
                    Multimesh.SetInstanceTransform(instance, position);

                    Console.WriteLine(position.origin);

                    instance++;
                }
            }
        }
    }
예제 #4
0
    public override void _Process(float delta)
    {
        if (++frame == 1000)
        {
            var elapsed = OS.GetSystemTimeMsecs() - started;
            GD.Print("Result: ", elapsed);
            GetTree().Quit();
            return;
        }

        {
            int i = 0;
            for (int y = 0; y < game.h; ++y)
            {
                for (int x = 0; x < game.w; ++x)
                {
                    var t = game.tiles[i];
                    var v = t.GetValue();

                    if (t.active)
                    {
                        t.next = v == 2 || v == 3;
                    }
                    else
                    {
                        t.next = v == 3;
                    }

                    ++i;
                }
            }
        }

        {
            for (int i = 0; i < game.tiles.Length; ++i)
            {
                var t = game.tiles[i];
                t.active = t.next;
                if (t.active)
                {
                    t.life = 20;
                }
                else if (t.life > 0)
                {
                    --t.life;
                }
            }
        }

        if (++counter == 10)
        {
            game.At(24, 25).active = true;
            game.At(25, 25).active = true;
            game.At(26, 25).active = true;
            game.At(25, 24).active = true;
            counter = 0;
        }

        {
            for (int i = 0; i < game.tiles.Length; ++i)
            {
                var t = game.tiles[i];
                if (t.active)
                {
                    Multimesh.SetInstanceColor(i, new Color(1, 0, 0, 1));
                }
                else
                {
                    Multimesh.SetInstanceColor(i, new Color(0, t.life / 50.0f, 0, 1));
                }
            }
        }
    }
예제 #5
0
 public void UnselectInstance(int instanceNum)
 {
     Multimesh.SetInstanceColor(instanceNum, new Color(0, 0, 0, 0));
 }