Exemplo n.º 1
0
    void OnTriggerEnter2D(Collider2D other)
    {
        //if touch food, delete food
        if (other.name.Equals("food(Clone)"))
        {
            ate = true;
            Destroy(other.gameObject);
            gc.AddScore();
        }
        else if (other.name.Equals("power(Clone)"))
        {
            ate = true;
            Destroy(other.gameObject);
            Shrink();
            gc.AddScore();
        }
        else if (other.tag == "border")
        {
            //check life
            isAlive = gc.LifeText();
            if (isAlive == false)
            {
                Destroy(gameObject);
                gc.GameOverText();
                GameObject[] bodies = GameObject.FindGameObjectsWithTag("snakebody");
                foreach (GameObject body in bodies)
                {
                    Destroy(body);
                }
            }
            else
            {
                //destroy body
                GameObject[] bodies = GameObject.FindGameObjectsWithTag("snakebody");
                foreach (GameObject body in bodies)
                {
                    Destroy(body);
                }
                tail.Clear();

                //head at center
                gameObject.transform.position = new Vector2(0f, 0f);
            }
        }
    }
Exemplo n.º 2
0
    void OnTriggerStay(Collider col)
    {
        GameControl.AddScore(3000);
        AudioClip clip = SoundHandler.GetSnd(GameSnd.Pickup);

        PlayerCtrl.cam_snd.PlayOneShot(clip);
        PlayerCtrl.weap.EnableWeapon(weapid);
        Destroy(gameObject);
    }
Exemplo n.º 3
0
 // Use this for initialization
 void Start()
 {
     if (scoreSprites.Length > 0)
     {
         int indx = Random.Range(0, scoreSprites.Length);
         scoreRender.sprite = scoreSprites [indx];
     }
     Invoke("ScoreDestroy", timeToLife);
     gameControl.AddScore(scoreValue);
 }
Exemplo n.º 4
0
 public override void Damage()
 {
     StopAllCoroutines();
     enabled        = false;
     tran.position -= look_pos;
     GameControl.AddScore(100);
     SoundScript.CreateSound(tran, SoundHandler.GetSnd(GameSnd.Death));
     anims.Play("Death");
     StartCoroutine(DelayDestroy());
 }
Exemplo n.º 5
0
    IEnumerator SpawnTimer()
    {
        while (spawned < SPAWN_NUMBER)
        {
            yield return(new WaitForSeconds(1.0f));

            spawned++;
            GameControl.AddScore(2000);
            GameObject.Instantiate(pow, spawn_point.position, spawn_point.rotation);
        }
    }
Exemplo n.º 6
0
 public override void Damage()
 {
     //Prevent any movement when playing death animation
     StopAllCoroutines();
     enabled      = false;
     col.enabled  = false;
     rig.velocity = Vector3.zero;
     GameControl.AddScore(100);
     SoundScript.CreateSound(tran, SoundHandler.GetSnd(GameSnd.Death));
     anims.Play("Death");
     StartCoroutine(DelayDestroy());
 }
Exemplo n.º 7
0
 public override void Damage()
 {
     health -= 20;
     GameControl.AddScore(2000);
     if (health <= 0)
     {
         snd.Stop();
         col.enabled   = false;
         rotsc.enabled = true;
         dying         = true;
     }
 }
Exemplo n.º 8
0
    void OnTriggerEnter(Collider other)
    {
        GameControlScript.AddScore(goal);

        Debug.Log("OnTriggerEnter");
        audio.PlayOneShot(ExplotionAudio);
        Instantiate(ExplotionParticles, transform.position, transform.rotation);
        ExplotionParticles.particleEmitter.emit = true;
        renderer.enabled = false;

        Destroy(other.gameObject);
        Destroy(gameObject);
    }
Exemplo n.º 9
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.name.Equals("Rock(Clone)"))
     {
         audioControl.SmallExplosion();
         collide = true;
         animator.Play("ExplodeBullet");
         Destroy(other.gameObject);
     }
     if (other.gameObject.name.Equals("Monster(Clone)"))
     {
         audioControl.SmallExplosion();
         collide = true;
         animator.Play("ExplodeBullet");
         Destroy(other.gameObject);
         gameControl.AddScore();
     }
 }
Exemplo n.º 10
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "boundary")
        {
            return;
        }
        Instantiate(explosion, other.transform.position, other.transform.rotation);

        if (other.tag == "Player")
        {
            Instantiate(playerEx, other.transform.position, other.transform.rotation);
            gameCunt.gameover();
        }

        gameCunt.AddScore(scoreValue);
        Destroy(other.gameObject);
        Destroy(gameObject);
    }
Exemplo n.º 11
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Boundary" || other.tag == "Enemy") //(other.CompareTag("Boundary") || other.CompareTag("Enemy"))
        {
            return;
        }
        if (explosion != null)
        {
            Instantiate(explosion, transform.position, transform.rotation);
            //Destroy(gameObject);
        }

        if (other.tag == "Player")
        {
            Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
            //Destroy(gameObject);
            gameControl.GameOver();
        }
        gameControl.AddScore(scoreValue);
        Destroy(other.gameObject);
        Destroy(gameObject);
    }
Exemplo n.º 12
0
    }// End Start()

    // Enemy will be destroyed on impact with missile
    void OnCollisionEnter2D(Collision2D coll)
    {
        // If there's a collision with an object that has the tag goodMissile
        if (coll.gameObject.tag == "goodMissile")
        {
            // When enemy is hit and destroyed add the points to the enemy score
            gc.AddScore(enemyScore);

            // If hit by missile destroy object
            Destroy(this.gameObject);

            // Clone the explosion object at the position where the enemy is hit with the missile
            GameObject cloneExplosion = (GameObject)Instantiate(explosion, transform.position, Quaternion.identity);

            // Destroy the explosion after half a second
            Destroy(cloneExplosion, 0.05f);

            if (enemyDeathSound)
            {
                // Play audio clip at the postiton the object is destroyed
                AudioSource.PlayClipAtPoint(enemyDeathSound, transform.position);
            } // End nested if
        }     // End outer if
    }         // End OnCollisionEnter2D
Exemplo n.º 13
0
    void OnTriggerEnter2D(Collider2D coll)
    {
        // Food?
        if (coll.gameObject.tag.Equals("Apple"))
        {
            // Get longer in next Move call
            ate = true;
            // Remove the Food
            Destroy(coll.gameObject);
            gc.AddScore(score_apple * mult_score);
        }
        // Collided with meat
        else if (coll.gameObject.tag.Equals("Meat"))
        {
            // Remove the Meat
            Destroy(coll.gameObject);
            gc.AddScore(score_meat * mult_score);
        }
        // Collided with medicine
        else if (coll.gameObject.tag.Equals("Medicine"))
        {
            // Remove the Medicine
            Destroy(coll.gameObject);
            foreach (GameObject go in GameObject.FindGameObjectsWithTag("Virus"))
            {
                Destroy(go);
            }
        }
        // Collided with Tail or Virus
        else if (coll.gameObject.tag.Equals("Virus") || coll.gameObject.tag.Equals("Tail"))
        {
            // Destroy Snake?
            // Destroy(this.gameObject);
            if (!gc.PlayerDie())
            {
                transform.position = originalPos;
            }
            // ToDo 'You lose' screen
        }
        // Collided with rune
        else if (coll.gameObject.tag.Equals("Rune"))
        {
            // Remove the rune
            Destroy(coll.gameObject);
            rune_duration_temp = rune_duration;
            int temp;
            if (Random.Range(1, 100) % 2 == 0)
            {
                temp = double_rune_mult;
            }
            else
            {
                temp = triple_rune_mult;
            }

            string runeEffect;
            if (Random.Range(1, 100) % 2 == 0)
            {
                act_rune[0] = 1;
                act_rune[1] = temp + 1;
                runeEffect  = "Speed X" + temp;
                mult_speed *= temp + 1;
            }
            else
            {
                act_rune[0] = 2;
                act_rune[1] = temp;
                runeEffect  = "Score X" + temp;
                mult_score *= temp;
            }

            gc.ShowRuneEffect(runeEffect);
            gc.AddScore(score_rune * mult_score);
        }
        // Collided with WormHole
        else if (coll.gameObject.tag.Equals("WormHole"))
        {
            float loc_y = transform.position.y, loc_x = transform.position.x;
            foreach (GameObject go in GameObject.FindGameObjectsWithTag("WormHole"))
            {
                if (go != coll.gameObject)
                {
                    loc_x = go.gameObject.transform.position.x;
                    loc_y = go.gameObject.transform.position.y;
                }
            }
            transform.position = new Vector3((loc_x + 2 * dir[0]), (loc_y + 2 * dir[1]), -1f);
        }
        // Collided with Potion
        else if (coll.gameObject.tag.Equals("Potion"))
        {
            // Remove the Potion
            Destroy(coll.gameObject);
            gc.AddLife();
        }
    }
Exemplo n.º 14
0
 void OnCollisionEnter2D(Collision2D other)
 {
     Destroy(other.gameObject);
     gameController.AddScore();
     Destroy(gameObject);
 }
 private void OnCollisionEnter2D(Collision2D collision)
 {
     Destroy(collision.gameObject);
     gameControl.AddScore();
     Destroy(gameObject);
 }
Exemplo n.º 16
0
 void OnTriggerStay(Collider col)
 {
     if (col.gameObject.layer != 8)
     {
         return;
     }
     //
     GameControl.AddScore(score);
     //
     if (win)
     {
         Application.LoadLevel((int)GameControl.GameLevels.End);
         return;
     }
     //
     if (knife && WeapHandler.weapid != 0)
     {
         return;
     }
     //
     if (dest_obj != null)
     {
         Destroy(dest_obj);
     }
     SetState(this, false);
     //
     if (req_stat != GameControl.GameProg.None &&
         req_stat != GameControl.GlobalProg)
     {
         Application.LoadLevel((int)GameControl.GameLevels.GameO);
         return;
     }
     if (req_stat == GameControl.GameProg.PowRes)
     {
         PlayerCtrl.weap.EnableWeapon(5);
     }
     else if (set_stat == GameControl.GameProg.PrisonOpen)
     {
         EnemySpawner.DisableSpawn();
         GameControl.inst.playerp_sc.locked     = true;
         GameControl.inst.playerp_sc.needtomove = true;
     }
     GameControl.GlobalProg = set_stat;
     //
     if (sound != GameSnd.None)
     {
         AudioClip clip = SoundHandler.GetSnd(sound);
         if (pausemus)
         {
             PlayerCtrl.cam_snd.Pause();
             StartCoroutine(ResumeMusic(clip.length));
         }
         PlayerCtrl.cam_snd.PlayOneShot(clip);
     }
     //
     if (sc_enable != null)
     {
         SetState(sc_enable, true);
     }
     if (sc_enable2 != null)
     {
         SetState(sc_enable2, true);
     }
     //
     if (sw_control)
     {
         GameControl.RestoreEnergy();
         if (sw_player)
         {
             GameControl.SetEnergyDrain(0);
             EnemySpawner.EnableSpawn();
         }
         else
         {
             EnemySpawner.DisableSpawn();
         }
         GameControl.RestoreEnergy();
         GameControl.inst.SwitchControl(sw_player, tr_player);
         if (tr_player != null)
         {
             Transform helitr = GameControl.inst.playerh_tr;
             helitr.position = tr_heli.position;
             helitr.GetComponent <PlayerCtrl>().axis_help.rotation = tr_heli.rotation;
             GameControl.inst.playerp_tr.position = tr_player.position;
         }
         else
         {
             GameControl.inst.playerp_tr.position = new Vector3(0, 0, -500);
         }
     }
     //
     if (brief_text != string.Empty)
     {
         BriefHud.inst.LoadBrief(brief_text, brief_mus, drain_lvl);
     }
 }
Exemplo n.º 17
0
    //Floodfill from single point, if flood fill >= 3 then set them all to visited and also destroy them
    void FloodFill(int x, int y, ref bool [] visited)
    {
        //Debug.Log ("flooding");
        Color      myColor = gridArray [x + y * width * 3].GetColor();
        List <int> indexes = new List <int> ();
        List <int> queue   = new List <int> ();

        queue.Add(x + y * width * 3);
        indexes.Add(x + y * width * 3);
        int curIndex = 0;

        while (queue.Count > 0)
        {
            curIndex = queue [0];
            queue.RemoveAt(0);

            if (curIndex % (width * 3) != 0 && !visited [curIndex - 1] && gridArray [curIndex - 1].GetColor() == myColor)
            {
                queue.Add(curIndex - 1);
                indexes.Add(curIndex - 1);
            }
            if ((curIndex - width + 1) % (width * 3) != 0 && !visited [curIndex + 1] && gridArray [curIndex + 1].GetColor() == myColor)
            {
                queue.Add(curIndex + 1);
                indexes.Add(curIndex + 1);
            }
            if (curIndex >= width * 3 && !visited [curIndex - width * 3] && gridArray [curIndex - width * 3].GetColor() == myColor)
            {
                queue.Add(curIndex - width * 3);
                indexes.Add(curIndex - width * 3);
            }
            if (curIndex < (width - 1) * width * 3 && !visited [curIndex + width * 3] && gridArray [curIndex + width * 3].GetColor() == myColor)
            {
                queue.Add(curIndex + width * 3);
                indexes.Add(curIndex + width * 3);
            }
            if (indexes.Count > 50)
            {
                Debug.Log("that's no good");
                break;
            }
            visited [curIndex] = true;
        }
        //redetect = true;
        if (indexes.Count > 1)
        {
            for (int i = 0; i < indexes.Count; i++)
            {
                if (indexes.Count > 2)
                {
                    gameController.AddScore(indexes.Count, iteration);
                    //Add to score based on number of boxes

                    gridArray [indexes [i]].Dissolve();
                    AddDestroyedPoint(indexes [i]);
                    for (int xx = 0; xx < 3; xx++)
                    {
                        for (int yy = 0; yy < 3; yy++)
                        {
                            gridArray [indexes [i] + xx * width + yy * width * 3 * width].Dissolve();
                        }
                    }
                }
            }
        }
        indexes.Clear();
    }
Exemplo n.º 18
0
 void Update()
 {
     if (locked)
     {
         return;
     }
     if (Input.GetButtonDown("Weap"))
     {
         weap.ChangeWeapon();
     }
     else if (Input.GetButtonDown("Cam"))
     {
         cam1.enabled = !(cam2.enabled = cam1.enabled);
     }
     else if (Input.GetButtonDown("Fire") && weap.CanFire(player))
     {
         weap.CreateProj(proj_point, player, audio);
     }
     if (devmode)
     {
         if (Input.GetKey(KeyCode.Backspace))
         {
             if (Input.GetKeyDown(KeyCode.F1))
             {
                 GameControl.TeleportPlayer(0);
             }
             else if (Input.GetKeyDown(KeyCode.F2))
             {
                 GameControl.TeleportPlayer(1);
             }
             else if (Input.GetKeyDown(KeyCode.F3))
             {
                 GameControl.TeleportPlayer(2);
             }
             else if (Input.GetKeyDown(KeyCode.F4))
             {
                 GameControl.TeleportPlayer(3);
             }
             else if (Input.GetKeyDown(KeyCode.F5))
             {
                 GameControl.TeleportPlayer(4);
             }
             else if (Input.GetKeyDown(KeyCode.F6))
             {
                 GameControl.TeleportPlayer(5);
             }
             else if (Input.GetKeyDown(KeyCode.F9))
             {
                 GameControl.AddScore(1000);
             }
             else if (Input.GetKeyDown(KeyCode.F10))
             {
                 GameControl.AddScore(10000);
             }
             else if (Input.GetKeyDown(KeyCode.F11))
             {
                 GameControl.RestoreEnergy();
             }
             else if (Input.GetKeyDown(KeyCode.F12))
             {
                 GameControl.Damage(10);
             }
         }
     }
     else
     {
         if (Input.GetKey(KeyCode.Backspace) &&
             Input.GetKey(KeyCode.D) && Input.GetKey(KeyCode.E) && Input.GetKeyDown(KeyCode.V))
         {
             devmode = true;
             snd.PlayOneShot(SoundHandler.GetSnd(GameSnd.Pickup));
         }
     }
 }