Esempio n. 1
0
 private void OnEnable()
 {
     unit                      = base.target as AStarUnit;
     unitSize                  = serializedObject.FindProperty("unitSize");
     target                    = serializedObject.FindProperty("target");
     targetFootOffset          = serializedObject.FindProperty("targetFootOffset");
     targetFollowStartDistance = serializedObject.FindProperty("targetFollowStartDistance");
     footOffset                = serializedObject.FindProperty("footOffset");
     fixedOffset               = serializedObject.FindProperty("fixedOffset");
     moveMode                  = serializedObject.FindProperty("moveMode");
     rigidbody                 = serializedObject.FindProperty("rigidbody");
     rigidbody2D               = serializedObject.FindProperty("rigidbody2D");
     controller                = serializedObject.FindProperty("controller");
     turnSpeed                 = serializedObject.FindProperty("turnSpeed");
     moveSpeed                 = serializedObject.FindProperty("moveSpeed");
     slopeLimit                = serializedObject.FindProperty("slopeLimit");
     stopDistance              = serializedObject.FindProperty("stopDistance");
     repathRate                = serializedObject.FindProperty("repathRate");
     drawGizmos                = serializedObject.FindProperty("drawGizmos");
     lineColor                 = serializedObject.FindProperty("lineColor");
     pointColor                = serializedObject.FindProperty("pointColor");
     pathRenderer              = serializedObject.FindProperty("pathRenderer");
     animator                  = serializedObject.FindProperty("animator");
     animaHorizontal           = serializedObject.FindProperty("animaHorizontal");
     animaVertical             = serializedObject.FindProperty("animaVertical");
     animaMagnitude            = serializedObject.FindProperty("animaMagnitude");
     manager                   = FindObjectOfType <AStarManager>();
 }
Esempio n. 2
0
	void Awake()
	{
		this.pathList = new List<GameObject> ();
		this.aStarUtils = new AStarUtils (this.cols, this.rows);

		// cols
		for(int i = 0; i < this.cols; i++)
		{
			// rows
			for(int j = 0; j < this.rows; j++)
			{
				AStarUnit aStarUnit = new AStarUnit();

				if(i != 0 && j != 0 && Random.Range(1, 10) <= 3)
				{
					aStarUnit.isPassable = false;

					GameObject gameObject = (GameObject)Instantiate(cubeObject);
					if(gameObject != null)
					{
						gameObject.transform.localPosition = new Vector3(i - this.cols * 0.5f + 0.5f, 0f, j - this.cols * 0.5f + 0.5f);
					}

				}else{
					aStarUnit.isPassable = true;
				}

				this.aStarUtils.GetNode(i,j).AddUnit(aStarUnit);
			}
		}
	}
Esempio n. 3
0
    void Awake()
    {
        this.pathList   = new List <GameObject> ();
        this.aStarUtils = new AStarUtils(this.cols, this.rows);

        // cols
        for (int i = 0; i < this.cols; i++)
        {
            // rows
            for (int j = 0; j < this.rows; j++)
            {
                AStarUnit aStarUnit = new AStarUnit();

                if (i != 0 && j != 0 && Random.Range(1, 10) <= 3)
                {
                    aStarUnit.isPassable = false;

                    GameObject gameObject = (GameObject)Instantiate(cubeObject);
                    if (gameObject != null)
                    {
                        gameObject.transform.localPosition = new Vector3(i - this.cols * 0.5f + 0.5f, 0f, j - this.cols * 0.5f + 0.5f);
                    }
                }
                else
                {
                    aStarUnit.isPassable = true;
                }

                this.aStarUtils.GetNode(i, j).AddUnit(aStarUnit);
            }
        }
    }
Esempio n. 4
0
    void Awake()
    {
        _aStarUtils = new AStarUtils (_cols, _rows);
        _moveableObj = Instantiate(pathObject);

        // cols
        for(int i = 0; i < _cols; i++)
        {
            // rows
            for(int j = 0; j < _rows; j++)
            {
                AStarUnit aStarUnit = new AStarUnit();

                if(i != 0 && j != 0 && Random.Range(1, 10) <= 3)
                {
                    aStarUnit.isPassable = false;

                    GameObject gameObject = Instantiate(cubeObject);
                    if(gameObject != null)
                    {
                        gameObject.transform.localPosition = new Vector3(i - this._cols * 0.5f + 0.5f, 0f, j - this._cols * 0.5f + 0.5f);
                    }

                }else{
                    aStarUnit.isPassable = true;
                }

                _aStarUtils.GetNode(i,j).AddUnit(aStarUnit);
            }
        }
    }
Esempio n. 5
0
    void Awake()
    {
        Application.targetFrameRate = 600;
        this.pathList   = new List <GameObject> ();
        this.aStarUtils = new AStarUtils(this.cols, this.rows);
        Debug.Log("start");
        // cols
        for (int i = 0; i < this.cols; i++)
        {
            // rows
            for (int j = 0; j < this.rows; j++)
            {
                AStarUnit aStarUnit = new AStarUnit();

                if (i != 0 && j != 0 && Random.Range(1, 10) <= 1)
                {
                    aStarUnit.isPassable = false;

                    GameObject gameObject = (GameObject)Instantiate(cubeObject);
                    if (gameObject != null)
                    {
                        var x = i - this.cols * 0.5f + 0.5f;
                        var y = 0f;
                        var z = j - this.rows * 0.5f + 0.5f;
                        //Debug.Log(string.Format("x: {0}, y: {1}, z: {2}", x, y, z));
                        gameObject.transform.localPosition = new Vector3(x, y, z);
                    }
                }
                else
                {
                    aStarUnit.isPassable = true;
                }

                this.aStarUtils.GetNode(i, j).AddUnit(aStarUnit);
            }
        }
        // 设置底板格子数量
        var mt = sceneGrid.GetComponent <Renderer>().material;

        Debug.Log(mt);
        if (mt != null)
        {
            //Debug.Log("setMaterial");
            mt.SetTextureScale("_MainTex", new Vector2(cols, rows));
        }

        // 设置底板宽度
        sceneGrid.transform.localScale = new Vector3(cols / unit, 1, rows / unit);
    }