コード例 #1
0
    public void OnPointerDown(PointerEventData eventData)
    {
        GameObject go;
        Transform  tr;

        if (CS_TurnOverPanel.turn == FinalVar.RED)
        {
            go = Resources.Load(characterName + "Red", typeof(GameObject)) as GameObject;
            tr = GameObject.Find("RedArmy").transform;
        }
        else
        {
            go = Resources.Load(characterName + "Blue", typeof(GameObject)) as GameObject;
            tr = GameObject.Find("BlueArmy").transform;
        }
        GameObject gObject = Instantiate(go) as GameObject;

        gObject.transform.position = new Vector3(0, -2, 0);
        gObject.GetComponent <CharacterScript>().localPosition = (--no).ToString();
        gObject.transform.SetParent(tr);
        if (CS_TurnOverPanel.turn == FinalVar.RED)
        {
            CS_ArmyManager.AddRedCharacter(no.ToString(), gObject.GetComponent <CharacterScript>());
        }
        else
        {
            CS_ArmyManager.AddBlueCharacter(no.ToString(), gObject.GetComponent <CharacterScript>());
        }
    }
コード例 #2
0
    // Use this for initialization
    void Start()
    {
        GameObject go = Resources.Load("PreMap", typeof(GameObject)) as GameObject;

        for (int i = 0; i < sizeX; i++)
        {
            for (int j = 0; j < sizeY; j++)
            {
                GameObject preMap = Instantiate(go) as GameObject;
                preMap.transform.SetParent(GameObject.Find("Map").transform, false);
                preMap.transform.Translate(new Vector3(i, 0, j));
                preMap.transform.name = i.ToString() + "," + j.ToString();
                preMap.GetComponent <MapScript>().type = cose[i, j];
            }
        }//加载UI地图

        GameObject go2     = Resources.Load("KingOfRed", typeof(GameObject)) as GameObject;
        GameObject preMap2 = Instantiate(go2) as GameObject;

        preMap2.transform.position = GameObject.Find(kingOfRed).transform.position;
        preMap2.transform.name     = "KingOfRed";
        preMap2.GetComponent <CharacterScript>().localPosition = kingOfRed;
        CS_ArmyManager.AddRedCharacter(kingOfRed, preMap2.GetComponent <CharacterScript>());
        //characters.Add(kingOfRed, preMap2.GetComponent<CharacterScript>());

        GameObject go3     = Resources.Load("KingOfBlue", typeof(GameObject)) as GameObject;
        GameObject preMap3 = Instantiate(go3) as GameObject;

        preMap3.transform.position = GameObject.Find(kingOfBlue).transform.position;
        preMap3.transform.name     = "KingOfBlue";
        preMap3.GetComponent <CharacterScript>().localPosition = kingOfBlue;
        CS_ArmyManager.AddBlueCharacter(kingOfBlue, preMap3.GetComponent <CharacterScript>());
        //characters.Add(kingOfBlue, preMap3.GetComponent<CharacterScript>());

        buildings.Add("1,4", GameObject.Find("tower"));
        buildings.Add("14,5", GameObject.Find("tower (1)"));
        buildings.Add("4,3", GameObject.Find("village"));
        buildings.Add("11,6", GameObject.Find("village (1)"));
    }