Esempio n. 1
0
    protected override void Think()
    {
        IaManager im = IaManager.Instance;

        int idEnemiesTeam            = (IdTeam + 1) % 2;
        int shortestDistanceToTarget = 1000000;

        destination = im.IaTeam(idEnemiesTeam)[0].Pos;
        target      = im.IaTeam(idEnemiesTeam)[0];
        shortestDistanceToTarget = GridData.Distance(Pos, destination);

        for (int i = 1; i < im.IaTeam(idEnemiesTeam).Count; i++)
        {
            if (im.IaTeam(idEnemiesTeam)[i].IsAlive)
            {
                int distanceTemp = GridData.Distance(Pos, im.IaTeam(idEnemiesTeam)[i].Pos);

                if (distanceTemp <= shortestDistanceToTarget)
                {
                    shortestDistanceToTarget = distanceTemp;
                    destination = im.IaTeam(idEnemiesTeam)[i].Pos;
                    target      = im.IaTeam(idEnemiesTeam)[i];
                }
            }
        }
        destination = Dijkstra(Pos, destination, MovePoints);
    }
Esempio n. 2
0
    protected override void Think()
    {
        IaManager im = IaManager.Instance;

        int idEnemiesTeam            = (IdTeam + 1) % 2;
        int shortestDistanceToTarget = 1000000;

        destination = im.IaTeam(idEnemiesTeam)[0].Pos;
        target      = im.IaTeam(idEnemiesTeam)[0];
        shortestDistanceToTarget = GridData.Distance(Pos, destination);

        for (int i = 1; i < im.IaTeam(idEnemiesTeam).Count; i++)
        {
            if (im.IaTeam(idEnemiesTeam)[i].IsAlive)
            {
                int distanceTemp = GridData.Distance(Pos, im.IaTeam(idEnemiesTeam)[i].Pos);

                if (distanceTemp <= shortestDistanceToTarget)
                {
                    shortestDistanceToTarget = distanceTemp;
                    destination = im.IaTeam(idEnemiesTeam)[i].Pos;
                    target      = im.IaTeam(idEnemiesTeam)[i];
                }
            }
        }
        // pour rester a distance de la target
        if (GridData.Distance(Pos, destination) <= 4)
        {
            List <GridData.PosGrid> pos = new List <GridData.PosGrid>();
            for (int i = Pos.column - 3; i < Pos.column + 3; i++)
            {
                for (int j = Pos.line - 3; j < Pos.line + 3; j++)
                {
                    GridData.PosGrid posGrid;
                    posGrid.column = i;
                    posGrid.line   = j;
                    if (GridData.Distance(destination, posGrid) == 3 && GridManager.Instance.IsValidPos(posGrid.column, posGrid.line))
                    {
                        pos.Add(posGrid);
                    }
                }
            }
            destination = pos[0];
            int distance = GridData.Distance(Pos, destination);
            for (int i = 1; i < pos.Count; i++)
            {
                if (GridData.Distance(Pos, pos[i]) < distance)
                {
                    destination = pos[i];
                    distance    = GridData.Distance(Pos, pos[i]);
                }
            }
        }
        else
        {
            destination = Dijkstra(Pos, destination, MovePoints);
        }
    }
        public void Init()
        {
            iaMgr = new LeaseManager();

            InitPoolMap();

            InitStaticBindings();

            StartReaper();
        }
Esempio n. 4
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(this);
     }
 }
Esempio n. 5
0
    IEnumerator Start()
    {
        yield return(null);

        im = IaManager.Instance;
        gm = GridManager.Instance;
        //map visuel
        for (int i = 0; i < gm.NbColumns; i++)
        {
            for (int j = 0; j < gm.NbLines; j++)
            {
                if (gm.GetCaseState(i, j) == GridData.STATE.EMPTY)
                {
                    Instantiate(prefabCase, new Vector3(i * sizeCase, j * sizeCase), Quaternion.identity);
                }
                else if (gm.GetCaseState(i, j) == GridData.STATE.BUSY)
                {
                    Instantiate(prefabWall, new Vector3(i * sizeCase, j * sizeCase), Quaternion.identity);
                }
                else
                {
                    Instantiate(prefabCase, new Vector3(i * sizeCase, j * sizeCase), Quaternion.identity);
                }
            }
        }
        iasOne = new List <GameObject>();
        iasTwo = new List <GameObject>();

        // ia equipe 1
        foreach (Ia ia in im.IaTeamOne)
        {
            if (ia.Behavior == Ia.BEHAVIOR.MELEE)
            {
                iasOne.Add(Instantiate(prefabMeleeTeamOne, new Vector2(ia.Pos.column, ia.Pos.line) * sizeCase, Quaternion.identity));
            }
            else if (ia.Behavior == Ia.BEHAVIOR.DISTANCE)
            {
                iasOne.Add(Instantiate(prefabDistanceTeamOne, new Vector2(ia.Pos.column, ia.Pos.line) * sizeCase, Quaternion.identity));
            }
            else
            {
                iasOne.Add(Instantiate(prefabIaOne, new Vector2(ia.Pos.column, ia.Pos.line) * sizeCase, Quaternion.identity));
            }
        }
        //ia equipe 2
        foreach (Ia ia in im.IaTeamTwo)
        {
            if (ia.Behavior == Ia.BEHAVIOR.MELEE)
            {
                iasTwo.Add(Instantiate(prefabMeleeTeamTwo, new Vector2(ia.Pos.column, ia.Pos.line) * sizeCase, Quaternion.identity));
            }
            else if (ia.Behavior == Ia.BEHAVIOR.DISTANCE)
            {
                iasTwo.Add(Instantiate(prefabDistanceTeamTwo, new Vector2(ia.Pos.column, ia.Pos.line) * sizeCase, Quaternion.identity));
            }
            else
            {
                iasTwo.Add(Instantiate(prefabIaTwo, new Vector2(ia.Pos.column, ia.Pos.line) * sizeCase, Quaternion.identity));
            }
        }
    }
 public void SetIaMgr(IaManager iaMgr)
 {
     this.iaMgr = iaMgr;
 }