예제 #1
0
파일: Ennemi.cs 프로젝트: antoinetb12/Jeu
    public void joue(Case[,] grid, int dimX, int dimY)
    {
        this.grid = grid;
        List <Case> cheminChoisi = null;
        List <Case> chemin;

        foreach (Joueur j in joueurs)
        {
            Debug.Log("joueur " + j);
            if (j.pdv > 0)
            {
                if (algo == null)
                {
                    algo = GetComponent <AlgoDeplacement>();
                }
                chemin = algo.FindPath(transform.position, j.transform.position, grid, dimX, dimY);
            }
            else
            {
                chemin = null;
            }
            if (cheminChoisi == null)
            {
                cheminChoisi = chemin;
                jChoisi      = j;
            }
            else if (chemin != null)
            {
                if (cheminChoisi.Count - 1 <= getPm() && chemin.Count - 1 <= getPm())
                {
                    if (jChoisi.pdv > j.pdv)
                    {
                        cheminChoisi = chemin;
                        jChoisi      = j;
                    }
                }
                else if (cheminChoisi.Count > chemin.Count)
                {
                    cheminChoisi = chemin;
                    jChoisi      = j;
                }
            }
        }


        cheminChoisi.RemoveAt(cheminChoisi.Count - 1);
        while (cheminChoisi.Count > getPm())
        {
            cheminChoisi.RemoveAt(cheminChoisi.Count - 1);
        }

        StartCoroutine(smoothMovement(cheminChoisi));
    }
예제 #2
0
파일: Ennemi.cs 프로젝트: antoinetb12/Jeu
 //TODO instancier chaque sort
 // Start is called before the first frame update
 void Start()
 {
     if (algo == null)
     {
         algo = GetComponent <AlgoDeplacement>();
     }
     foreach (GameObject g in sortsG)
     {
         g.GetComponent <Sort>().Detenteur = this;
         Sorts.Add(g.GetComponent <Sort>());
     }
 }