Exemplo n.º 1
0
 public void HeatTheIron()
 {
     for (int w = 0; w < gridWidth; w++)
     {
         for (int h = 0; h < gridHeight; h++)
         {
             Stage2Tile tmpTile = stage2TileObjects[w, h].GetComponent <Stage2Tile>();
             tmpTile.AddMaterialMass(-materialMassLostPerHeating);
             tmpTile.SetHeat(100);
         }
     }
 }
Exemplo n.º 2
0
    public void Smithy(SUBBUTTONTYPE buttonType)
    {
        if (heat >= heatLostPerHit)
        {
            GameObject leftObject  = null;
            GameObject rightObject = null;
            GameObject upObject    = null;
            GameObject downObject  = null;

            if (posX - 1 >= 0)
            {
                leftObject = gridManager.stage2TileObjects[posX - 1, posY];
            }
            if (posY - 1 >= 0)
            {
                downObject = gridManager.stage2TileObjects[posX, posY - 1];
            }
            if (posX + 1 <= gridManager.stage2TileObjects.GetUpperBound(0))
            {
                rightObject = gridManager.stage2TileObjects[posX + 1, posY];
            }
            if (posY + 1 <= gridManager.stage2TileObjects.GetUpperBound(1))
            {
                upObject = gridManager.stage2TileObjects[posX, posY + 1];
            }

            float materialMassForEach = 0.0f;

            AddMaterialMass(-materialMassLostPerHit);
            //quality = Mathf.Clamp(quality - qualityLostPerHit, 0, quality);
            AddHeat(-heatLostPerHit);
            isChanged = true;
            if (materialMass > 0)
            {
                GameObject tmpObject = null;
                Stage2Tile tmpTile   = null;

                if (buttonType == SUBBUTTONTYPE.Center)
                {
                    materialMassForEach = Mathf.Clamp(4 * materialMassPerBlock, 0, materialMass);
                    AddMaterialMass(-materialMassForEach);
                    materialMassForEach = materialMassForEach / 4;


                    //if (leftObject != null) leftObject.GetComponent<Stage2Tile>().isActive = true;
                    //if (rightObject != null) rightObject.GetComponent<Stage2Tile>().isActive = true;
                    //if (upObject != null) upObject.GetComponent<Stage2Tile>().isActive = true;
                    //if (downObject != null) downObject.GetComponent<Stage2Tile>().isActive = true;
                    for (int side = 0; side < 4; side++)
                    {
                        switch (side)
                        {
                        case (0): tmpObject = leftObject; break;

                        case (1): tmpObject = rightObject; break;

                        case (2): tmpObject = upObject; break;

                        case (3): tmpObject = downObject; break;
                        }
                        if (tmpObject != null)
                        {
                            tmpTile = tmpObject.GetComponent <Stage2Tile>();
                            if (tmpTile.materialMass > 0)
                            {
                                tmpTile.AddHeat(-heatLostPerHit);
                            }
                            else
                            {
                                tmpTile.SetHeat(heat);
                            }
                            tmpTile.AddMaterialMass(materialMassForEach);
                            tmpTile.isChanged = true;
                            if (tmpTile.currentForm == FORMS.Empty)
                            {
                                tmpTile.currentForm = FORMS.Block;
                            }
                        }
                        //if (rightObject != null) rightObject.GetComponent<Stage2Tile>().AddQuality(qualityForEach);
                        //if (upObject != null) upObject.GetComponent<Stage2Tile>().AddQuality(qualityForEach);
                        //if (downObject != null) downObject.GetComponent<Stage2Tile>().AddQuality(qualityForEach);
                    }
                }
                else if (buttonType == SUBBUTTONTYPE.Left ||
                         buttonType == SUBBUTTONTYPE.Down ||
                         buttonType == SUBBUTTONTYPE.Right ||
                         buttonType == SUBBUTTONTYPE.Up)
                {
                    materialMassForEach = Mathf.Clamp(materialMassPerBlock, 0, materialMass);
                    AddMaterialMass(-materialMassForEach);

                    switch (buttonType)
                    {
                    case (SUBBUTTONTYPE.Left): tmpObject = rightObject; break;

                    case (SUBBUTTONTYPE.Right): tmpObject = leftObject; break;

                    case (SUBBUTTONTYPE.Up): tmpObject = downObject; break;

                    case (SUBBUTTONTYPE.Down): tmpObject = upObject; break;
                    }

                    if (tmpObject != null)
                    {
                        tmpTile = tmpObject.GetComponent <Stage2Tile>();
                        if (tmpTile.materialMass > 0)
                        {
                            tmpTile.AddHeat(-heatLostPerHit);
                        }
                        else
                        {
                            tmpTile.SetHeat(heat);
                        }
                        tmpTile.AddMaterialMass(materialMassForEach);
                        tmpTile.isChanged = true;
                        if (tmpTile.currentForm == FORMS.Empty)
                        {
                            tmpTile.currentForm = FORMS.Block;
                        }
                    }
                }
            }
            ShowValues();
            gridManager.AfterHammerHit();
        }
    }