コード例 #1
0
 private void OnMouseDown()
 {
     if (Loaded != null && Loaded.GetToolsPlayerId() == game.GetTurnPlayerID())
     {
         if (Loader.GetComponentInParent <Loading>().GetReadyToUnloadTool() == null)
         {
             Loader.GetComponentInParent <Loading>().SetReadyToUnloadTool(Loader, Loaded);
         }
         else
         {
             if (Loader == game.GetLoader())
             {
                 if (Loaded.GetComponentInParent <Loading>().CanBeLoadTo(Loader.GetComponentInParent <Loading>().GetReadyToUnloadTool()))
                 {
                     Loader.GetComponentInParent <Loading>().LoadToolOnReadyToUnloadTool(Loaded);
                     game.SetClickedLoadedTool(Loader, Loader.GetComponentInParent <Loading>().GetReadyToUnloadTool());
                 }
             }
             else
             {
                 Loader.GetComponentInParent <Loading>().SetReadyToUnloadTool(Loader, Loaded);
             }
         }
     }
 }
コード例 #2
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);
                }
            }
        }
    }
コード例 #3
0
    private void OnMouseOver()
    {
        if (canWalkTo)
        {
            Material[] transparent = { regMaterial, transparent2 };
            GetComponent <MeshRenderer>().materials = transparent;
        }
        else if (canBeClicked)
        {
            Material[] transparent = { regMaterial, transparent2 };
            GetComponent <MeshRenderer>().materials = transparent;
            if (currentStepingGameTool != null && !gameToolResized)
            {
                currentStepingGameTool.gameObject.transform.localScale += currentStepingGameTool.GetResizeFactor();
                gameToolResized = true;
            }
        }

        if (game.GetClickedTile() == null && currentStepingGameTool != null || currentStepingGameTool != null && currentStepingGameTool.GetToolsPlayerId() != game.GetTurnPlayerID())
        {
            game.SetToolUI(currentStepingGameTool, currentStepingGameTool.GetComponentInParent <Loading>(), true);
        }
    }