当前位置: 首页>>代码示例>>C#>>正文


C# Mission.AddTeam方法代码示例

本文整理汇总了C#中Mission.AddTeam方法的典型用法代码示例。如果您正苦于以下问题:C# Mission.AddTeam方法的具体用法?C# Mission.AddTeam怎么用?C# Mission.AddTeam使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mission的用法示例。


在下文中一共展示了Mission.AddTeam方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Start

    public void Start()
    {
        if (positions == null) {
          positions = new Vector2[StarCount];

          float minX = Mathf.Min(TopLeft.x, TopRight.x, BottomLeft.x, BottomRight.x);
          float maxX = Mathf.Max(TopLeft.x, TopRight.x, BottomLeft.x, BottomRight.x);
          float minZ = Mathf.Min(TopLeft.y, TopRight.y, BottomLeft.y, BottomRight.y);
          float maxZ = Mathf.Max(TopLeft.y, TopRight.y, BottomLeft.y, BottomRight.y);

          for (int i = 0; i < StarCount; i++) {
        // Randomly generate coordinates.
        float x = 0, y = 0;

        CheckBounds:

        x = minX + Random.value * (maxX - minX);
        y = minZ + Random.value * (maxZ - minZ);

        // Check top bounds.
        float m = (TopRight.x - TopLeft.x) / (TopRight.y - TopLeft.y);
        float b = TopLeft.x + (y - TopLeft.y) * m;
        if (x > b) {
          goto CheckBounds;
        }

        // Check bottom bounds.
        m = (BottomRight.x - BottomLeft.x) / (BottomRight.y - BottomLeft.y);
        b = BottomLeft.x + (y - BottomLeft.y) * m;
        if (x < b) {
          goto CheckBounds;
        }

        // Check left bounds.
        m = (TopLeft.x - BottomLeft.x) / (TopLeft.y - BottomLeft.y);
        b = (x - BottomLeft.x) / m + BottomLeft.y;
        if (y > b) {
          goto CheckBounds;
        }

        // Check right bounds.
        m = (TopRight.x - BottomRight.x) / (TopRight.y - BottomRight.y);
        b = (x - BottomRight.x) / m + BottomRight.y;
        if (y < b) {
          goto CheckBounds;
        }

        // Check bounds with other stars.
        Vector2 test = new Vector2(x, y);
        for (int j = 0; j < i; j++) {
          Vector2 position = positions[j];
          if (Vector2.Distance(test, position) < 50) {
            goto CheckBounds;
          }
        }

        positions[i] = new Vector2(x, y);
          }
        }

        int which = Random.Range(1, positions.Length - 1);
        for (int i = 0; i < positions.Length; i++) {
          Vector3 pos = new Vector3(positions[i].x, 0.01f, positions[i].y);
          Quaternion rot = new Quaternion(0, 0, 0, 0);
          GameObject star = Instantiate(StarPrefab, pos, rot) as GameObject;

          Star script = star.GetComponent<Star>();
          GameObject marker = Instantiate(script.Marker, pos, rot) as GameObject;
          marker.transform.parent = star.transform;

          if (i == which) {
        Mission mission = new Mission(CursorPrefab);
        foreach (GameObject prefab in CombatTeamPrefabs) {
          mission.AddTeam(prefab, Random.Range(15, 20), new Vector3(Random.Range(-100, 100), 0, Random.Range(-100, 100)));
        }

        marker.GetComponent<StarMarker>().Mission = mission;
          }

          script.Marker = marker;
        }

        Instantiate(PlayerPrefab);
    }
开发者ID:kyranitar,项目名称:gaf,代码行数:84,代码来源:StarGeneration.cs


注:本文中的Mission.AddTeam方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。