Exemplo n.º 1
0
    private void checkInventoryCardMode()
    {
        InventoryCard.MODES mode = INVENTORY_CARD.getMode();
        Part partBeingPreviewed = null, partBeingEquipt = null;

        Part[]   previewRobotParts = previewRobot.getParts();
        string[] robotStats        = null;
        if (CONFIGURATION_CARD.getMode() != mode)
        {
            switch (mode)
            {
            case InventoryCard.MODES.VIEW_PART_STATS:
                MASK.SetActive(false);
                previewRobot.GAME_OBJECT.transform.localPosition = new Vector3(previewRobot.GAME_OBJECT.transform.localPosition.x, previewRobot.GAME_OBJECT.transform.localPosition.y, 500);
                previewRobot.GAME_OBJECT.transform.localScale    = new Vector3(100, 100, 100);
                CONFIGURATION_CARD.initialize();
                if (partWithPreviewedTexture != null)
                {
                    if (partWithPreviewedTexture.getShape() == Shape.SHAPES.HEMISPHERE && !partWithPreviewedTexture.GAME_OBJECT.GetComponent <MeshFilter>().mesh.name.Contains("Sphere"))
                    {
                        partWithPreviewedTexture.GAME_OBJECT.transform.localPosition = new Vector3(partWithPreviewedTexture.GAME_OBJECT.transform.localPosition.x, partWithPreviewedTexture.GAME_OBJECT.transform.localPosition.y - .5f, partWithPreviewedTexture.GAME_OBJECT.transform.localPosition.z);
                    }
                    else if (partWithPreviewedTexture.getShape() != Shape.SHAPES.HEMISPHERE && partWithPreviewedTexture.GAME_OBJECT.GetComponent <MeshFilter>().mesh.name.Contains("Sphere"))
                    {
                        partWithPreviewedTexture.GAME_OBJECT.transform.localPosition = new Vector3(partWithPreviewedTexture.GAME_OBJECT.transform.localPosition.x, partWithPreviewedTexture.GAME_OBJECT.transform.localPosition.y + .5f, partWithPreviewedTexture.GAME_OBJECT.transform.localPosition.z);
                    }
                    partWithPreviewedTexture.changeTextureAndShape(partWithPreviewedTexture.getImage().getTexture(), MESHES[(int)partWithPreviewedTexture.getShape()], partWithPreviewedTexture.getShape());
                    partWithPreviewedTexture = null;
                }
                break;

            case InventoryCard.MODES.PREVIEW_PART:
                partBeingPreviewed = INVENTORY_CARD.getPartBeingPreviewed();
                previewRobot.GAME_OBJECT.transform.localPosition = new Vector3(previewRobot.GAME_OBJECT.transform.localPosition.x, previewRobot.GAME_OBJECT.transform.localPosition.y, 125);
                previewRobot.GAME_OBJECT.transform.localScale    = new Vector3(25, 25, 25);
                MASK.SetActive(true);
                List <Part>       parts       = new List <Part>();
                List <Attachment> attachments = new List <Attachment>();
                if (partBeingPreviewed is Attachment)
                {
                    attachments.Add((Attachment)partBeingPreviewed);
                }
                for (int robotPartIndex = 0; robotPartIndex < robotParts.Count; ++robotPartIndex)
                {
                    if (!(robotParts[robotPartIndex] is Attachment))
                    {
                        if (partBeingPreviewed.GetType() == robotParts[robotPartIndex].GetType())
                        {
                            partWithPreviewedTexture = previewRobotParts[robotPartIndex];
                            if (partBeingPreviewed.getShape() == Shape.SHAPES.HEMISPHERE && !previewRobotParts[robotPartIndex].GAME_OBJECT.GetComponent <MeshFilter>().mesh.name.Contains("Sphere"))
                            {
                                previewRobotParts[robotPartIndex].GAME_OBJECT.transform.localPosition = new Vector3(previewRobotParts[robotPartIndex].GAME_OBJECT.transform.localPosition.x, previewRobotParts[robotPartIndex].GAME_OBJECT.transform.localPosition.y - .5f, previewRobotParts[robotPartIndex].GAME_OBJECT.transform.localPosition.z);
                            }
                            else if (partBeingPreviewed.getShape() != Shape.SHAPES.HEMISPHERE && previewRobotParts[robotPartIndex].GAME_OBJECT.GetComponent <MeshFilter>().mesh.name.Contains("Sphere"))
                            {
                                previewRobotParts[robotPartIndex].GAME_OBJECT.transform.localPosition = new Vector3(previewRobotParts[robotPartIndex].GAME_OBJECT.transform.localPosition.x, previewRobotParts[robotPartIndex].GAME_OBJECT.transform.localPosition.y + .5f, previewRobotParts[robotPartIndex].GAME_OBJECT.transform.localPosition.z);
                            }
                            previewRobotParts[robotPartIndex].changeTextureAndShape(partBeingPreviewed.getImage().getTexture(), MESHES[(int)partBeingPreviewed.getShape()], partBeingPreviewed.getShape());
                        }
                        parts.Add(partBeingPreviewed.GetType() == robotParts[robotPartIndex].GetType() ? partBeingPreviewed : robotParts[robotPartIndex]);
                    }
                    else if (robotParts[robotPartIndex].GetType() != partBeingPreviewed.GetType())
                    {
                        attachments.Add((Attachment)robotParts[robotPartIndex]);
                    }
                }
                Robot tempRobot = new Robot("", true, robot.isHuman(), (Head)parts[(int)PART_INDICES.HEAD], (Body)parts[(int)PART_INDICES.BODY], (Mobility)parts[(int)PART_INDICES.MOBILITY], attachments.ToArray());
                robotStats = tempRobot.getRobotStatStrings();
                double[] differenceInStats = robot.compareTo(tempRobot);
                for (int differenceInStatsIndex = FIRST_STAT_INDEX; differenceInStatsIndex < differenceInStats.Length; ++differenceInStatsIndex)
                {
                    robotStats[differenceInStatsIndex - FIRST_STAT_INDEX] += (differenceInStats[differenceInStatsIndex] != 0 ? " (" + applyStatDifferenceFormatting(differenceInStats[differenceInStatsIndex], robotStats[differenceInStatsIndex - FIRST_STAT_INDEX].Contains("Weight")) + ")" : "");
                }
                break;

            case InventoryCard.MODES.EQUIPT_PART:
                MASK.SetActive(false);
                partBeingEquipt = INVENTORY_CARD.getPartBeingEquipt();
                if (partWithPreviewedTexture != null)
                {
                    if (partWithPreviewedTexture.getShape() == Shape.SHAPES.HEMISPHERE && !partWithPreviewedTexture.GAME_OBJECT.GetComponent <MeshFilter>().mesh.name.Contains("Sphere"))
                    {
                        partWithPreviewedTexture.GAME_OBJECT.transform.localPosition = new Vector3(partWithPreviewedTexture.GAME_OBJECT.transform.localPosition.x, partWithPreviewedTexture.GAME_OBJECT.transform.localPosition.y - .5f, partWithPreviewedTexture.GAME_OBJECT.transform.localPosition.z);
                    }
                    else if (partWithPreviewedTexture.getShape() != Shape.SHAPES.HEMISPHERE && partWithPreviewedTexture.GAME_OBJECT.GetComponent <MeshFilter>().mesh.name.Contains("Sphere"))
                    {
                        partWithPreviewedTexture.GAME_OBJECT.transform.localPosition = new Vector3(partWithPreviewedTexture.GAME_OBJECT.transform.localPosition.x, partWithPreviewedTexture.GAME_OBJECT.transform.localPosition.y + .5f, partWithPreviewedTexture.GAME_OBJECT.transform.localPosition.z);
                    }
                    partWithPreviewedTexture.changeTextureAndShape(partWithPreviewedTexture.getImage().getTexture(), MESHES[(int)partWithPreviewedTexture.getShape()], partWithPreviewedTexture.getShape());
                    partWithPreviewedTexture = null;
                }
                for (int robotPartIndex = 0; robotPartIndex < robotParts.Count; ++robotPartIndex)
                {
                    if (robotParts[robotPartIndex].GetType() == partBeingEquipt.GetType())
                    {
                        robotParts[robotPartIndex] = partBeingEquipt;
                        if (!(partBeingEquipt is Attachment))
                        {
                            if (partBeingEquipt.getShape() == Shape.SHAPES.HEMISPHERE && !previewRobotParts[robotPartIndex].GAME_OBJECT.GetComponent <MeshFilter>().mesh.name.Contains("Sphere"))
                            {
                                previewRobotParts[robotPartIndex].GAME_OBJECT.transform.localPosition = new Vector3(previewRobotParts[robotPartIndex].GAME_OBJECT.transform.localPosition.x, previewRobotParts[robotPartIndex].GAME_OBJECT.transform.localPosition.y - .5f, previewRobotParts[robotPartIndex].GAME_OBJECT.transform.localPosition.z);
                            }
                            else if (partBeingEquipt.getShape() != Shape.SHAPES.HEMISPHERE && previewRobotParts[robotPartIndex].GAME_OBJECT.GetComponent <MeshFilter>().mesh.name.Contains("Sphere"))
                            {
                                previewRobotParts[robotPartIndex].GAME_OBJECT.transform.localPosition = new Vector3(previewRobotParts[robotPartIndex].GAME_OBJECT.transform.localPosition.x, previewRobotParts[robotPartIndex].GAME_OBJECT.transform.localPosition.y + .5f, previewRobotParts[robotPartIndex].GAME_OBJECT.transform.localPosition.z);
                            }
                            previewRobotParts[robotPartIndex].changeTextureAndShape(partBeingPreviewed.getImage().getTexture(), MESHES[(int)partBeingPreviewed.getShape()], partBeingPreviewed.getShape());
                        }
                        break;
                    }
                    if (robotPartIndex == robotParts.Count - 1)
                    {
                        robotParts.Add(partBeingEquipt);
                    }
                }
                robot = new Robot("", true, robot.isHuman(), robotParts.ToArray());
                break;

            default:
                break;
            }
            CONFIGURATION_CARD.setMode(mode, partBeingPreviewed, partBeingEquipt, robotStats);
        }
    }