Ejemplo n.º 1
0
    public void SetPlayerTool(GameTool gameTool, Loading gameToolLoading)
    {
        if (gameTool.GetToolsPlayerId() == 1)
        {
            if (Tool1.transform.childCount == 0)
            {
                GameObject tool1 = GameObject.Instantiate(game.GetToolByID(gameTool.GetToolID()), Tool1.transform.position, Quaternion.identity);
                tool1.transform.parent        = Tool1.transform;
                tool1.transform.position      = Tool1.transform.position;
                tool1.transform.localRotation = Tool1.transform.localRotation;
                tool1.transform.localScale    = new Vector3(30f, 30f, 30f);
            }
            PlayerTool1.gameObject.transform.Find("ToolName").gameObject.GetComponent <TMPro.TMP_Text>().text = "Name : " + gameTool.GetName();
            PlayerTool1.gameObject.transform.Find("Rank").gameObject.GetComponent <TMPro.TMP_Text>().text     = "Rank : " + gameTool.GetRank();
            PlayerTool1.gameObject.transform.Find("Army").gameObject.GetComponent <TMPro.TMP_Text>().text     = "Army : " + gameTool.GetArmy();


            if (gameToolLoading != null)
            {
                PlayerTool1.gameObject.transform.Find("Load").gameObject.GetComponent <TMPro.TMP_Text>().text = "Load Capability : " + gameToolLoading.GetLoadCapability();
                List <GameTool> loaded = gameToolLoading.GetLoadedToolsList();
                for (int i = 1; i <= loaded.Count; i++)
                {
                    PlayerTool1.gameObject.transform.Find("LoadedTool" + i).gameObject.GetComponent <TMPro.TMP_Text>().text = loaded[i - 1].GetName();
                    PlayerTool1.gameObject.transform.Find("LoadedTool" + i).GetComponent <LoadedToolsText>().SetLoaded(loaded[i - 1]);
                    PlayerTool1.gameObject.transform.Find("LoadedTool" + i).GetComponent <LoadedToolsText>().SetLoader(gameTool);
                }
            }
        }
        else if (gameTool.GetToolsPlayerId() == 2)
        {
            if (Tool2.transform.childCount == 0)
            {
                GameObject tool2 = GameObject.Instantiate(game.GetToolByID(gameTool.GetToolID()), Tool2.transform.position, Quaternion.identity);
                tool2.transform.parent        = Tool2.transform;
                tool2.transform.position      = Tool2.transform.position;
                tool2.transform.localRotation = Tool2.transform.localRotation;
                tool2.transform.localScale    = new Vector3(30f, 30f, 30f);
                // tool2.transform.trv
            }
            PlayerTool2.gameObject.transform.Find("ToolName").gameObject.GetComponent <TMPro.TMP_Text>().text = "Name : " + gameTool.GetName();
            PlayerTool2.gameObject.transform.Find("Rank").gameObject.GetComponent <TMPro.TMP_Text>().text     = "Rank : " + gameTool.GetRank();
            PlayerTool2.gameObject.transform.Find("Army").gameObject.GetComponent <TMPro.TMP_Text>().text     = "Army : " + gameTool.GetArmy();

            if (gameToolLoading != null)
            {
                PlayerTool2.gameObject.transform.Find("Load").gameObject.GetComponent <TMPro.TMP_Text>().text = "Load Capability : " + gameToolLoading.GetLoadCapability();
                List <GameTool> loaded = gameToolLoading.GetLoadedToolsList();
                for (int i = 1; i <= loaded.Count; i++)
                {
                    PlayerTool2.gameObject.transform.Find("LoadedTool" + i).gameObject.GetComponent <TMPro.TMP_Text>().text = loaded[i - 1].GetName();
                    PlayerTool2.gameObject.transform.Find("LoadedTool" + i).GetComponent <LoadedToolsText>().SetLoaded(loaded[i - 1]);
                    PlayerTool2.gameObject.transform.Find("LoadedTool" + i).GetComponent <LoadedToolsText>().SetLoader(gameTool);
                }
            }
        }
    }