protected override void OnCantMove <T>(T component)
    {
        Completed.Player hitplayer = component as Completed.Player;

        animator.SetTrigger("enemyAttack");
        SoundManager.instance.RandomizeSFX(enemyattack1, enemyattack2);
        hitplayer.LoseFood(playerDamage);
    }
Beispiel #2
0
        //OnCantMove is called if Enemy attempts to move into a space occupied by a Player, it overrides the OnCantMove function of MovingObject
        //and takes a generic parameter T which we use to pass in the component we expect to encounter, in this case Player
        protected override void OnCantMove <T> (T component)
        {
            //Declare hitPlayer and set it to equal the encountered component.
            Player hitPlayer = component as Player;

            //Call the LoseFood function of hitPlayer passing it playerDamage, the amount of foodpoints to be subtracted.
            hitPlayer.LoseFood(playerDamage);

            //Set the attack trigger of animator to trigger Enemy attack animation.
            animator.SetTrigger("enemyAttack");

            SoundManager.instance.RandomizeSfx(enemyAttack1, enemyAttack2);
        }
Beispiel #3
0
 void NpcAttack(string id, string target, int hp)
 {
     if (target == "1")
     {
         if (idEnemy.ContainsKey(id))
         {
             GameObject gameObject = idEnemy[id];
             Enemy      enemy      = gameObject.GetComponent <Enemy>();
             enemy.OnCantMove();
         }
         player.LoseFood(hp);
     }
 }
Beispiel #4
0
        //OnCantMove is called if Enemy attempts to move into a space occupied by a Player, it overrides the OnCantMove function of MovingObject
        //and takes a generic parameter T which we use to pass in the component we expect to encounter, in this case Player
        protected override void OnCantMove(RaycastHit2D hit)
        {
            if (hit.transform.GetComponent <Player>() != null)
            {
                //Declare hitPlayer and set it to equal the encountered component.
                Player hitPlayer = (hit.transform.GetComponent <Player>());

                //Call the LoseFood function of hitPlayer passing it playerDamage, the amount of foodpoints to be subtracted.
                hitPlayer.LoseFood(playerDamage);

                //Set the attack trigger of animator to trigger Enemy attack animation.
                animator.SetTrigger("enemyAttack");
            }
        }
Beispiel #5
0
        //OnCantMove is called if Enemy attempts to move into a space occupied by a Player, it overrides the OnCantMove function of MovingObject
        //and takes a generic parameter T which we use to pass in the component we expect to encounter, in this case Player
        protected override void OnCantMove <T>(T component)
        {
            //Declare hitPlayer and set it to equal the encountered component.
            Player hitPlayer = component as Player;

            //Call the LoseFood function of hitPlayer passing it playerDamage, the amount of foodpoints to be subtracted.
            hitPlayer.LoseFood(playerDamage);

            //Set the attack trigger of animator to trigger Enemy attack animation.
            animator.SetTrigger("EnemyHit");

            //Call the RandomizeSfx function of SoundManager passing in the two audio clips to choose randomly between.
            SoundManager.instance.RandomizeSfx(attackSound1, attackSound2);
        }
Beispiel #6
0
        //OnCantMove被调用如果敌人试图移动到玩家占据的空间,它会覆盖MovingObject的OnCantMove函数并接受一个通用参数T,
        // 我们用它来传递我们希望遇到的组件,在这种情况下,玩家
        protected override void OnCantMove <T> (T component)
        {
            //声明hitPlayer并将其设置为与遇到的组件相等.
            Player hitPlayer = component as Player;

            //调用hitPlayer的LoseFood函数传递playerDamage,减去foodpoints的数量。
            hitPlayer.LoseFood(playerDamage);

            //设置animator的攻击触发器以触发敌人攻击动画.
            animator.SetTrigger("enemyAttack");

            //调用SoundManager传入两个音频剪辑的RandomizeSfx函数,在两者之间随机选择。
            SoundManager.instance.RandomizeSfx(attackSound1, attackSound2);
        }
Beispiel #7
0
        // OnCantMove is called if Enemy attempts to move into a space occupied by a Player, it overrides the OnCantMove function of MovingObject
        // and takes a generic parameter T which we use to pass in the component we expect to encounter, in this case Player
        protected override void OnCantMove(Transform component)
        {
            // Declare hitPlayer and set it to equal the encountered component.
            Player hitPlayer = component.GetComponent <Player>();

            if (hitPlayer)
            {
                // Call the LoseFood function of hitPlayer passing it playerDamage, the amount of foodpoints to be subtracted.
                hitPlayer.LoseFood(playerDamage);

                // Set the attack trigger of animator to trigger Enemy attack animation.
                animator.SetTrigger(animationAttack);

                // Call the RandomizeSfx function of SoundManager passing in the audio clips to choose randomly between.
                SoundManager.instance.RandomizeSfx(attackSounds);
            }
        }
Beispiel #8
0
        //OnCantMoveは、EnemyがPlayerが占めるスペースに移動しようとすると呼び出され、
        //MovingObjectのOnCantMove関数をオーバーライドし、遭遇すると予想されるコンポーネント(この場合Player)を渡すために使用するジェネリックパラメータTをとります
        protected override void OnCantMove <T>(T component) //Playerへのダメージ
        {
            if (component.tag == "Player")
            {
                //hitPlayerを宣言し、遭遇したコンポーネントと等しくなるように設定します
                Player hitPlayer = component as Player;

                //hitPlayerのLoseFood関数を呼び出し、playerDamageを渡す
                hitPlayer.LoseFood(playerDamage);

                //エネミーの攻撃アニメーションのトリガー
                animator.SetTrigger("enemyAttack");

                //SoundManagerのRandomizeSfx関数を呼び出し、ランダムに再生
                SoundManager.instance.RandomizeSfx(attackSound1, attackSound2);
            }
            else if (component.tag == "Enemy")
            {
            }
        }
Beispiel #9
0
        //敵が攻撃する時に呼び出す
        protected override void OnCantMove <T> (T component)
        {
            Debug.Log("敵が攻撃をする");

            //衝突したプレイヤーを設定
            Player hitPlayer = component as Player;

            if (hp > 0)
            {
                Debug.Log("敵が生きてるので攻撃する");

                //プレイヤーのHPを減らす
                hitPlayer.LoseFood(playerDamage);

                //プレイヤーに攻撃するアニメーションを呼び出す
                animator.SetTrigger("enemyAttack");

                //攻撃する効果音を鳴らす
                SoundManager.instance.RandomizeSfx(attackSound1, attackSound2);
            }
        }
Beispiel #10
0
        protected override void OnCantMove <T> (T component)
        {
            Player hitPlayer = component as Player;

            hitPlayer.LoseFood(playerDamage);
        }