コード例 #1
0
ファイル: PathEditor.cs プロジェクト: mattbrand/campconquer
    /*
     * public void AddPath()
     * {
     *  List<float> x = new List<float>();
     *  List<float> y = new List<float>();
     *  PathDot firstDot = null;
     *  float newX;
     *  float newY;
     *  int i;
     *
     *  _currentDots.RemoveAt(0);
     *
     *  if (_color == TeamColor.RED)
     *  {
     *      while (_currentDots.Count > 1)
     *      {
     *          for (i = 0; i < _currentDots.Count; i++)
     *          {
     *              if (firstDot == null || _currentDots[i].transform.position.x < firstDot.transform.position.x)
     *              {
     *                  firstDot = _currentDots[i];
     *              }
     *          }
     *          newX = Utilities.RoundToDecimals(firstDot.transform.position.x, 1);
     *          newY = Utilities.RoundToDecimals(firstDot.transform.position.y, 1);
     *          x.Add(newX);
     *          y.Add(newY);
     *          _currentDots.Remove(firstDot);
     *          firstDot = null;
     *      }
     *      x.Add(Utilities.RoundToDecimals(_blueFlag.Position.x, 1));
     *      y.Add(Utilities.RoundToDecimals(_blueFlag.Position.y, 1));
     *  }
     *  else
     *  {
     *      while (_currentDots.Count > 1)
     *      {
     *          for (i = 0; i < _currentDots.Count; i++)
     *          {
     *              if (firstDot == null || _currentDots[i].transform.position.x > firstDot.transform.position.x)
     *              {
     *                  firstDot = _currentDots[i];
     *              }
     *          }
     *          x.Add(Utilities.RoundToDecimals(firstDot.transform.position.x, 1));
     *          y.Add(Utilities.RoundToDecimals(firstDot.transform.position.y, 1));
     *          _currentDots.Remove(firstDot);
     *          firstDot = null;
     *      }
     *      x.Add(Utilities.RoundToDecimals(_redFlag.Position.x, 1));
     *      y.Add(Utilities.RoundToDecimals(_redFlag.Position.y, 1));
     *  }
     * }
     */

    void CreateDot(Vector2 pos)
    {
        PathDot newDot = (PathDot)Instantiate(RedDotPrefab, pos, Quaternion.identity);

        _currentDots.Add(newDot);
        newDot.SetIndex(_currentDots.Count - 1);
    }
コード例 #2
0
ファイル: PathEditor.cs プロジェクト: mattbrand/campconquer
 void OnMouseUp()
 {
     if (!ClickingDot)
     {
         Vector2 newPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
         PathDot dot    = (PathDot)Instantiate(RedDotPrefab, new Vector3(newPos.x, newPos.y, 0.0f), Quaternion.identity);
         dot.Placed = true;
         _currentDots.Add(dot);
         dot.SetIndex(_currentDots.Count - 1);
         dot = null;
     }
 }