Exemplo n.º 1
0
    public void Tirer(Vector2 dir, int dmg)
    {
        if (m_Laser == null)
        {
            Debug.LogWarning("Il n'y a aucun prefab de balle dans " + name);
            return;
        }

        WeaponEnnemi canon = m_Core.GetComponent <WeaponEnnemi>();

        Bullet bul = Instantiate(m_Laser, m_FirePoint.position, m_FirePoint.rotation, transform).GetComponent <Bullet>() as Bullet;

        bul.direction  = dir;
        bul.noHit      = canon.noHit;
        bul.dommageHit = canon.dommageHit;
        bul.dmg        = dmg;
    }
Exemplo n.º 2
0
    private void Start()
    {
        myTransform = transform;
        rb          = GetComponent <Rigidbody2D>() as Rigidbody2D;

        if (GetComponent <EnnemiAI>() != null)
        {
            ia       = true;
            artIntel = GetComponent <EnnemiAI>() as EnnemiAI;
        }

        if (GetComponent <WeaponEnnemi>() != null)
        {
            weapon = GetComponent <WeaponEnnemi>() as WeaponEnnemi;
        }

        if (GetComponent <PatrolControl>() != null)
        {
            control     = GetComponent <PatrolControl>() as PatrolControl;
            direction.x = control.direction.x;
            //myTransform.localScale = new Vector2(myTransform.localScale.x * -direction.x, myTransform.localScale.y);
        }

        if (GetComponent <SpriteMask>() != null)
        {
            m_mask = GetComponent <SpriteMask>() as SpriteMask;
        }

        rb.gravityScale = (comp.deplacement == typeDeplac.Voler) ? 0 : rb.gravityScale;
        directionTir.x  = (facingRight) ? 1 : -1;

        if (en == null)
        {
            if (!searchingForPlayer)
            {
                searchingForPlayer = true;
                StartCoroutine(SearchForPlayer());
            }
        }

        StartCoroutine(CheckDistance());
    }
Exemplo n.º 3
0
    //  fonction de déplacement vers le noeud précicé, true = gauche / false = droite
    public void jumpRot(bool gd)
    {
        //  test de déplacement avec DOTween
        Vector3 pos   = tr.position;
        Vector3 angle = tr.rotation.eulerAngles;

        if (m_arreter)
        {
            return;
        }

        //Vector3 pos = new Vector3(7.0f, 0.0f, 0.0f) + tr.position;
        if (m_CurrentNode != null) // le boss est sur un noeud de la liste
        {
            if (gd == true)        //  il veux aller à gauche
            {
                if (m_CurrentNode.m_VoisinGauche != null)
                {
                    pos          += (m_CurrentNode.m_VoisinGauche.transform.position - pos);
                    angle        += new Vector3(0.0f, 0.0f, 90.0f);
                    m_CurrentNode = m_CurrentNode.m_VoisinGauche;
                }
                else if (m_CurrentNode.m_VoisinDroit != null)  // aucun voisin gauche, va à droite
                {
                    pos          += (m_CurrentNode.m_VoisinDroit.transform.position - pos);
                    angle        += new Vector3(0.0f, 0.0f, -90.0f);
                    m_CurrentNode = m_CurrentNode.m_VoisinDroit;
                }
                else
                {
                    return;
                }
            }
            else    // il veux aller à droite
            {
                if (m_CurrentNode.m_VoisinDroit != null)
                {
                    pos          += (m_CurrentNode.m_VoisinDroit.transform.position - pos);
                    angle        += new Vector3(0.0f, 0.0f, -90.0f);
                    m_CurrentNode = m_CurrentNode.m_VoisinDroit;
                }
                else if (m_CurrentNode.m_VoisinGauche != null)// aucun voisin droite, va à gauche
                {
                    pos          += (m_CurrentNode.m_VoisinGauche.transform.position - pos);
                    angle        += new Vector3(0.0f, 0.0f, 90.0f);
                    m_CurrentNode = m_CurrentNode.m_VoisinGauche;
                }
                else
                {
                    return;
                }
            }
        }
        else
        {
            Debug.LogError("Aucun noeud courrant pour le boss écrabouilleur");
            return;
        }

        if (m_Phase2)
        {
            pos.y -= 6.5f;
        }

        Sequence bouge = DOTween.Sequence();

        bouge.Append(tr.DOJump(pos, 8.0f, 1, 0.8f).SetEase(Ease.InOutQuad));
        bouge.Insert(0.1f, tr.DORotate(angle, 0.75f).SetEase(Ease.InOutQuart));

        if (m_Phase2 == false)
        {
            bouge.AppendCallback(() =>
            {
                CameraShaker.Instance.ShakeOnce(3f, 2f, .1f, 1.0f);
                if (FindObjectOfType <AudioManager>() != null)
                {
                    FindObjectOfType <AudioManager>().Play("StompBoss");
                }
            });
        }
        else if (m_Player != null)
        {
            bouge.AppendCallback(() =>
            {
                WeaponEnnemi canon = m_Core.GetComponent <WeaponEnnemi>();

                canon.Tirer(new Vector2(1.0f, 0.0f), 10, 0.0f);
                canon.Tirer(new Vector2(0.0f, 1.0f), 10, 0.0f);
                canon.Tirer(new Vector2(-1.0f, 0.0f), 10, 0.0f);
            });
        }

        bouge.Play();
    }