Exemple #1
0
    private void FireTo(int color)
    {
        if (bManager.IsActive(BonusName.DOOM_HAMMER))
        {
            List <AKillable> targets = (bManager.IsActive(BonusName.MULTI_STRIKES) ? gManager.HitAllFirstEntities(ref color) : gManager.HitAllEntities(color));

            if (targets == null)
            {
                GetHit(true);
            }
            else
            {
                audioSource.PlayOneShot(shootClip[Random.Range(0, shootClip.Count)], 1.0f);
                GameObject atk = Instantiate(hammerPrefab, this.transform.position, Quaternion.identity) as GameObject;
                atk.GetComponent <HammerAttack>().Init(targets, gManager.GetColor(color));
            }
        }
        else
        {
            //Si on est sous multiStrike, on choppe le premier ennemi peu importe la couleur pressée.
            AKillable target = (bManager.IsActive(BonusName.MULTI_STRIKES) ? gManager.HitFirstEntity(ref color) : gManager.HitEntity(color));

            if (target == null)
            {
                GetHit(true);
            }
            else
            {
                audioSource.PlayOneShot(shootClip[Random.Range(0, shootClip.Count)], 1.0f);
                GameObject atk = Instantiate(attackPrefab, this.transform.position, Quaternion.identity) as GameObject;
                atk.GetComponent <HeroAttack>().Init(target.transform, gManager.GetColor(color));
            }
        }
    }
Exemple #2
0
    void Update()
    {
        if (target != null)
        {
            if (Vector2.Distance(this.transform.position, target.position) < range)
            {
                AKillable ak = target.GetComponent <AKillable>();
                ak.PlayHit();
                ak.isHitByAttack = true;

                //On détruit le particle system 0.3f secondes plus tard pour lui laisser le temps de finir l'animation
                partColor.loop             = false;
                partColor.transform.parent = null;
                GameObject.Destroy(partColor.gameObject, 0.3f);

                GameObject.Destroy(this.gameObject);
            }
            else
            {
                transform.position = Vector3.MoveTowards(transform.position, target.transform.position, speed * Time.deltaTime);
            }
        }
        else
        {
            GameObject.Destroy(this.gameObject);
        }
    }
Exemple #3
0
    //Stock la valeur de la couleur dans l'argument. Nécessaire pour les ennemis qui changent de couleur après un coup
    public AKillable HitFirstEntity(ref int color)
    {
        AKillable res = null;

        foreach (AKillable entity in entityList)
        {
            if (entity.GetColor() != -1)
            {
                if (res == null)
                {
                    res = entity;
                }
                else if (res != null && (res.transform.position.y > entity.transform.position.y))
                {
                    res = entity;
                }
            }
        }

        if (res)
        {
            color = res.GetColor();
            res.GetHit(1);
        }
        return(res);
    }
Exemple #4
0
    void OnTriggerEnter2D(Collider2D other)
    {
        AKillable entity = other.GetComponent <AKillable>();

        if (entity)
        {
            entity.Kill(hardKill);
        }
    }
Exemple #5
0
 //Direction should be between -1 and 1
 public void Init(float time, float direction, AKillable own, HeroController target, float s, int c = -1)
 {
     base.Init(own, target, s, c);
     fuse                 = time;
     spriteRenderer       = GetComponent <SpriteRenderer>();
     colored              = gameManager.GetColor(color);
     step                 = (colored - new Color(0.3f, 0.3f, 0.3f)) / fuse;
     spriteRenderer.color = colored;
     movement             = new Vector2(direction * speed, -speed);
 }
Exemple #6
0
    //Touche tous les ennemis de la couleur du premier ennemi
    public List <AKillable> HitAllFirstEntities(ref int color)
    {
        List <AKillable> res = null;
        AKillable        e   = HitFirstEntity(ref color);

        if (e != null)
        {
            res = HitAllEntities(color);
            if (res == null)
            {
                res = new List <AKillable>();
            }
            res.Insert(0, e);
        }
        return(res);
    }
Exemple #7
0
    // return l'enemie le plus bas de la couleur
    // return null si pas de couleur
    private AKillable FindEntityByColor(int colorVal)
    {
        AKillable res = null;

        foreach (AKillable entity in entityList)
        {
            if (entity.GetColor() == colorVal)
            {
                if (res == null)
                {
                    res = entity;
                }
                else if (res != null && (res.transform.position.y > entity.transform.position.y))
                {
                    res = entity;
                }
            }
        }

        return(res);
    }
Exemple #8
0
 public void Init(AKillable own, HeroController target, float s, int color = -1)
 {
     base.Init(target, 1.0f, color);
     owner = own;
     speed = s;
 }
Exemple #9
0
 //Retire l'ennemi de la liste
 public void RemoveEntity(AKillable obj)
 {
     entityList.Remove(obj);
 }
Exemple #10
0
 //ajoute un enemy dans la liste et lui attribue une couleur.
 public void AddEntity(AKillable obj)
 {
     entityList.Add(obj);
     //attribue la couleur d'affichage
 }
Exemple #11
0
 public void Init(Transform h, AKillable own, HeroController target, float s, int c = -1)
 {
     base.Init(own, target, s, c);
     hand = h;
 }