예제 #1
0
    // Use to process your families.
    protected override void onProcess(int familiesUpdateCount)
    {
        foreach (GameObject go in _triggeredGO)
        {
            //Récupérer les élements qui rentrent en collision
            Triggered2D t2d = go.GetComponent <Triggered2D> ();
            //Vérifier que le target peut être agglutinés
            if (go.GetComponent <Agglutinué> () != null)
            {
                Debug.Log(go + " aggl");
                continue;
            }
            foreach (GameObject target in t2d.Targets)
            {
                //On lui rajoute le leucocyte  IsInfacble et Isinfecte comme component
                Leucocyte    leucocyte    = target.GetComponent <Leucocyte> ();
                IsInfectable isInfectable = target.GetComponent <IsInfectable> ();
                IsInfecte    infecte      = target.GetComponent <IsInfecte> ();
                if ((isInfectable != null || leucocyte != null) && infecte == null)
                {
                    target.AddComponent <IsInfecte>();
                    //On lui change l'image pour représenter qu'il est infecté
                    SpriteRenderer spriteRenderer;
                    spriteRenderer = target.GetComponent <SpriteRenderer>();
                    Sprite s = (Sprite)Resources.Load(spriteRenderer.sprite.name + "_infected", typeof(Sprite));
                    Debug.Log(s);
                    spriteRenderer.sprite = s;
                    Infecteur virus = go.GetComponent <Infecteur>();
                    virus.hasInfect = true;

                    Debug.Log(target + " : est infecté !");
                }
            }
        }
    }
예제 #2
0
    // Use to process your families.
    protected override void onProcess(int familiesUpdateCount)
    {
        foreach (GameObject go in _triggeredGO)
        {
            //Récupérer les élements qui peuvent être en collision
            Triggered2D t2d = go.GetComponent <Triggered2D> ();

            foreach (GameObject target in t2d.Targets)
            {
                Leucocyte leucocyte = go.GetComponent <Leucocyte> ();
                HP        hp1       = target.GetComponent <HP>();
                Absorbeur absorbe   = target.GetComponent <Absorbeur> ();
                //Si l'élément n'est pas mort et que c'est un leucocyte et qu'il n'est pas un absorbeur
                if (hp1 != null && leucocyte != null && absorbe == null)
                {
                    //on lui rajoute endommager
                    Endommage endommage = go.GetComponent <Endommage> ();
                    Debug.Log(hp1.hp);
                    hp1.hp -= endommage.hpLost;

                    /*if (hp1.hp <= 0)
                     *      GameObjectManager.destroyGameObject (target);
                     */
                }
            }
        }
    }
예제 #3
0
    // Use to process your families.
    protected override void onProcess(int familiesUpdateCount)
    {
        foreach (GameObject go in _triggeredGO)
        {
            bool tokill = false;
            //On vérifie tous les cas ou on peut mourrir, soit un infection par un virus etc...
            Infecteur  virusC     = go.GetComponent <Infecteur> ();
            HP         hp1        = go.gameObject.GetComponentInChildren <HP> ();
            IsApoptose isApoptose = go.GetComponent <IsApoptose>();
            IsAbsorbe  isAbsorbe  = go.GetComponent <IsAbsorbe> ();
            IsInfecte  infecte    = go.GetComponent <IsInfecte> ();
            Leucocyte  leucocyte  = go.GetComponent <Leucocyte> ();
            Secreter   secreter   = go.GetComponent <Secreter> ();
            if (virusC != null && virusC.hasInfect)               // mort des virus une fois qu'ils ont infecté qlqu'un
            {
                Debug.Log("MORT : virus a infecté " + go);
                tokill = true;
                //GameObjectManager.destroyGameObject (go);
            }
            if (hp1 != null && hp1.hp <= 0)               // mort de toute entitées quand elle a plus d'HP
            {
                Debug.Log("MORT : plus d'hp " + go);
                tokill = true;
                //GameObjectManager.destroyGameObject (go);
            }
            if (isApoptose != null)               // MORT APOPTOSE
            {
                Debug.Log("MORT : apoptose " + go);
                tokill = true;
                //GameObjectManager.destroyGameObject (go);
            }
            if (isAbsorbe != null)               // MORT absorbé
            {
                Debug.Log("MORT : absorbé " + go);
                tokill = true;
                //GameObjectManager.destroyGameObject (go);
            }
            if (leucocyte != null && tokill)
            {
                bound = go.GetComponent <Renderer>().bounds;
                for (int i = 0; i < 3; i++)
                {
                    float x = Random.Range(bound.min.x - 0.5f, bound.max.x + 0.5f);
                    float y = Random.Range(bound.min.y - 0.5f, bound.max.y + 0.5f);
                    float z = 0.0f;

                    Vector3 toxPosition = new Vector3(x, y, z);

                    vir = GameObjectManager.instantiatePrefab("Dechet");
                    vir.transform.position = toxPosition;
                }
            }
            if (secreter != null && tokill)
            {
                bound = go.GetComponent <Renderer>().bounds;
                float x = Random.Range(bound.max.x, bound.max.x + 0.5f);
                float y = Random.Range(bound.max.y, bound.max.y + 0.5f);
                float z = 0.0f;

                Vector3 toxPosition = new Vector3(x, y, z);

                vir = GameObjectManager.instantiatePrefab("Dechet");
                //vir.transform.position = toxPosition;
            }

            if (infecte != null && isAbsorbe == null && isApoptose == null && tokill)
            {
                Debug.Log("dlibere VIrus : absorbé " + go);
                bound = go.GetComponent <Renderer>().bounds;
                for (int i = 0; i < 5; i++)
                {
                    float x = Random.Range(bound.min.x, bound.max.x);
                    float y = Random.Range(bound.min.y, bound.max.y);
                    float z = 0.0f;

                    Vector3 toxPosition = new Vector3(x, y, z);

                    vir = GameObjectManager.instantiatePrefab("Virus");
                    vir.transform.position = toxPosition;
                }
            }
            if (tokill)
            {
                //if(go.gameObject.transform.parent.gameObject)
                //	GameObjectManager.destroyGameObject (go.gameObject.transform.parent.gameObject);
                //else
                GameObjectManager.destroyGameObject(go);
            }
        }
    }