public override void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "Enemy")
        {
            ActorModel.Model.SetEngery(ActorModel.Model.GetCurrentWeapon().回复能量);

            View.CurrentScene.GetView <GameInfoView>().HitCount++;

            if (attack_type == HitType.击飞)
            {
                Camera.main.GetComponent <Cinemachine.CinemachineImpulseSource>().GenerateImpulse();
                if (View.CurrentScene is GameScene)
                {
                    TimeModel.SetTimeScale(0.2f, true, 0.2f);
                }
            }
            bool isCrit     = false;
            var  weapon     = WeaponConfig.Get(ActorModel.Model.GetPlayerEquipment(EquipmentType.武器));
            var  hurt_value = ActorModel.Model.GetPlayerAttribute(PlayerAttribute.攻击力);
            if (Random.value <= ActorModel.Model.GetPlayerAttribute(PlayerAttribute.暴击率) * 0.01f)
            {
                isCrit     = true;
                hurt_value = ActorModel.Model.GetPlayerAttribute(PlayerAttribute.暴击伤害);
            }
            collision.gameObject.GetComponent <IHurt>().GetHurt(
                new AttackData(hurt_value, isCrit, ActorController.Controller.transform.position, attack_type)
                );
        }
    }
예제 #2
0
 public void UpdateHealth()
 {
     health_text.text      = (int)ActorModel.Model.GetHealth() + "/" + ActorModel.Model.GetPlayerAttribute(PlayerAttribute.生命值);
     health_bar.fillAmount = (float)(ActorModel.Model.GetHealth() / ActorModel.Model.GetPlayerAttribute(PlayerAttribute.生命值));
     if (ActorModel.Model.GetHealth() <= 0)
     {
         TimeModel.SetTimeScale(0.2f);
         View.CurrentScene.OpenView <TipView>().SetContent("你已经死了!!", () => {
             TimeModel.SetTimeScale(1);
             ActorModel.Model.ResetState();
             LoadingScene.LoadScene(GameConstData.GAME_MAIN_SCENE_NAME);
         });
     }
 }
예제 #3
0
 public override void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.tag == "Enemy")
     {
         View.CurrentScene.GetView <GameInfoView>().HitCount++;
         if (attack_type == HitType.击飞)
         {
             Camera.main.GetComponent <Cinemachine.CinemachineImpulseSource>().GenerateImpulse();
             TimeModel.SetTimeScale(0.2f, true, 0.2f);
         }
         collision.gameObject.GetComponent <IHurt>().GetHurt(
             new AttackData(model.GetHurtValue(), false, transform.position, attack_type)
             );
     }
 }