ruxa_15reg | Дата: Четверг, 28 Мая 2020, 12:42 | Сообщение # 1 | Тема: Assets\Enemy.cs(18,10): error CS0246: The type or namespace |
уже был
Сейчас нет на сайте
| using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Enemy : MonoBehaviour { private float timeBtwAttack; public float startTimeBtwAttack;
public int health; public float speed; public GameObject deathEffect; public int damage; private float stopTime; public float startStopTime; public float normalSpeed; private Animator anim; private Player player; private void Start() { anim = GetComponent<Animator>(); player = FindObjectOfType<Player>(); normalSpeed = speed; }
private void Update() { if(stopTime <= 0) { speed = normalSpeed; } else { speed = 0; stopTime -= Time.deltaTime; } if(health <= 0) { Destroy(gameObject); } transform.Translate(Vector2.left * speed * Time.deltaTime); } public void TakeDamage(int damage) { stopTime = startStopTime; Instantiate(deathEffect, transform.position, Quaternion.identity); health -= damage; } public void OnTriggerStay2D(Collider2D other) { if(other.CompareTag("Player")) { if(timeBtwAttack <=0) { anim.SetTrigger("attack"); } else { timeBtwAttack -= Time.deltaTime; } } } public void OnEnemyAttack() { Instantiate(deathEffect, player.transform.position, Quaternion.identity); player.health -= damage; timeBtwAttack = startTimeBtwAttack; } }
|
|
| |