Exemplo n.º 1
0
 public void UnLoad(GameTool gameTool, Tile unLoadTo = null)
 {
     if (gameTool.GetName().Contains("Boat"))
     {
         foreach (Transform child in gameTool.gameObject.transform.parent)
         {
             child.gameObject.transform.localScale = Vector3.one * 1.5f;
         }
         gameTool.gameObject.transform.localScale = Vector3.one * 0.5f;
     }
     else
     {
         foreach (Transform child in gameTool.gameObject.transform.parent)
         {
             child.gameObject.transform.localScale = Vector3.one * 1.5f;
         }
         gameTool.gameObject.transform.localScale = Vector3.one * 1.4f;
     }
     //gameTool.gameObject.transform.parent.parent = null;
     loadedGameTools.Remove(gameTool);
     if (unLoadTo != null)
     {
         gameTool.gameObject.transform.parent.position = unLoadTo.GetPosition();
         unLoadTo.SetCurrentStepingGameTool(gameTool);
     }
 }
Exemplo n.º 2
0
    public void Load(GameTool gameTool, Tile loadFrom = null)
    {
        Debug.Log(gameTool.transform.position);
        if (gameTool.GetName() != "Flag")
        {
            loadedGameTools.Add(gameTool);

            if (loadFrom != null)
            {
                loadFrom.SetCurrentStepingGameTool(null);
            }
            Debug.Log(gameTool.transform.position);
            foreach (Transform child in gameTool.gameObject.transform.parent)
            {
                child.gameObject.transform.localScale = Vector3.zero;
            }
            //gameTool.gameObject.transform.parent.position = transform.parent.position;
            //gameTool.gameObject.transform.parent.parent = transform.parent;
            gameTool.GetComponentInParent <Loading>().SetLoader(GetComponentInParent <GameTool>());
            Debug.Log(gameTool.transform.position);
            game.PassTurn();
        }
        else
        {
            loadedGameTools.Add(gameTool);
            if (loadFrom != null)
            {
                loadFrom.SetCurrentStepingGameTool(null);
            }

            foreach (Transform child in gameTool.gameObject.transform.parent)
            {
                child.gameObject.transform.localScale = Vector3.zero;
            }
            //gameTool.gameObject.transform.parent.position = transform.parent.position;
            //gameTool.gameObject.transform.parent.parent = transform.parent;
            HasFlag = true;
        }
        Debug.Log(gameTool.transform.position);
    }
Exemplo n.º 3
0
    public bool CanBeLoadTo(GameTool gameTool)
    {
        if (gameTool.GetName() == "Flag")
        {
            return(false);
        }
        if (!canBeLoaded || gameTool.transform.parent.tag == "Soldier")

        {
            return(false);
        }
        else
        {
            if (loadedGameTools.Count + 1 + gameTool.GetComponentInParent <Loading>().loadedGameTools.Count <= gameTool.GetComponentInParent <Loading>().loadCapability)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
    }
Exemplo n.º 4
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);
                }
            }
        }
    }