Beispiel #1
0
    /// <summary>
    /// 创建队伍
    /// </summary>
    private Team CreateTeam()
    {
        if (Field == null)
        {
            return(null);
        }

        Formation f = CreateForamtion(_Formations [_FormationID].Value);

        if (f == null)
        {
            return(null);
        }

        GameObject go   = new GameObject();
        Team       team = go.AddComponent <Team> ();

        team.name = _TeamID.ToString();
        team.Formation.Copy(f);
        UILayer.AddChild(Field, team);

        for (int i = 0; i < f.Count; i++)
        {
            GameObject child = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            Unit       unit  = child.AddComponent <Unit> ();
            unit.Initialize();
            child.transform.position = f.GetPoint(i);
            UILayer.AddChild(team, unit);
        }

        return(team);
    }