AddPoints() public static method

public static AddPoints ( int pointsToAdd ) : void
pointsToAdd int
return void
Ejemplo n.º 1
0
    // Update is called once per frame
    private void Update()
    {
        if (health <= 0)
        {
            //Instantiate(deathEffect, transform.position, Quaternion.identity);
            gameObject.SetActive(false);
            Destroy(gameObject);
            ScoreManager.AddPoints(pointsToAdd);
            NextPanel.SetActive(true);
        }

        if (Vector2.Distance(transform.position, target.position) > 2)
        {
            transform.position = Vector2.MoveTowards(transform.position, target.position, speed * Time.deltaTime);
        }
        else if (Vector2.Distance(transform.position, target.position) < stoppingDistance && Vector2.Distance(transform.position, target.position) > retreatDistance)
        {
            transform.position = this.transform.position;
        }
        else if (Vector2.Distance(transform.position, target.position) < retreatDistance)
        {
            transform.position = Vector2.MoveTowards(transform.position, target.position, -speed * Time.deltaTime);
        }


        if (timeBtwShots <= 0)
        {
            Instantiate(projectile, transform.position, Quaternion.identity);
            timeBtwShots = startTimeBtwShots;
        }
        else
        {
            timeBtwShots -= Time.deltaTime;
        }
    }
Ejemplo n.º 2
0
    protected override void OnPickup(Collider2D collision)
    {
        if (GameManager.IsDone)
        {
            return;
        }

        base.OnPickup(collision);

        var tree = collision.GetComponentInParent <TreeOfLife>();

        if (tree != null)
        {
            if (ScoreManager.Score > 50)
            {
                ScoreManager.AddPoints(-50);
            }
            else
            {
                ScoreManager.SetPoints(0);
            }

            tree.Wither();
        }

        var waterTank = collision.GetComponentInParent <WaterTank>();

        if (waterTank != null)
        {
            ScoreManager.AddPoints(100);

            waterTank.Use();
        }
    }
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.name == "Player")
        {
            UserCtrl healthVal = other.GetComponent <UserCtrl>();
            print("You've collected the item, m8");
            if (isHealth)
            {
                if (healthVal.userHealth < 10)
                {
                    healthVal.userHealth += healUp;
                }
                else if (healthVal.userHealth <= 10)
                {
                    healthVal.userHealth = 10;
                }
            }


            ScoreManager.AddPoints(value);

            Instantiate(pickUpEffect, transform.position, transform.rotation);
            Destroy(gameObject);
        }
    }
Ejemplo n.º 4
0
    void Update()
    {
        hittingWall = Physics2D.OverlapCircle(wallCheck.position, wallCheckRadius, whatIsWall);

        if (hittingWall)
        {
            moveRight = !moveRight;
        }

        if (moveRight)
        {
            transform.localScale = new Vector3(-1f, 1f, 1f);
            GetComponent <Rigidbody2D>().velocity = new Vector2(moveSpeed, GetComponent <Rigidbody2D>().velocity.y);
        }
        else
        {
            transform.localScale = new Vector3(1f, 1f, 1f);
            GetComponent <Rigidbody2D>().velocity = new Vector2(-moveSpeed, GetComponent <Rigidbody2D>().velocity.y);
        }

        if (enemyHealth <= 0)
        {
            Instantiate(deathEffect, transform.position, transform.rotation);
            ScoreManager.AddPoints(pointsOnDeath);
            Destroy(gameObject);
        }
    }
Ejemplo n.º 5
0
    public IEnumerator RespawnPCo()
    {
        //Generate Death Particle
        Instantiate(DeathParticle, gaben.transform.position, gaben.transform.rotation);

        //hide pc
        //PC.ennabled = false;
        PC2.SetActive(false);
        gaben.GetComponent <Renderer>().enabled = false;
        //Gravity Reset
        GravityStore = gaben.GetComponent <Rigidbody2D>().gravityScale;
        gaben.GetComponent <Rigidbody2D>().gravityScale = 0f;
        gaben.GetComponent <Rigidbody2D>().velocity     = Vector2.zero;
        // point penalty
        ScoreManager.AddPoints(-PointPenaltyOnDeath);
        //Debug message
        Debug.Log("lord gaben has Respwned ");
        //Respawn Delay
        yield return(new WaitForSeconds(RespawnDelay));

        //Gravity Restore
        gaben.GetComponent <Rigidbody2D>().gravityScale = GravityStore;
        //match gabens transform postion
        gaben.transform.position = CurrentCheckPoint.transform.position;
        //show gaben
        //gaben.enabled = true;

        PC2.SetActive(true);
        gaben.GetComponent <Renderer> ().enabled = true;
        //Spawn gaben
        Instantiate(RespawnParticle, CurrentCheckPoint.transform.position, CurrentCheckPoint.transform.rotation);
    }
    public IEnumerator RespawnPlayerCo()
    {
        Instantiate(deathParticle, PCRigid.transform.position, deathParticle.transform.rotation);

        player.SetActive(false);

        PCRigid.GetComponent <Renderer> ().enabled = false;

        gravityStore = PCRigid.GetComponent <Rigidbody2D>().gravityScale;

        PCRigid.GetComponent <Rigidbody2D>().gravityScale = 0f;

        PCRigid.GetComponent <Rigidbody2D>().velocity = Vector2.zero;

        ScoreManager.AddPoints(-PointPenaltyOnDeath);

        Debug.Log("PC Respawn");

        yield return(new WaitForSeconds(RespawnDelay));

        PCRigid.GetComponent <Rigidbody2D>().gravityScale = gravityStore;

        PCRigid.transform.position = currentCheckPoint.transform.transform.position;

        player.SetActive(true);
        PCRigid.GetComponent <Renderer> ().enabled = true;

        Instantiate(respawnParticle, currentCheckPoint.transform.position, deathParticle.transform.rotation);
    }
Ejemplo n.º 7
0
    // Update is called once per frame
    void Update()
    {
        if (!IsDead)
        {
            currentState.Execute();

            LookAtTarget();
        }

        else if (IsDead)
        {
            myAnimator.SetTrigger("death");
            deathTimer = deathTimer - 1;

            if (deathTimer == 0 && gameObject.tag != "Boss")
            {
                Destroy(gameObject);
                ScoreManager.AddPoints(pointsToAdd);
            }

            if (deathTimer == 1000 && gameObject.tag == "Boss")
            {
                ScoreManager.AddPoints(pointsToAdd);
            }
        }
    }
Ejemplo n.º 8
0
    public IEnumerator RespawnPlayerCo()
    {
        Instantiate(deathParticle, player.transform.position, player.transform.rotation); // to create at the same point

        player.enabled = false;                                                           //disable the player after death

        player.GetComponent <Renderer>().enabled = false;

        ScoreManager.AddPoints(-pointPenaltyOnDeath); // on death penalty point

        Debug.Log("PlayerRespawn");

        yield return(new WaitForSeconds(respawnDelay));

        player.transform.position = currentCheckpoint.transform.position;
        player.enabled            = true; //disable the player after death

        player.GetComponent <Renderer>().enabled = true;

        healthManager.FullHealth();

        healthManager.IsDead = false; // so that it doesnt call for kill player script


        Instantiate(respawnParticle, currentCheckpoint.transform.position, currentCheckpoint.transform.rotation); // to create at the checkpoint
    }
Ejemplo n.º 9
0
    void OnTriggerEnter2D(Collider2D Other)
    {
        if (Other.GetComponent <Rigidbody2D> () == null)
        {
            return;
        }

        switch (PickupType)
        {
        case "Coin":
            ScoreManager.AddPoints(ValueToAdd);
            break;

        case "Health":
            ScoreManager.AddHealth(ValueToAdd);
            break;

        case "Ammo":
            ScoreManager.AddAmmo(ValueToAdd);
            break;

        case "Life":
            ScoreManager.AddLives(ValueToAdd);
            break;
        }

        Destroy(gameObject);
    }
Ejemplo n.º 10
0
    public IEnumerator RespawnPlayerCo()
    {
        //Creates death particle
        Instantiate(DeathParticle, Pc2.transform.position, Pc2.transform.rotation);
        //hide player
        //Player.enable = false;
        Pc2.SetActive(false);
        //Pc.GetComponent<Renderer>() .enabled = false;
        LifeCount.RemovePoints(PointsToRemove);
        // Gravity reset
        StoreGravity = Pc2.GetComponent <Rigidbody2D>().gravityScale;
        Pc2.GetComponent <Rigidbody2D>().gravityScale = 0f;
        Pc2.GetComponent <Rigidbody2D>().velocity     = Vector2.zero;
        //point penalty
        ScoreManager.AddPoints(-DeathPenalty);
        //Debug Penailty
        Debug.Log("Player Respawn");
        yield return(new WaitForSeconds(RespawnDelay));

        Pc2.GetComponent <Rigidbody2D>().gravityScale = StoreGravity;
        Pc2.transform.position = CurrentCheckPoint.transform.position;
        Pc2.SetActive(true);
        //Pc.GetComponent<Renderer>() .enabled = true;
        Instantiate(RespawnParticle, CurrentCheckPoint.transform.position, CurrentCheckPoint.transform.rotation);
    }
Ejemplo n.º 11
0
    public void AttemptMove(int xDir, int yDir)
    {
        if (Time.timeScale == 1)
        {
            Vector2      end = rb2D.position + new Vector2(xDir, yDir);
            RaycastHit2D fogDetect;
            RaycastHit2D walldetect;

            fogDetect  = Physics2D.Linecast(rb2D.position, end, fog);
            walldetect = Physics2D.Linecast(rb2D.position, end, wall); //nekeisti

            WorldPos pos = EditTerrain.GetBlockPos(fogDetect);
            //Debug.Log(pos.x + " " + pos.y);

            if (fogDetect)
            {
                fogWorld.SetTile(pos.x, pos.y, new GridTile(GridTile.TileTypes.Empty));
                scoreManager.AddPoints(1);
            }
            //if (fogDetect)
            //{
            //    GameObject.Find(fogDetect.transform.name).GetComponent<SpriteRenderer>().enabled = false;
            //    print(fogDetect.transform.name);
            //    GameObject.Find(fogDetect.transform.name).GetComponent<BoxCollider2D>().enabled = false;
            //    Destroy(GameObject.Find(fogDetect.transform.name).GetComponent<GameObject>());
            //}
            if (!walldetect && !fogDetect)
            {
                gameSounds.PlaySound(rnd.Next(0, 2));
                rb2D.MovePosition(end);
            }
        }
        StartCoroutine(Delay());
    }
Ejemplo n.º 12
0
    public IEnumerator RespawnPlayerCo()
    {
        Instantiate(deathFX, player.transform.position, player.transform.rotation);
        player.enabled = false;
        player.GetComponent <Renderer>().enabled = false;

        camCtrl.isFollowing = false;

        // gravityStore = player.GetComponent<Rigidbody2D>().gravityScale;

        //player.GetComponent<Rigidbody2D>().gravityScale = 0f;
        //player.GetComponent<Rigidbody2D>().velocity = Vector2.zero;
        ScoreManager.AddPoints(-pointsPenaltyOnDeath);

        Debug.Log("Player Respawned");

        yield return(new WaitForSeconds(respawnDelay));

        //player.GetComponent<Rigidbody2D>().gravityScale = gravityStore;
        player.transform.position = currentCheckpoint.transform.position;
        player.knockBackCount     = 0;
        player.enabled            = true;
        player.GetComponent <Renderer>().enabled = true;

        healthManager.FullHealth();
        healthManager.isDead = false;

        camCtrl.isFollowing = true;
        Instantiate(respawnFX, currentCheckpoint.transform.position, currentCheckpoint.transform.rotation);
    }
Ejemplo n.º 13
0
    public IEnumerator RespawnPlayerCo()
    {
        //Generate Death Particle
        Instantiate(DeathParticle, Dude.transform.position, Dude.transform.rotation);
        //Hide Dude
        //PC.enabled = False;
        Dude2.SetActive(false);
        animator.SetBool("isDead", true);
        Dude.GetComponent <Renderer> ().enabled = false;
        //Gravity Reset
        GravityStore = Dude.GetComponent <Rigidbody2D>().gravityScale;
        Dude.GetComponent <Rigidbody2D>().gravityScale = 0f;
        Dude.GetComponent <Rigidbody2D>().velocity     = Vector2.zero;
        //point Penalty
        ScoreManager.AddPoints(-PointPenaltyOnDeath);
        //Debug message
        Debug.Log("Dude Respawn");
        //Respawn Delay
        yield return(new WaitForSeconds(RespawnDelay));

        //Gravity Restore
        Dude.GetComponent <Rigidbody2D>().gravityScale = GravityStore;
        //Match Dudes transform position
        Dude.transform.position = CurrentCheckPoint.transform.position;
        //Show dude
        //Dude.enabled = true;
        Dude2.SetActive(true);
        //Dude.GetComponent<Renderer> ().enabled = true;
        //Spawn Dude
        Instantiate(RespawnParticle, CurrentCheckPoint.transform.position, CurrentCheckPoint.transform.rotation);
        animator.SetBool("isDead", false);
    }
Ejemplo n.º 14
0
    //coroutine to generalize subroutinens
    //this method controls what happens during and after player death

    public IEnumerator RespawnPlayerCo()
    {
        Instantiate(dParticle, player.transform.position, player.transform.rotation);

        player.enabled = false;

        player.GetComponent <Renderer>().enabled          = false;
        player.GetComponent <Rigidbody2D> ().gravityScale = 0f;

        player.GetComponent <Rigidbody2D> ().velocity = Vector2.zero;

        ScoreManager.AddPoints(-pointPenatlyOnDeath);

        yield return(new WaitForSeconds(respawnTime));

        player.GetComponent <Rigidbody2D> ().gravityScale = 5;

        player.transform.position = currentCheckPoint.transform.position;

        player.enabled = true;

        player.GetComponent <Renderer>().enabled = true;
        healthManager.FullHealth();
        healthManager.isDead = false;

        Instantiate(lParticle, currentCheckPoint.transform.position, currentCheckPoint.transform.rotation);
    }
    // Destroy the projectile and the enemy when it enters the trigger area of an enemy
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Enemy")
        {
            Instantiate(EnemyDeath, other.transform.position, other.transform.rotation);
            // Drop some loot at random. Loot is weighted: Ammo has highest chance, then Health, then no loot drop, then Lives.
            switch (Random.Range(0, 11))
            {
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
                Instantiate(AmmoPickup, other.transform.position, other.transform.rotation);
                break;

            case 5:
            case 6:
            case 7:
            case 8:
                Instantiate(HealthPickup, other.transform.position, other.transform.rotation);
                break;

            case 9:
                Instantiate(LifePickup, other.transform.position, other.transform.rotation);
                break;
            }
            Destroy(other.gameObject);
            ScoreManager.AddPoints(PointsForKill);
            Destroy(gameObject);
        }

        Destroy(gameObject, 10);
    }
 // Update is called once per frame
 void Update()
 {
     if (enemyHealth <= 0)
     {
         if (!enemyKilled)
         {
             ScoreManager.AddPoints(pointsOnDeath);
         }
         if (gameObject.name == "Boss")
         {
             Instantiate(bossParticle, gameObject.transform.position, gameObject.transform.rotation);
             var exitTrigger = GameObject.FindGameObjectWithTag("ExitLevel");
             exitTrigger.GetComponent <BoxCollider2D>().enabled = true;
         }
         enemyKilled = true;
         GetComponent <Animator>().SetTrigger("Death");
         gameObject.GetComponent <EnemyPatrol>().enabled   = false;
         gameObject.GetComponent <BoxCollider2D>().enabled = false;
         if (gameObject.GetComponent <ThrowStarAtPlayer>() != null)
         {
             gameObject.GetComponent <ThrowStarAtPlayer>().enabled = false;
         }
         attackCollider.enabled = false;
         gameObject.GetComponent <Rigidbody2D>().gravityScale = 0f;
         gameObject.GetComponent <Rigidbody2D>().velocity     = new Vector2(0, 0);
         Destroy(gameObject, GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).length + delay);
     }
 }
Ejemplo n.º 17
0
    private void Connect(Connector connector)
    {
        player.transform.position = connector.transform.position;

        string soundFullPath = Application.dataPath + "/" + connector.ConnectorDef.RelativeSoundPath;

        if (File.Exists(soundFullPath))
        {
            WWW audioLoader = new WWW("file://" + soundFullPath);
            while (!audioLoader.isDone)
            {
            }

            audioLoader.GetAudioClip().Play(Random.Range(0, 10));
        }

        if (connector.ConnectorDef.IsBad)
        {
            GameOver();
            return;
        }

        if (!currentConnector.Connectors.Contains(connector))
        {
            ScoreManager.AddPoints(1);

            currentConnector.Connectors.Add(connector);

            var connection = ConnectionPool.GetConnection(currentConnector, connector);
            ConnectionList.Add(connection);
        }

        currentConnector = connector;
    }
Ejemplo n.º 18
0
    // Update is called once per frame
    void Update()
    {
        if (enemyHealth <= 0)
        {
            Instantiate(deathEffect, transform.position, transform.rotation);
            ScoreManager.AddPoints(pointsOnDeath);

            if (transform.localScale.y > minSize)
            {
                GameObject clone1 = Instantiate(bossPrefab, new Vector3(transform.position.x + 0.5f, transform.position.y, transform.position.z), transform.rotation) as GameObject;
                GameObject clone2 = Instantiate(bossPrefab, new Vector3(transform.position.x - 0.5f, transform.position.y, transform.position.z), transform.rotation) as GameObject;

                clone1.transform.localScale = new Vector3(transform.localScale.y * 0.5f, transform.localScale.y * 0.5f, transform.localScale.z);
                clone2.transform.localScale = new Vector3(transform.localScale.y * 0.5f, transform.localScale.y * 0.5f, transform.localScale.z);


                //full health on each clone
                clone1.GetComponent <BossHealthManager>().enemyHealth = 10;
                clone2.GetComponent <BossHealthManager>().enemyHealth = 10;
            }



            Destroy(gameObject);
        }
    }
Ejemplo n.º 19
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.GetComponent <PlayerController> () != null)
        {
            if (!isEquipment && !isHpRegen)
            {
                ScoreManager.AddPoints(pointsToAdd);
            }

            if (isEquipment)
            {
                eq.AddItem();
                door.isOpened = true;
                door.Open();
            }

            if (isHpRegen)
            {
                HealthManager.playerHp++;
            }

            if (isLifeUp)
            {
                life.GiveLife();
            }

            pickedItemSoundEffect.Play();
            Destroy(gameObject);
        }
    }
Ejemplo n.º 20
0
    void Update()
    {
        float step = speed * Time.deltaTime;                                        // how much it moves each frame

        transform.position = Vector3.MoveTowards(transform.position, target, step); //the position of the claw
        lineRenderer.SetPosition(0, origin.position);                               //draw the line renderer from origin
        lineRenderer.SetPosition(1, transform.position);                            //to the position of the claw

        if (!retracting)
        {
            m_Collider.enabled = true;
        }


        if (transform.position == origin.position && retracting)
        {
            Hook.CollectedObject();
            if (hitFish)
            {
                scoreManager.AddPoints(fishValue);
                hitFish = false;
            }
            Destroy(childObject);
            gameObject.SetActive(false);
            retracting = false;
        }
    }
Ejemplo n.º 21
0
    public IEnumerator RespawnPlayerCo()
    {
        ScoreManager.AddPoints(-PointPenaltyOnDeath);
        Instantiate(DeathParticle, Player.transform.position, Player.transform.rotation);
        Player.GetComponent <Rigidbody2D>().bodyType  = RigidbodyType2D.Static;
        Player.GetComponent <BoxCollider2D>().enabled = false;
        Player.GetComponent <Renderer>().enabled      = false;
        yield return(new WaitForSeconds(RespawnDelay));

        if (LivesManager.LivesCounter > 0)
        {
            Health_Manager.FullHealth();
            HealthManager.IsDead      = false;
            Player.KnockBackTimer     = 0;
            Player.transform.position = CheckPoint.transform.position;
            Instantiate(RespawnParticle, CheckPoint.transform.position, CheckPoint.transform.rotation);
            Player.GetComponent <Rigidbody2D>().bodyType  = RigidbodyType2D.Dynamic;
            Player.GetComponent <BoxCollider2D>().enabled = true;
            Player.GetComponent <Renderer>().enabled      = true;
            HealthManager.PauseMenu.gameObject.SetActive(true);
        }
        else if (LivesManager.LivesCounter == 0)
        {
            HealthManager.IsDead = false;
            SceneManager.LoadScene("Game_Over");
        } //if
    }     //public void RespawnPlayer
Ejemplo n.º 22
0
    // Update is called once per frame
    void Update()
    {
        lifetime += Time.deltaTime;

        if (playerProximity < sightRange)
        {
            transform.LookAt(target);
            target = GameObject.FindWithTag("Player").transform;
        }


        target = GameObject.FindWithTag("Player").transform;

        enemyCooldown += Time.deltaTime;

        //measures the object's distance from player
        playerProximity = Vector3.Distance(target.position, transform.position);
        if (playerProximity > enemyRange && playerProximity < sightRange)
        {
            transform.Translate(Vector3.forward * moveSpeed * Time.deltaTime);
        }
        if (enemyHealth < 1)
        {
            Destroy(gameObject);
            ScoreManager.AddPoints(pointsToAdd);
        }


        if (playerProximity > 100)
        {
            Destroy(gameObject);
        }
    }
Ejemplo n.º 23
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.name == "Player")
        {
            if (waitForAnotherHit < 0)
            {
                hittedPlayer = true;
                ScoreManager.AddPoints(-pointPenalty);
                HealthManager.HurtPlayer(damageToGive);
                //playercontroler.HurtCollider(cośtam);
                hittedPlayer      = false;
                waitForAnotherHit = waitSetting;
            }
            other.GetComponent <AudioSource>().Play();

            var player = other.GetComponent <PlayerController> ();

            player.hitted = true;

            player.knockbackCount = player.knockbackLength;

            if (other.transform.position.x < transform.position.x)
            {
                player.knockFromRight = true;
            }
            else
            {
                player.knockFromRight = false;
            }
        }
    }
Ejemplo n.º 24
0
    public IEnumerator RespawnPlayerCo()
    {
        Instantiate(deathParticle, player.transform.position, player.transform.rotation);
        player.enabled = false;
        player.GetComponent <Renderer> ().enabled = false;
        gravityStore = player.GetComponent <Rigidbody2D> ().gravityScale;
        player.GetComponent <Rigidbody2D> ().gravityScale = 0f;
        player.GetComponent <Rigidbody2D> ().velocity     = Vector2.zero;
        ScoreManager.AddPoints(-pointPenaltyOnDeath);
        Debug.Log("Player Respawn");
        yield return(new WaitForSeconds(respawnDelay));

        player.GetComponent <Rigidbody2D> ().gravityScale = gravityStore;
        player.transform.position = currentCheckpoint.transform.position;
        if (FindObjectOfType <Camera2DFollow>() != null)
        {
            FindObjectOfType <Camera2DFollow> ().target = player.gameObject.transform;
        }
        Instantiate(respawnParticle, currentCheckpoint.transform.position, currentCheckpoint.transform.rotation);
        player.enabled          = true;
        player.transform.parent = null;
        player.GetComponent <Renderer> ().enabled = true;
        healthManager.FullHealth();
        //if (FindObjectOfType<AdsOnLvl> ())
        //{
        //	FindObjectOfType<AdsOnLvl> ().deaths++;
        //}
        healthManager.isDead = false;
    }
Ejemplo n.º 25
0
    public IEnumerator RespawnPlayerCo()
    {
        //Generate Death Particle
        Instantiate(deathParticle, pcRigid.transform.position, pcRigid.transform.rotation);
        //Hide PC
        player.SetActive(false);
        player.GetComponent <Renderer> ().enabled = false;
        // Gravity Reset
        gravityStore = pcRigid.GetComponent <Rigidbody2D>().gravityScale;
        pcRigid.GetComponent <Rigidbody2D>().gravityScale = 0f;
        pcRigid.GetComponent <Rigidbody2D>().velocity     = Vector2.zero;
        // Point Penalty
        ScoreManager.AddPoints(-pointPenaltyOnDeath);
        //Debug Message
        Debug.Log("PC Respawn");
        //Respawn Delay
        yield return(new WaitForSeconds(respawnDelay));

        //Gravity Restore
        pcRigid.GetComponent <Rigidbody2D>().gravityScale = gravityStore;
        //Match PCs transform position
        pcRigid.transform.position = currentCheckPoint.transform.position;
        //Show PC
        player.SetActive(true);
        player.GetComponent <Renderer> ().enabled = true;
        //Spawn PC
        Instantiate(respawnParticle, currentCheckPoint.transform.position, currentCheckPoint.transform.rotation);
    }
Ejemplo n.º 26
0
    public IEnumerator RespawnPlayerCo()
    {
        // Generate death particle
        Instantiate(DeathParticle, PC.transform.position, PC.transform.rotation);
        //hide pc
        // PC.enabled = false;
        PC2.SetActive(false);
        PC.GetComponent <Renderer> ().enabled = false;
        // gravity reset
        GravityStore = PC.GetComponent <Rigidbody2D>().gravityScale;
        PC.GetComponent <Rigidbody2D>().gravityScale = 0f;
        PC.GetComponent <Rigidbody2D>().velocity     = Vector2.zero;
        //point penalty
        ScoreManager.AddPoints(-PointPenaltyOnDeath);
        //debug message
        Debug.Log("PC Respawn");
        //respawn delay
        yield return(new WaitForSeconds(RespawnDelay));

        //gravity restore
        PC.GetComponent <Rigidbody2D>().gravityScale = GravityStore;
        //match pcs transform position
        PC.transform.position = CurrentCheckPoint.transform.position;
        //show pc
        //PC.enabled = true;
        PC2.SetActive(true);
        PC.GetComponent <Renderer> ().enabled = true;
        //Spawn PC
        Instantiate(RespawnParticle, CurrentCheckPoint.transform.position, CurrentCheckPoint.transform.rotation);
    }
Ejemplo n.º 27
0
 public void CollectChest()
 {
     Instantiate(chestCollectParticle, player.transform.position, player.transform.rotation);
     GetComponent <AudioSource>().clip = audioClips[0];
     GetComponent <AudioSource>().Play();
     ScoreManager.AddPoints(100);
 }
Ejemplo n.º 28
0
    public IEnumerator RespawnPlayerCo()
    {
        // Generate death particle
        Instantiate(deathParticle, PC.transform.position, PC.transform.rotation);
        // Hide Player
        //PC.enabled = false;
        PC.GetComponent <Renderer>().enabled = false;
        //Gravity Reset
        gravityStore = PC.GetComponent <Rigidbody2D>().gravityScale;
        PC.GetComponent <Rigidbody2D>().gravityScale = 0f;
        PC.GetComponent <Rigidbody2D>().velocity     = Vector2.zero;
        //point penalty
        ScoreManager.AddPoints(-PointPenaltyOnDeath);
        //Debug message
        Debug.Log("Player Respawn");
        //respawn delay
        yield return(new WaitForSeconds(respawnDelay));

        //gravity restore
        PC.GetComponent <Rigidbody2D>().gravityScale = gravityStore;
        //match players transform position
        PC.transform.position = currentCheckPoint.transform.position;
        //show player
        //PC.enabled = true;
        PC.GetComponent <Renderer>().enabled = true;
        //spawn player
        Instantiate(respawnParticle, currentCheckPoint.transform.position, currentCheckPoint.transform.rotation);
    }
Ejemplo n.º 29
0
    public IEnumerator RespawnPlayerCo()
    {
        //Generate Death Particle
        Instantiate(DeathParticle, Player.transform.position, Player.transform.rotation);
        //Hide Player
        //Player.enabled = false;
        Player.GetComponent <Renderer> ().enabled = false;
        PC2.SetActive(false);
        //Gravity Reset
        GravityStore = Player.GetComponent <Rigidbody2D>().gravityScale;
        Player.GetComponent <Rigidbody2D>().gravityScale = 0f;
        Player.GetComponent <Rigidbody2D>().velocity     = Vector2.zero;
        //Point Penalty
        ScoreManager.AddPoints(-PointPenaltyOnDeath);
        //Debug Message
        Debug.Log("Player Respawn");
        //Respawn Delay
        yield return(new WaitForSeconds(RespawnDelay));

        //Gravity Restore
        Player.GetComponent <Rigidbody2D>().gravityScale = GravityStore;
        //Match Players transform position
        Player.transform.position = CurrentCheckPoint.transform.position;
        //Show Player
        //Player.enabled = true;
        PC2.SetActive(true);
        Player.GetComponent <Renderer> ().enabled = true;
        //Spawn Particle
        Instantiate(RespawnParticle, CurrentCheckPoint.transform.position, CurrentCheckPoint.transform.rotation);
    }
Ejemplo n.º 30
0
    void Update()
    {
        if (EnemyCurrentHealth <= 0)
        {
            EnemyAudio.PlayOneShot(EnemyDeathSound);

            Destroy(gameObject);

            RandomDrop = Random.Range(1, 4);

            if (RandomDrop == 1)
            {
                Instantiate(drop, transform.position, transform.rotation);
            }

            else if (RandomDrop == 2)
            {
                Instantiate(drop2, transform.position, transform.rotation);
            }

            Debug.Log("RAND: " + RandomDrop);

            ScoreManager.AddPoints(pointstoadd);
        }
    }