Exemplo n.º 1
0
  public void Init()
  {
    agent = gameObject.GetComponent<NavMeshAgent>();
    animator = gameObject.GetComponent<Animator>();
    combat_unit = gameObject.GetComponent<CombatUnit>();

    effects_go = gameObject.GetChild("blood_vfx");
    effects = effects_go.GetComponentsInChildren<ParticleSystem>(true);

    effects_go.SetActive(true);
    StopEffects();

    gameObject.tag = "Enemy";

    combat_unit.OnDie.AddListener(OnDie);
    combat_unit.OnDamaged.AddListener(OnDamaged);

    fsm = new StateMachine<AIState>();
    fsm.enable_log = false;

    AddState(new StateSpawn());
    AddState(new StateMove());
    AddState(new StateAttack());
    AddState(new StateDie());

    fsm.SwitchTo(AIState.Spawn);
  }
Exemplo n.º 2
0
    public override void OnEnter()
    {
      player = Game.self.combat.player;
      animator = ai.animator;

      animator.SetBool("IsAttacking", true);
      animator.Play("Attacking");

      ai.StartCoroutine(Attack());
    }
Exemplo n.º 3
0
        public void Attack(CombatUnit damaged)
        {
            if (!is_alive)
            {
                return;
            }

            var damage = Random.Range(attack_min, attack_max);

            damaged.RecieveDamage(damage);

            OnAttack.Invoke();
        }
Exemplo n.º 4
0
  void Awake()
  {
    cctl = GetComponent<CharacterController>();
    player = GetComponent<CombatUnit>();
    animator = GetComponent<Animator>();
    cam = Camera.main;

    effects_go = gameObject.GetChild("shot_vfx");
    effects = effects_go.GetComponentsInChildren<ParticleSystem>(true);

    effects_go.SetActive(true);
    StopEffects();

    gameObject.tag = "Player";
  }
Exemplo n.º 5
0
    public override void OnEnter()
    {
      player = Game.self.combat.player;
      agent = ai.agent;
      animator = ai.animator;
      agent.isStopped = false;
      
      if(player == null)
      {
        agent.isStopped = true;
        return;
      }

      agent.SetDestination(player.transform.position);
    }
Exemplo n.º 6
0
  public void SpawnPlayer()
  {
    var point = Game.self.location.GetChild("PlayerSpawnPoint");
    Error.Verify(point != null);

    cam_go = Assets.TryReuse("Cameras/PlayerCamera");

    var player_go = Assets.TryReuse(prefab: "Characters/Player", activate: false);
    player_go.transform.position = new Vector3(point.transform.position.x, point.transform.position.y, point.transform.position.z);
    player_go.transform.rotation = new Quaternion(point.transform.rotation.x, point.transform.rotation.y, point.transform.rotation.z, point.transform.rotation.w);

    var unit = player_go.GetComponent<CombatUnit>();
    unit.Reset();
    unit.OnDamaged.AddListener(OnPlayerDamaged);

    player = unit;
    player_go.SetActive(true);

    hud = UI.Open<UIHud>();
    hud.Init();
  }