Exemplo n.º 1
0
 // Start is called before the first frame update
 void Start()
 {
     rb         = GetComponent <Rigidbody2D>();
     col        = GetComponent <Collider2D>();
     camControl = GameObject.Find("/Camera").GetComponent <T10_CameraController>();
     smiley     = SMILEY.SLIGHTSMILE;
     lastSmiley = smiley;
     WhichSmiley(smiley);
     speed = Speed.Value;
     shieldConsumedUI.SetActive(true);
     shieldUI.SetActive(true);
 }
Exemplo n.º 2
0
    IEnumerator CooldownSmiley()
    {
        yield return(new WaitForSeconds(cooldownSmiley.Value));

        smiley = SMILEY.SLIGHTSMILE;
    }
Exemplo n.º 3
0
 private void WhichSmiley(SMILEY smiley)
 {
     StopCoroutine("Fire");
     StopCoroutine("FireGlace");
     canFire = false;
     StopCoroutine("CooldownSmiley");
     if (smiley == SMILEY.SLIGHTSMILE)
     {
         weapon  = Weapon.DEFAULT;
         bullets = BULLETS.DEFAULT;
         bulletInUse.GetComponent <T10_Bullet>().bulletType = T10_Bullet.BULLETS.DEFAULT;
         playerCap.sprite = emojiSprite[0];
     }
     else if (smiley == SMILEY.JOY)
     {
         weapon  = Weapon.MITRAILLETTE;
         bullets = BULLETS.DEFAULT;
         bulletInUse.GetComponent <T10_Bullet>().bulletType = T10_Bullet.BULLETS.DEFAULT;
         playerCap.sprite = emojiSprite[1];
     }
     else if (smiley == SMILEY.RAGE)
     {
         weapon  = Weapon.SHOTGUN;
         bullets = BULLETS.DEFAULT;
         bulletInUse.GetComponent <T10_Bullet>().bulletType = T10_Bullet.BULLETS.SHOTGUN;
         playerCap.sprite = emojiSprite[2];
     }
     else if (smiley == SMILEY.COLDFACE)
     {
         weapon  = Weapon.COLD;
         bullets = BULLETS.GLACE;
         bulletInUse.GetComponent <T10_Bullet>().bulletType = T10_Bullet.BULLETS.GLACE;
         playerCap.sprite = emojiSprite[3];
     }
     else if (smiley == SMILEY.SCREAM)
     {
         weapon  = Weapon.DEFAULT;
         speed  *= SpeedIncrease.Value;
         bullets = BULLETS.DEFAULT;
         bulletInUse.GetComponent <T10_Bullet>().bulletType = T10_Bullet.BULLETS.DEFAULT;
         playerCap.sprite = emojiSprite[4];
     }
     else if (smiley == SMILEY.SMILINGIMP)
     {
         weapon  = Weapon.SNIPER;
         bullets = BULLETS.SNIPER;
         bulletInUse.GetComponent <T10_Bullet>().bulletType = T10_Bullet.BULLETS.SNIPER;
         lineRenderer.enabled = true;
         isSniper             = true;
         playerCap.sprite     = emojiSprite[5];
     }
     else if (smiley == SMILEY.MAD)
     {
         weapon  = Weapon.GRENADE;
         bullets = BULLETS.GRENADE;
         bulletInUse.GetComponent <T10_Bullet>().bulletType = T10_Bullet.BULLETS.GRENADE;
         playerCap.sprite = emojiSprite[6];
     }
     StartCoroutine("CooldownSmiley");
     canFire = true;
 }
Exemplo n.º 4
0
    // Update is called once per frame
    void Update()
    {
        // Julien
        if (Input.GetAxis("Horizontal") != 0 || Input.GetAxis("Vertical") != 0)
        {
            gameObject.GetComponent <Animator>().Play("player_walk");
        }
        else
        {
            gameObject.GetComponent <Animator>().Play("player_idle");
        }
        if (smiley != lastSmiley)
        {
            if (lastSmiley == SMILEY.SCREAM)
            {
                speed /= SpeedIncrease.Value;
            }
            if (lastSmiley == SMILEY.SMILINGIMP)
            {
                lineRenderer.enabled = false;
                isSniper             = false;
            }
            WhichSmiley(smiley);
        }
        RaycastHit2D hit = Physics2D.Raycast(transform.position, Vector2.zero, Mathf.Infinity, ~player);;

        if (hit)
        {
            if (hit.transform.gameObject.layer == 8)
            {
                //timeRecul = 1;
                isGlace = true;
            }
        }
        else
        {
            isGlace = false;
        }
        if (!isGlace)
        {
            if (Input.GetKeyDown("space") && canDash)
            {
                if (rb.velocity.magnitude != 0)
                {
                    Debug.Log("dash");
                    StartCoroutine("Dash");
                }
            }
            // Curseur();
            FaceMouse();
            if (isSniper)
            {
                SetLineRenderer();
            }
            if (!ui.isGameMenued && !ui.isGamePaused && Input.GetMouseButton(0) && canFire)
            {
                canFire = false;
                StartCoroutine("Fire");
                actualPos = transform.position;
                Vector3 dir = direction.normalized;
                Vector3 vit = rb.velocity.normalized;
                if (weapon == Weapon.DEFAULT)
                {
                    targetPos = transform.position - ((new Vector3(direction.x, direction.y) * reculPower) + (dir - vit));
                    StartCoroutine(Recul(targetPos, TimeReculTerreDEFAULT.Value, PuissReculTerreDEFAULT.Value));
                    camControl.ShakeCamera(shakeDurDefault, shakeAmDefault);
                }
                else if (weapon == Weapon.MITRAILLETTE)
                {
                    targetPos = transform.position - ((new Vector3(direction.x, direction.y) * reculPower) + (dir - vit));
                    StartCoroutine(Recul(targetPos, TimeReculTerreMITRAILLETTE.Value, PuissReculTerreMITRAILLETTE.Value));
                    camControl.ShakeCamera(shakeDurSMG, shakeAmSMG);
                }
                else if (weapon == Weapon.SHOTGUN)
                {
                    targetPos = transform.position - ((new Vector3(direction.x, direction.y) * reculPower) + (dir - vit));
                    camControl.ShakeCamera(shakeDurShotGun, shakeAmShotGun);
                    StartCoroutine(Recul(targetPos, TimeReculTerreSHOTGUN.Value, PuissReculTerreSHOTGUN.Value));
                }
                else if (weapon == Weapon.SNIPER)
                {
                    targetPos = transform.position - ((new Vector3(direction.x, direction.y) * reculPower) + (dir - vit));
                    //camControl.ShakeCamera(shakeDurShotGun, shakeAmShotGun);
                    StartCoroutine(Recul(targetPos, TimeReculTerreSNIPER.Value, PuissReculTerreSNIPER.Value));
                }
                else if (weapon == Weapon.GRENADE)
                {
                    targetPos = transform.position - ((new Vector3(direction.x, direction.y) * reculPower) + (dir - vit));
                    //camControl.ShakeCamera(shakeDurShotGun, shakeAmShotGun);
                    StartCoroutine(Recul(targetPos, TimeReculTerreGRENADE.Value, PuissReculTerreGRENADE.Value));
                }
            }
        }
        if (isGlace)
        {
            //Curseur();
            FaceMouse();
            if (isSniper)
            {
                SetLineRenderer();
            }
            if (!ui.isGameMenued && !ui.isGamePaused && Input.GetMouseButton(0) && canFire)
            {
                canFire = false;
                StartCoroutine("FireGlace");
                actualPos = transform.position;
            }
        }
        lastSmiley = smiley;
    }