Ejemplo n.º 1
0
 /// <summary>
 /// Tuer la brigade
 /// </summary>
 /// <param name="brig">Brigade.</param>
 public void killBrig(BrigadeController brig)
 {
     int i=0;
     while (Brigs[i]!=brig)
         i++;
     outBrig(i);
 }
Ejemplo n.º 2
0
    void OnTriggerExit2D(Collider2D other)
    {
        if (other is CircleCollider2D && other.CompareTag("Brigade"))
        {
            BrigadeController brigade = other.GetComponent <BrigadeController>();

            brigade.underObjectOut();
        }
    }
Ejemplo n.º 3
0
    Vector3 target; //destination

    #endregion Fields

    #region Methods

    /// <summary>
    /// Detection d'une brigade
    /// </summary>
    /// <param name="brig">Brigade.</param>
    public void detectBrig(BrigadeController brig)
    {
        brigChase=brig;
            destChase=brigChase.transform.position;
            isChasing=true;
            goTo(destChase);

            addDetection(fear);
    }
Ejemplo n.º 4
0
    /// <summary>
    /// Detection d'une brigade
    /// </summary>
    /// <param name="brig">Brigade.</param>
    public void detectBrig(BrigadeController brig)
    {
        brigChase = brig;
        destChase = brigChase.transform.position;
        isChasing = true;
        goTo(destChase);

        addDetection(fear);
    }
Ejemplo n.º 5
0
    /// <summary>
    /// Tuer la brigade
    /// </summary>
    /// <param name="brig">Brigade.</param>
    public void killBrig(BrigadeController brig)
    {
        int i = 0;

        while (Brigs[i] != brig)
        {
            i++;
        }
        outBrig(i);
    }
Ejemplo n.º 6
0
    /// <summary>
    /// Sortir la brigade
    /// </summary>
    /// <param name="brig">Brigade.</param>
    void sortirBrig(BrigadeController brig)
    {
        Vector3 _pos = new Vector3(transform.position.x, transform.position.y, brig.transform.position.z);      //pour que la brigade reste derrière le meuble

        brig.transform.position = _pos;
        brig.outObject();
        Vector3 _spawn = new Vector3(spawnPoint.position.x, spawnPoint.position.y, 1);      //les meuble sont un z=0 pour rester devant, donc les briagades spawn en z=1;

        brig.moveToDest(_spawn);
        brig.select();
    }
Ejemplo n.º 7
0
 /// <summary>
 /// Detects the brigade in object.
 /// </summary>
 /// <param name="brig">Brigade.</param>
 public void detectBrigInObject(BrigadeController brig)
 {
     ObjectScript meuble;
     if(brig.isInObject)
     {
         meuble=brig.objectIn;
         float detectRand=100*Random.value;
         if(detectRand>meuble.hiddenness)
             addDetection(fear);
     }
 }
Ejemplo n.º 8
0
 void OnTriggerExit2D(Collider2D other)
 {
     if (other is CircleCollider2D && other.CompareTag("Brigade"))
     {
         BrigadeController brigade = other.GetComponent <BrigadeController>();
         if (brigade.typeBrigade == typeBrig.Sabot)
         {
             UnSweep(brigade.speedSweep);
         }
     }
 }
Ejemplo n.º 9
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other is CircleCollider2D && other.CompareTag("Brigade") && isChasing && !hasCrushed)
     {
         BrigadeController brigade = other.GetComponent <BrigadeController>();
         if (!brigade.isInObject)
         {
             brigade.Hurt(force);
             hasCrushed = true;
             StartCoroutine(crushing());
         }
     }
 }
Ejemplo n.º 10
0
    public BrigadeController AddBrigade(typeBrig type, Vector3 spawnPoint)
    {
        if (nbbrigade < limitBrigade)
        {
            Vector3    _spawn = new Vector3(spawnPoint.x, spawnPoint.y, 1);       //les meuble sont un z=0 pour rester devant, donc les briagades spawn en z=1;
            GameObject brig   = null;
            if (type == typeBrig.Recolt && waterStock >= waterRecolt && foodStock >= foodRecolt)
            {
                brig = (GameObject)Instantiate(Recolt, _spawn, Quaternion.identity);
                RemoveWater(waterRecolt);
                RemoveFood(foodRecolt);
                nbbrigade++;
            }
            else if (type == typeBrig.Strong && waterStock >= waterStrong && foodStock >= foodStrong)
            {
                brig = (GameObject)Instantiate(Strong, _spawn, Quaternion.identity);
                RemoveWater(waterStrong);
                RemoveFood(foodStrong);
                nbbrigade++;
            }
            else if (type == typeBrig.Scout && waterStock >= waterScout && foodStock >= foodScout)
            {
                brig = (GameObject)Instantiate(Scout, _spawn, Quaternion.identity);
                RemoveWater(waterScout);
                RemoveFood(foodScout);
                nbbrigade++;
            }
            else if (type == typeBrig.Sabot && waterStock >= waterSabot && foodStock >= foodSabot)
            {
                brig = (GameObject)Instantiate(Sabot, _spawn, Quaternion.identity);
                RemoveWater(waterSabot);
                RemoveFood(foodSabot);
                nbbrigade++;
            }

            if (brig != null)
            {
                BrigadeController brigade = brig.GetComponent <BrigadeController>();
                brigade.select();
                return(brigade);
            }
            else
            {
                return(null);
            }
        }
        else
        {
            return(null);
        }
    }
Ejemplo n.º 11
0
    /// <summary>
    /// Detects the brigade in object.
    /// </summary>
    /// <param name="brig">Brigade.</param>
    public void detectBrigInObject(BrigadeController brig)
    {
        ObjectScript meuble;

        if (brig.isInObject)
        {
            meuble = brig.objectIn;
            float detectRand = 100 * Random.value;
            if (detectRand > meuble.hiddenness)
            {
                addDetection(fear);
            }
        }
    }
Ejemplo n.º 12
0
    DataSave CreateData()
    {
        DataSave data = new DataSave();

        data.waterStock     = lvlC.waterStock;
        data.foodStock      = lvlC.foodStock;
        data.constructStock = lvlC.constructStock;
        data.chemStock      = lvlC.chemStock;
        data.levelRecolt    = lvlC.levelRecolt;
        data.levelStrong    = lvlC.levelStrong;
        data.levelScout     = lvlC.levelScout;
        data.levelSabot     = lvlC.levelSabot;
        data.timer          = lvlC._time;
        data.amelDisp       = lvlC.amelDisp;


        GameObject[] brigObjects = GameObject.FindGameObjectsWithTag("Brigade");

        data.nbBrig         = brigObjects.Length;
        data.brigadesType   = new typeBrig[data.nbBrig];
        data.brigadesPos    = new float[data.nbBrig, 3];
        data.brigadesLife   = new float[data.nbBrig];
        data.brigadesSpeed  = new float[data.nbBrig];
        data.brigadesPoison = new float[data.nbBrig, 2];

        int i = 0;

        foreach (GameObject brigO in brigObjects)
        {
            BrigadeController brig = brigO.GetComponent <BrigadeController>();
            data.brigadesType[i]      = brig.typeBrigade;
            data.brigadesPos[i, 0]    = brig.transform.position.x;
            data.brigadesPos[i, 1]    = brig.transform.position.y;
            data.brigadesPos[i, 2]    = brig.transform.position.z;
            data.brigadesLife[i]      = brig.life;
            data.brigadesSpeed[i]     = brig.speed;
            data.brigadesPoison[i, 0] = brig.damagePoison;
            data.brigadesPoison[i, 1] = brig.lenghtPoisonRemain;

            i++;
        }



        return(data);
    }
Ejemplo n.º 13
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if(other is CircleCollider2D && other.CompareTag("Brigade"))
        {
            brigade=other.GetComponent<BrigadeController>();
            if(!hasDetected)
            {
                if(!brigade.isInObject && !brigade.underMeuble)
                    human.detectBrig(brigade);
                else
                    human.detectBrigInObject(brigade);

                hasDetected=true;
                StartCoroutine(ReDetect());
            }
        }
    }
Ejemplo n.º 14
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other is CircleCollider2D && other.CompareTag("Brigade"))
     {
         BrigadeController brigade = other.GetComponent <BrigadeController>();
         if (brigade.typeBrigade != typeBrig.Sabot)
         {
             brigade.Poison(poisonValue, lenght);
             poisonValue--;
             if (poisonValue == 0)
             {
                 Destroy(this.gameObject);
             }
         }
         else
         {
             Sweep(brigade.speedSweep);
         }
     }
 }
Ejemplo n.º 15
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other is CircleCollider2D && other.CompareTag("Brigade"))
        {
            brigade = other.GetComponent <BrigadeController>();
            if (!hasDetected)
            {
                if (!brigade.isInObject && !brigade.underMeuble)
                {
                    human.detectBrig(brigade);
                }
                else
                {
                    human.detectBrigInObject(brigade);
                }

                hasDetected = true;
                StartCoroutine(ReDetect());
            }
        }
    }
Ejemplo n.º 16
0
    void LoadData(DataSave data)
    {
        lvlC.waterStock     = data.waterStock;
        lvlC.foodStock      = data.foodStock;
        lvlC.constructStock = data.constructStock;
        lvlC.chemStock      = data.chemStock;
        lvlC.levelRecolt    = data.levelRecolt;
        lvlC.levelStrong    = data.levelStrong;
        lvlC.levelScout     = data.levelScout;
        lvlC.levelSabot     = data.levelSabot;
        lvlC.timeRemain     = data.timer;
        lvlC.amelDisp       = data.amelDisp;

        for (int i = 0; i < data.nbBrig; i++)
        {
            Vector3           pos  = new Vector3(data.brigadesPos[i, 0], data.brigadesPos[i, 1], data.brigadesPos[i, 2]);
            BrigadeController brig = lvlC.AddBrigade(data.brigadesType[i], pos);
            brig.isSelected = false;
        }

        //penser à "isPoisonned"
    }
Ejemplo n.º 17
0
 /// <summary>
 /// Sortir la brigade
 /// </summary>
 /// <param name="brig">Brigade.</param>
 void sortirBrig(BrigadeController brig)
 {
     Vector3 _pos=new Vector3(transform.position.x, transform.position.y, brig.transform.position.z);//pour que la brigade reste derrière le meuble
     brig.transform.position=_pos;
     brig.outObject();
     Vector3 _spawn=new Vector3(spawnPoint.position.x, spawnPoint.position.y, 1);//les meuble sont un z=0 pour rester devant, donc les briagades spawn en z=1;
     brig.moveToDest(_spawn);
     brig.select();
 }
Ejemplo n.º 18
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other is CircleCollider2D && other.CompareTag("Brigade"))
        {
            BrigadeController brigade = other.GetComponent <BrigadeController>();

            //si la brigade n'est pas à destination de ce meuble, elle ne doit pas y rentrer
            if (!brigade.goToMeuble || brigade.meubleToGo != this)
            {
                brigade.underObjectIn(this);
                return;
            }

            //les brigades ne peuvent pas rentrer dans les meubles solides si elles n'ont pas de capacité de destruction)
            //les brigades ne peuvent pas renrter dans la colonie pour l'instant.
            if (isColonie || (brigade.destructCap == 0 && solidityLevel > 0))
            {
                brigade.moveToDest(spawnPoint.position);
            }
            //brigade colon
            else if (brigade.typeBrigade == typeBrig.Scout && brigade.isColonizing)
            {
                colonize();
                brigade.Hurt(1000f);                 //meurt
            }
            else
            {
                //les brigades pouvant "ouvrir" les meubles "solides"
                if (brigade.destructCap > 0 && solidityLevel > 0)
                {
                    opening(brigade.destructCap);
                }
                if (nbBrigade < maxBrig)
                {
                    //brigade entre, ajoute sa vitesse de collecte
                    Brigs[nbBrigade] = brigade;
                    speedWater      += brigade.waterTaking;
                    speedFood       += brigade.foodTaking;
                    speedConstruct  += brigade.constructTaking;
                    brigade.inObject(this);                                                                               //la brigade sait dans quel objet elle est
                    Vector3 _pos = new Vector3(transform.position.x, transform.position.y, brigade.transform.position.z); //pour que la brigade reste derrière le meuble
                    brigade.transform.position = _pos;
                    nbBrigade++;
                }
                else
                {
                    brigade.moveToDest(spawnPoint.position);
                }
                if (!isInfected)
                {
                    isInfected = true;
                    lvlC.AddContamin();
                    sprite.color = infectedColor;
                    //A la première contamination, on déclenche la prise de ressource
                    Invoke("takeWater", ListConst.takeDelay);
                    Invoke("takeFood", ListConst.takeDelay);
                    Invoke("takeConstruct", ListConst.takeDelay);
                }
            }
        }
    }