Пример #1
0
 private void Enable()
 {
     if (Functions.DeltaMax(player.position.x, theTransform.position.x, 4f) && Functions.DeltaMax(player.position.y, theTransform.position.y, 2f))
     {
         // Parent object has a sprite, so GetComponetInChildren doesn't work
         // Get all the components in the children and used the 1 element, which is the actual child.
         SpriteRenderer[] gO = gameObject.GetComponentsInChildren <SpriteRenderer>();
         if (gO[1].sprite == SMGSprite)
         {
             gO[1].sprite   = pistolSprite;
             gun.bulletType = (int)Gun.bullets.SMG;
             custom.PlayClipAt(activateClip, theTransform.position);
         }
         else if (gO[1].sprite == pistolSprite)
         {
             gO[1].sprite   = sniperSprite;
             gun.bulletType = (int)Gun.bullets.Pistol;
             custom.PlayClipAt(activateClip, theTransform.position);
         }
         else if (gO[1].sprite == sniperSprite)
         {
             gO[1].sprite   = SMGSprite;
             gun.bulletType = (int)Gun.bullets.Sniper;
             custom.PlayClipAt(activateClip, theTransform.position);
         }
     }
 }
Пример #2
0
    public IEnumerator Death()
    {
        custom.PlayClipAt(deathClip, theTransform.position);
        anim.SetTrigger("Death");
        yield return(new WaitForSeconds(0.4f));

        DeathState();
    }
Пример #3
0
 private void Update()
 {
     if (Application.loadedLevel != 0)
     {
         if (!playerH.isDead && playerCtrl.allowedToShoot && !playerCtrl.isGhost && CustomGetButtonDown.ButtonDown() || TouchShoot())
         {
             playerCtrl.allowedToShoot = false;
             if (playerCtrl.isRight)
             {
                 anim.SetTrigger("RightShoot");
             }
             else
             {
                 anim.SetTrigger("LeftShoot");
             }
             // Derive the bullet's position from the player's position.
             Rigidbody2D bulletR;
             if (bulletType == 0)
             {
                 bulletR = bullet0;
                 custom.PlayClipAt(SMGClip, theTransform.position);
             }
             else if (bulletType == 1)
             {
                 bulletR = bullet1;
                 custom.PlayClipAt(pistolClip, theTransform.position);
             }
             else if (bulletType == 2)
             {
                 bulletR = bullet2;
                 custom.PlayClipAt(sniperClip, theTransform.position);
             }
             else
             {
                 bulletR = bullet2;
             }
             if (playerCtrl.isRight)
             {
                 position = new Vector3(player.position.x + SHIFTX, player.position.y + SHIFTY, 0);
                 Rigidbody2D bulletInstance = Instantiate(bulletR, position, Quaternion.Euler(new Vector3(0, 0, 0))) as Rigidbody2D;
                 bulletInstance.velocity = new Vector2(SPEED, 0);
             }
             else
             {
                 position = new Vector3(player.position.x - SHIFTX, player.position.y + SHIFTY, 0);
                 Rigidbody2D bulletInstance = Instantiate(bulletR, position, Quaternion.Euler(new Vector3(0, 0, 180f))) as Rigidbody2D;
                 bulletInstance.velocity = new Vector2(-SPEED, 0);
             }
             StartCoroutine(Wait());
         }
         CustomGetButtonDown.ButtonUp();
     }
 }
Пример #4
0
 public void Show(GameObject panel)
 {
     panel.SetActive(true);
     Tint.SetActive(true);
     if (pausePanel.activeSelf && panel != pausePanel)
     {
         fromPause = true;
         Hide(pausePanel);
     }
     else
     {
         fromPause = false;
     }
     custom.PlayClipAt(pressClip, transform.position);
 }
Пример #5
0
 public void Enable()
 {
     if (Functions.DeltaMax(player.position.x, theTransform.position.x, 4f) && Functions.DeltaMax(player.position.y, theTransform.position.y, 2f))
     {
         if (!used)
         {
             SpriteChange();
             custom.PlayClipAt(activateClip, theTransform.position);
             playerH.AddHealth();
         }
     }
 }
Пример #6
0
 private void Enable()
 {
     if (Functions.DeltaMax(player.position.x, theTransform.position.x, 4f) && Functions.DeltaMax(player.position.y, theTransform.position.y, 2.75f))
     {
         accessLight.enabled = !accessLight.enabled;
         doorLight.enabled   = !doorLight.enabled;
         custom.PlayClipAt(activateClip, theTransform.position);
         if (Application.loadedLevel == 5)
         {
             beam.SetActive(!beam.activeSelf);
         }
     }
 }
Пример #7
0
 private void Update()
 {
     playerPos = new Vector2(player.transform.position.x, player.transform.position.y);
     if ((playerPos.x > theTransform.position.x && !isRight) || (playerPos.x < theTransform.position.x && isRight))
     {
         Flip();
     }
     if (playerH.playerCtrl.isRight)
     {
         maxVal = 2.9f;
     }
     else
     {
         maxVal = 3.2f;
     }
     if (allowedToAttack && !playerH.isDead && Functions.DeltaMax(playerPos.x, theTransform.position.x, maxVal) && Functions.DeltaMax(playerPos.y, theTransform.position.y, 2f))
     {
         allowedToAttack = false;
         anim.SetTrigger("Attack");
         attacking = true;
         StartCoroutine(PlayerHurt());
         StartCoroutine(WaitToAttack());
         custom.PlayClipAt(swingClip, theTransform.position);
     }
     else if (allowedToAttack && Functions.DeltaMin(playerPos.x, theTransform.position.x, maxVal) && Functions.DeltaMax(playerPos.y, theTransform.position.y, 2f))
     {
         anim.SetTrigger("Walk");
         attacking = false;
         Move();
     }
     else
     {
         anim.SetTrigger("Idle");
         attacking = false;
     }
 }
Пример #8
0
    public IEnumerator Death()
    {
        // Do visual/audio death stuff then wait to explode and depower.
        health = 0;
        custom.PlayClipAt(deathClip, theTransform.position);
        anim.SetTrigger("Death");
        yield return(new WaitForSeconds(0.35f));

        if (Functions.DeltaMax(playerPos.x, theTransform.position.x, 3.05f) && Functions.DeltaMax(playerPos.y, theTransform.position.y, 2f))
        {
            playerH.TakeDamage(20f, true, isRight);
        }
        GetComponentInChildren <Light>().enabled = false;
        DeathState();
    }
Пример #9
0
 private void Die()
 {
     isDead = true;
     if (playerCtrl.isGhost)
     {
         playerCtrl.BackToNormal();
     }
     if (playerCtrl.isRight)
     {
         anim.SetTrigger("DeathRight");
     }
     else
     {
         anim.SetTrigger("DeathLeft");
     }
     custom.PlayClipAt(deathClip, theTransform.position);
     GetComponent <Rigidbody2D>().constraints = RigidbodyConstraints2D.None;
     reset.helmet.rotation     = Quaternion.Euler(20f, 0f, 0f);
     playerCtrl.allowedToShoot = false;
     playerCtrl.allowedToGhost = false;
     ripAnim.SetTrigger("Rip");
     ripSprite.enabled = true;
     StartCoroutine(Revive());
 }
Пример #10
0
 private void Beam()
 {
     if (GetComponent <PolygonCollider2D>().IsTouching(poly) && playerCtrl.allowedToBeam && !playerCtrl.isGhost && !playerH.isDead)
     {
         playerCtrl.allowedToBeam = false;
         playerCtrl.isBeam        = true;
         if (theTransform.position.y < player.position.y)
         {
             anim.SetTrigger("BeamDown");
             rigid.gravityScale = 0.1f;
         }
         else
         {
             anim.SetTrigger("BeamUp");
             rigid.gravityScale = -0.1f;
         }
         poly.isTrigger            = true;
         playerCtrl.allowedToShoot = false;
         rigid.velocity            = new Vector2(0, 0);
         StartCoroutine(WaitForBeam());
         custom.PlayClipAt(liftClip, theTransform.position);
     }
 }