void OnTriggerEnter2D(Collider2D col)
 {
     if (col.CompareTag("Player"))
     {
         playe.Damage(100);
     }
 }
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Player")
        {
            player player = other.transform.GetComponent <player>();
            if (player != null)
            {
                player.Damage();
            }
            enemy_anim.SetTrigger("ondeath");
            _speed = 0f;
            enemysound.Play();
            Destroy(gameObject, 1.5f);
        }

        else if (other.tag == "laser")
        {
            Destroy(other.gameObject);
            _player.ScoreUpadte();
            enemy_anim.SetTrigger("ondeath");
            _speed = 1f;
            enemysound.Play();
            Destroy(this.GetComponent <Collider2D>());
            Destroy(this.gameObject, 1.5f);
        }
    }
 void OnTriggerEnter2D(Collider2D col)
 {
     if (col.CompareTag("PlayerFeet"))
     {
         player.Damage(2);
         StartCoroutine(player.KnockBack(0.02f, 350, player.transform.position));
     }
 }
Exemple #4
0
    // Update is called once per frame

    private void OnTriggerEnter2D(Collider2D col)
    {
        if (col.CompareTag("Player"))
        {
            player.Damage(1);

            StartCoroutine(player.Knockback(0.02f, 50, player.transform.position));
        }
    }
    // Called when trigger collides with another collider
    void OnTriggerStay2D(Collider2D other)

    {
        // attempting to get the player script from what Goomba collides with.
        player playerscript = other.GetComponent <player>();

        // if player script exists
        if (playerscript != null)
        {
            playerscript.Damage(damage);
            Debug.Log("Goomba dealt damage to player =" + damage);
        }
    }     // end onTriggerEnter2D
Exemple #6
0
    //called  when trigger collides with anouther collider
    void OnTriggerStay2D(Collider2D other)
    {
        //attempting to get the player script from the colider
        player playerscript = other.GetComponent <player> ();

        //if the player script does collide
        if (playerscript != null)
        {
            // calling the damage function on the script then applying the damage
            playerscript.Damage(damage);

            Debug.Log("goomba dealt damage to player = " + damage);
        } //end if (playerscript != null)
    }     //end ontriggerenter2d()
Exemple #7
0
    //called when trigger collides with another collider
    void OnTriggerStay2D(Collider2D other)
    {
        //Attempting to get player script from the thing we collided with
        player playerScript = other.GetComponent <player> ();

        //if the player scrpt exists on thing collided with
        if (playerScript != null)
        {
            //call the damage function
            playerScript.Damage(damage);

            Debug.Log("Goomba Dealt damage to player = " + damage);
        } // end of if
    }     //end ontriggerenter2d()
Exemple #8
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Player")
        {
            player playerComponet = other.transform.GetComponent <player>();
            if (playerComponet != null)
            {
                playerComponet.Damage();
            }
            // trigger animation
            _enemy_Animator.SetTrigger("OnEnemyDeath");
            _speed = 2f;
            _audioSource.Play();

            Destroy(GetComponent <Collider2D>());
            Destroy(this.gameObject, 0.5f);
        }

        if (other.tag == "Bullet")
        {
            var     _randomNum = Random.Range(1, 100);
            float   _posX      = transform.position.x;
            Vector3 spwanPos   = new Vector3(Random.Range(-8, 8), 10, 0);
            player.score += 10;

            GameObject bullet = GameObject.FindGameObjectWithTag("Bullet");

            Destroy(bullet);

            // trigger animation
            _enemy_Animator.SetTrigger("OnEnemyDeath");
            _speed = 2f;
            _audioSource.Play();
            Destroy(this.gameObject, 2.5f);

            if (_randomNum > 95)
            {
                GameObject newPowerUp = Instantiate(powerups[0], spwanPos, Quaternion.identity);
            }
            else if (_randomNum > 70 && _randomNum < 80)
            {
                GameObject speedPowerup = Instantiate(powerups[1], spwanPos, Quaternion.identity);
            }
            else if (_randomNum < 5)
            {
                GameObject shieldPowerup = Instantiate(powerups[2], spwanPos, Quaternion.identity);
            }
        }
    }
Exemple #9
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "Laser")
     {
         Destroy(this.gameObject);
         Destroy(other.gameObject);
     }
     else if (other.tag == "Player")
     {
         player playerer = other.GetComponent <player>();
         if (playerer != null)
         {
             playerer.Damage();
         }
         Destroy(this.gameObject);
     }
 }
Exemple #10
0
 public void OnTriggerEnter2D(Collider2D other)
 {
     if (gameObject.transform.parent.tag == "Player" || gameObject.transform.parent.tag == "tripleshot")
     {
         return;
     }
     else
     {
         if (other.tag == "Player")
         {
             player player = other.GetComponent <player>();
             if (player != null)
             {
                 player.Damage();
             }
             Destroy(this.gameObject);
         }
     }
 }
Exemple #11
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        Debug.Log("Hit:  " + other.transform.name);

        //if other is player
        //destroy  the player
        //destroy us
        if (other.tag == "Player")
        {
            //damage player
            player player = other.transform.GetComponent <player>();
            //other.transform.GetComponent<Player>().Damage();
            if (player != null)
            {
                player.Damage();
            }
            _anim.SetTrigger("OnEnemyDeath");
            _speed = 0;
            _audioSource.Play();
            Destroy(this.gameObject, 2.3f);
        }
        //if other is laser
        //destroy the laser
        //DESTROY us

        if (other.tag == "Laser")
        {
            _audioSource.Play();
            Destroy(other.gameObject);
            //trigger anim

            if (_player != null)
            {
                _player.AddScore(10);
            }
            _anim.SetTrigger("OnEnemyDeath");
            _speed = 0;

            Destroy(GetComponent.Collider2D);
            Destroy(this.gameObject, 2.3f);
        }
    }
Exemple #12
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Player")
        {
            Destroy(this.gameObject);
            player player = other.transform.GetComponent <player>();

            if (player != null)
            {
                player.Damage();
            }
        }

        if (other.tag == "Laser")
        {
            Destroy(this.gameObject);
            if (_player != null)
            {
                _player.AddScore();
            }
            Destroy(other.gameObject);
        }
    }
Exemple #13
0
        static void Main(string[] args)
        {
           

            Console.WriteLine("Name your character: ");
            string characterNameOne = Console.ReadLine();
            Console.WriteLine("Name your second character: ");
            string characterNameTwo = Console.ReadLine();

            player playerOne = new player(characterNameOne);
            player playerTwo = new player(characterNameTwo);
            playerOne.SayHello();
            playerOne.ShowYourHP();
            playerTwo.SayHello();
            playerTwo.ShowYourHP();

            for(int i = 0; i < 3; i++)
            {
                playerOne.damage(playerTwo.Damage());
                playerTwo.damage(playerOne.Damage());
                playerOne.ShowYourHP();
                playerTwo.ShowYourHP();
            }
            if(playerOne.HP > playerTwo.HP)
            {
                Console.WriteLine(" ''NICE SHOT M8'' ,  player one");

            }else if(playerOne.HP < playerTwo.HP)
            {
                Console.WriteLine(" ''GOOD ONE'', player Two");
            }else
            {
                Console.WriteLine("BORING tie");
            }
           
            //Console.WriteLine($"Player one did {playerOne.Damage()} damage");
        }
Exemple #14
0
    // Use this for initialization
    void Start()
    {
        Debug.Log("Hello.Warld");

        int age;

        age = 30;
        Debug.Log(age);

        float height1 = 160.5f;
        int   height2;

        height2 = (int)height1;
        Debug.Log(height2);

        string name;

        name = "kitamura";
        Debug.Log(name);

        int answer;

        answer = 1 + 2;
        Debug.Log(answer);

        answer = 3 - 4;
        Debug.Log(answer);

        answer = 5 * 6;
        Debug.Log(answer);

        answer = 8 / 4;
        Debug.Log(answer);

        int n1 = 8, n2 = 9;

        answer = n1 + n2;
        Debug.Log(answer);

        answer  = 10;
        answer += 5;
        Debug.Log(answer);

        answer = 10;
        answer++;
        Debug.Log(answer);

        string str1 = "happy";
        string str2 = "birthday";
        string message;

        message = str1 + str2;
        Debug.Log(message);

        str1 += str2;
        Debug.Log(str1);

        string str = "happy";
        int    num = 123;

        message = str + num;
        Debug.Log(message);

        int hetbNum = 1;

        if (hetbNum == 1)
        {
            Debug.Log("HPが50回復");
        }

        int hp = 200;

        if (hp >= 100)
        {
            Debug.Log("攻撃!");
        }
        else
        {
            Debug.Log("防御!");
        }

        hp = 180;
        if (hp <= 50)
        {
            Debug.Log("逃走!");
        }
        else if (hp >= 200)
        {
            Debug.Log("攻撃!");
        }
        else
        {
            Debug.Log("防御!");
        }

        int x = 1;

        if (x == 1)
        {
            int y = 2;
            Debug.Log(x);
            Debug.Log(y);
        }
        //Debug.Log(y);

        for (int i = 0; i < 5; i++)
        {
            Debug.Log(i);
        }

        for (int i = 0; i < 10; i += 2)
        {
            Debug.Log(i);
        }

        for (int i = 3; i < 5; i++)
        {
            Debug.Log(i);
        }

        for (int i = 3; i >= 0; i--)
        {
            Debug.Log(i);
        }

        int sum = 0;

        for (int i = 0; i <= 10; i++)
        {
            sum += i;
        }
        Debug.Log(sum);

        //四回目

        int[] array = new int[5];

        array[0] = 2;
        array[1] = 10;
        array[2] = 5;
        array[3] = 16;
        array[4] = 3;

        for (int i = 0; i < 5; i++)
        {
            Debug.Log(array[i]);
        }

        int[] points = { 83, 99, 52, 93, 15 };

        for (int i = 0; i < points.Length; i++)
        {
            if (points[i] >= 90)
            {
                Debug.Log(points[i]);
            }
        }

        SayHello();

        CallName("Tom");

        answer = Add(2, 3);

        Debug.Log(answer);

        player myPlayer = new player();

        myPlayer.Attack();
        myPlayer.Damage(30);

        Vector2 playerPos = new Vector2(3.0f, 4.0f);

        playerPos.x += 8.0f;
        playerPos.y += 5.0f;
        Debug.Log(playerPos);

        Vector2 startPos = new Vector2(2.0f, 1.0f);
        Vector2 endPos   = new Vector2(8.0f, 5.0f);
        Vector2 dir      = endPos - startPos;

        float len = dir.magnitude;

        Debug.Log(len);
    }
Exemple #15
0
    // Use this for initialization
    void Start()
    {
        //配列の使い方
        int[] array = new int[5];

        array[0] = 2;
        array[1] = 10;
        array[2] = 5;
        array[3] = 15;
        array[4] = 3;

        for (int i = 0; i < 5; i++)
        {
            Debug.Log(array[i]);
        }

        //簡単な初期化の方法
        int[] points =
        {
            83,
            99,
            52,
            93,
            15
        };

        for (int i = 0; i < points.Length; i++)
        {
            if (points[i] >= 90)
            {
                Debug.Log(points[i]);
            }
        }

        //引数も返り値もないメソッド

        SayHello();

        //引数のあるメソッド

        CallName("Tom");

        //引数と返り値のあるメソッド
        int answer;

        answer = Add(2, 3);
        Debug.Log(answer);

        //クラスの作成
        player myplayer = new player();

        myplayer.Attack();
        myplayer.Damage(30);

        //Vectorクラスの使い方
        Vector2 playerPos = new Vector2(3.0f, 4.0f);

        playerPos.x += 8.0f;
        playerPos.y += 5.0f;
        Debug.Log(playerPos);

        //ベクトルの減算
        Vector2 startPos = new Vector2(2.0f, 1.0f);
        Vector2 endpos   = new Vector2(8.0f, 5.0f);
        Vector2 dir      = endpos - startPos;

        float len = dir.magnitude;

        Debug.Log(len);
    }
Exemple #16
0
 private void Damage()
 {
     playerCharacter.Damage(damage * damageMultiplier);
 }
Exemple #17
0
    void Start()
    {
        //Hello, Worldをコンソールウィンドウに表示する
        Debug.Log("Hello World");
        int age;

        age = 30;
        Debug.Log(age);
        float height1 = 160.5f;
        float height2;

        height2 = height1;
        Debug.Log(height2);
        string name;

        name = "kitamura";
        Debug.Log(name);
        int answer;

        answer = 1 + 2;
        Debug.Log(answer);
        int n1 = 8;
        int n2 = 9;

        answer = n1 + n2;
        Debug.Log(answer);
        answer  = 10;
        answer += 5;
        Debug.Log(answer);
        answer = 10;
        answer++;
        Debug.Log(answer);
        string str1 = "happy ";
        string str2 = "birthday";
        string message;

        message = str1 + str2;
        Debug.Log(message);
        int num = 123;

        message = str1 + num;
        Debug.Log(message);
        int herbNum = 1;

        if (herbNum == 1)
        {
            ;
        }
        Debug.Log("HPが50回復");
        int hp = 200;

        if (hp >= 100)
        {
            Debug.Log("攻撃");
        }
        else
        {
            Debug.Log("防御");
        }
        for (int i = 0; i < 5; i++)
        {
            Debug.Log(i);
        }
        for (int i = 0; i < 16; i += 2)
        {
            Debug.Log(i);
        }
        for (int i = 3; i <= 5; i++)
        {
            Debug.Log(i);
        }
        for (int i = 3; i >= 0; i--)
        {
            Debug.Log(i);
        }
        int sum = 0;

        for (int i = 1; i <= 10; i++)
        {
            sum += i;
        }
        Debug.Log(sum);

        int[] array = new int[5];

        array[0] = 2;
        array[1] = 10;
        array[2] = 5;
        array[3] = 15;
        array[4] = 3;

        for (int i = 0; i < 5; i++)
        {
            Debug.Log(array[i]);
        }

        int[] points = { 83, 99, 52, 93, 15 };

        for (int i = 0; i < points.Length; i++)
        {
            if (points[i] >= 90)
            {
                Debug.Log(points[i]);
            }
        }

        SayHello();

        CallName("Tom");

        answer = Add(2, 3);
        Debug.Log(answer);

        player myplayer = new player();

        myplayer.Attack();
        myplayer.Damage(30);

        Vector2 playerPos = new Vector2(3.0f, 4.0f);

        playerPos.x = 8.0f;
        playerPos.y = 5.0f;
        Debug.Log(playerPos);

        Vector2 startPos = new Vector2(2.0f, 1.0f);
        Vector2 endPos   = new Vector2(8.0f, 5.0f);
        Vector2 dir      = endPos - startPos;

        Debug.Log(dir);

        float len = dir.magnitude;

        Debug.Log(len);
    }