Ejemplo n.º 1
0
    private void ChangeCount(DigMode key, int x, int y)
    {
        int index = Count_v * x + y;

        if (key == DigMode.pickel)
        {
            if (0 <= index && index < 150)//???
            {
                panelGenerator._panelHP[x, y]--;
            }
        }
        else if (key == DigMode.hummer)
        {
            if (0 <= index && index < 150)//???
            {
                panelGenerator._panelHP[x, y] -= 2;
            }
        }

        if (panelGenerator._panelHP[x, y] >= 0)
        {
            panelGenerator.panelSpriteRenderer[x, y].sprite = panelGenerator.panelSprites[panelGenerator._panelHP[x, y]];
        }
        else
        {
            panelGenerator.panelSpriteRenderer[x, y].gameObject.SetActive(false);
        }
    }
Ejemplo n.º 2
0
 public void SetDigMode(string mode)
 {
     try
     {
         digMode = (DigMode)Enum.Parse(typeof(DigMode), mode, true);
     }
     catch (Exception)
     {
     }
 }
Ejemplo n.º 3
0
    public void SetDigMode(string mode)
    {
        try
        {
            digMode = (DigMode)Enum.Parse(typeof(DigMode), mode, true);
        }
        catch (Exception)
        {

        }
    }
Ejemplo n.º 4
0
    private void DecreaseHP(DigMode key)
    {
        if (key == DigMode.pickel)
        {
            hp--;
        }
        else if (key == DigMode.hummer)
        {
            hp -= 2;
        }

        hpBar.value = (float)hp / sliderHpDiscountRate;
    }
Ejemplo n.º 5
0
        public void DigCylinder(vec3 worldNormal, vec3 position, float radius, IEnumerable <int> filterMaterials, int terrainMaterialId = 1, DigMode digMode = DigMode.Substract)
        {
            cylinderNode.MaterialIndex = terrainMaterialId;
            cylinderNode.SetParameterFloat("digRadius", radius);
            cylinderNode.SetParameterVec3("digPosition", position);

            vec3 dx, dy, dz;

            player.AlignmentSystem(worldNormal, out dx, out dy, out dz);
            cylinderNode.SetParameterVec3("digDirX", dx);
            cylinderNode.SetParameterVec3("digDirY", dy);
            cylinderNode.SetParameterVec3("digDirZ", dz);

            Dig(cylinderNode, new BoundingSphere(position, radius * 1.5f), digMode, filterMaterials);
        }
Ejemplo n.º 6
0
        public void Dig(CsgNode shape, BoundingSphere shapeBoundary, DigMode digMode, IEnumerable <int> materialFilter)
        {
            CsgNode digShape = null;

            // constraintDiffNode performs the constraint as a CSG operation
            // by cutting away anything of thge digging shape not inside the allowed area.
            CsgOpDiff constraintDiffNode = new CsgOpDiff();

            // Assemble difference operation by applying all drone constraints.
            player.AddDroneConstraints(constraintDiffNode, shapeBoundary.Center);

            // When placing material, add a safety margin around the player to prevent it from physically glitching trough the terrain
            if (digMode == DigMode.Add)
            {
                playerNode.SetParameterFloat("playerRadius", player.Character.CharacterDiameter * 0.5f + 0.2f);
                playerNode.SetParameterVec3("playerPosition", player.Character.Position);
                playerNode.SetParameterVec3("digDirX", new vec3(1, 0, 0));
                playerNode.SetParameterVec3("digDirZ", new vec3(0, 0, 1));
                playerNode.SetParameterVec3("digDirY", new vec3(0, 0, player.Character.BodyHeight * 0.5f + 0.2f));
                constraintDiffNode.AddNode(playerNode);
            }

            // We apply the constraint by substracting it from the given shape.
            CsgOpConcat constraintedShape = new CsgOpConcat();

            constraintedShape.AddNode(shape);
            constraintedShape.AddNode(constraintDiffNode);
            digShape = constraintedShape;

            CsgNode digNode = null;

            // Depending on the digging mode, we either add or substract the digging shape from the terrain.
            if (digMode == DigMode.Substract)
            {
                digNode = new CsgOpDiff(digShape);
            }
            else
            {
                digNode = new CsgOpUnion(digShape);
            }

            // Filter for tools
            CsgNode filterNode = digNode;

            if (materialFilter != null)
            {
                CsgFilterNode filter = new CsgFilterNode(true, digNode);
                foreach (int mat in materialFilter)
                {
                    filter.AddMaterial(mat);
                }
                filter.AddMaterial(0); // Air must be white-listed, too!
                filterNode = filter;
            }

            // Float elimination
            CsgOpConcat collapser = new CsgOpConcat(filterNode);

            collapser.AddNode(new CsgCollapseNode());

            // Callback for statistical purposes.
            CsgStatCallback finalNode = new CsgStatCallback(collapser, 4, 4);

            finalNode.AddSimpleVolumeCallback("UpvoidMiner", UpvoidMiner.ModDomain, "UpvoidMiner.DiggingController", "StatCallback");
            finalNode.AddVolumeChangePointCallback("UpvoidMiner", UpvoidMiner.ModDomain, "UpvoidMiner.DiggingController", "PointCallback");

            world.Terrain.ModifyTerrain(shapeBoundary, finalNode);
        }