Пример #1
0
 // Update is called once per frame
 void Update()
 {
     endGridPosition = new gridPosition(17, (int)fetchGridPosition().y);
     if (!isMoving)
     {
         StartCoroutine(move());
     }
     GameOver();
 }
Пример #2
0
    // Use this for initialization
    void Start()
    {
        myColor = getRandomColor();

        startGridPosition = new gridPosition(spawnx, spawny);
        initializePosition(spawnx, spawny);
        InitPath();

        StartCoroutine(ChangeState());
    }
Пример #3
0
    void Start()
    {
        myColor = getRandomColor();
        // Straight line pathfinding
        int startPos = UnityEngine.Random.Range(0, Game.gridHeight - 1);
        int endPos   = (int)fetchGridPosition().y;

        startGridPosition = new gridPosition(0, startPos);
        endGridPosition   = new gridPosition(17, startPos);
        initializePosition();
        MySolver <MyPathNode, System.Object> aStar = new MySolver <MyPathNode, System.Object>(Game.grid);
        IEnumerable <MyPathNode>             path  = aStar.Search(new Vector2(startGridPosition.x, startGridPosition.y), new Vector2(endGridPosition.x, endGridPosition.y), null);

        updatePath();
        this.GetComponent <Renderer>().material.color = myColor;
    }
Пример #4
0
    // Use this for initialization
    void Start()
    {
        startGridPosition = new gridPosition(0, UnityEngine.Random.Range(0, Game.gridHeight - 1));
        endGridPosition   = new gridPosition(Game.gridWidth - 1, UnityEngine.Random.Range(0, Game.gridHeight - 1));
        initializePosition();


        MySolver <MyPathNode, System.Object> aStar = new MySolver <MyPathNode, System.Object>(Game.grid);
        IEnumerable <MyPathNode>             path  = aStar.Search(new Vector2(startGridPosition.x, startGridPosition.y), new Vector2(endGridPosition.x, endGridPosition.y), null);

        foreach (GameObject g in GameObject.FindGameObjectsWithTag("GridBox"))
        {
            g.GetComponent <Renderer>().material.color = Color.white;
        }


        findUpdatedPath(currentGridPosition.x, currentGridPosition.y);

        this.GetComponent <Renderer>().material.color = myColor;
    }
Пример #5
0
    // Update is called once per frame
    void Update()
    {
        endGridPosition = new gridPosition(Game.targetx, Game.targety);
        quadrant        = xpoint > 0 ? (ypoint > 0 ? 1 : 4) : (ypoint > 0 ? 2 : 3);

        this.gameObject.transform.GetComponentInChildren <Transform>().position = this.gameObject.transform.position;
        if (!isTracing)
        {
            //  transform.position += moveVelocity * speed * Time.deltaTime;
        }
        else if (isMoving)
        {
            isMoving  = false;
            isTracing = true;

            initializePosition(startx, starty);
            updatePath();
            // StopAllCoroutines();
            //StartCoroutine(move());
        }
    }
Пример #6
0
    void InitPath()
    {
        endGridPosition   = new gridPosition(Game.targetx, Game.targety);
        startGridPosition = new gridPosition(startx, starty);



        MySolver <MyPathNode, System.Object> aStar = new MySolver <MyPathNode, System.Object>(Game.grid);
        IEnumerable <MyPathNode>             path  = aStar.Search(new Vector2(startGridPosition.x, startGridPosition.y), new Vector2(endGridPosition.x, endGridPosition.y), null);



        //foreach (GameObject g in GameObject.FindGameObjectsWithTag("GridBox"))
        //{
        //    g.GetComponent<Renderer>().material.color = Color.white;
        //}


        updatePath();

        this.GetComponent <Renderer>().material.color = myColor;
    }