public virtual void Setup(ProjectileData data) { this.data = data; if (data.projectileSprite != null) { rd.sprite = data.projectileSprite; } movement.Setup(); }
private void SpawnPerFrame() { if (spawnCounter >= spawnFrame) { ProjectileMovement spawned = Instantiate <ProjectileMovement>(spawnPrefab); spawned.Setup(transform.position, target.transform.position, 0.1f); spawnCounter = 0; } else { spawnCounter++; } }
private void StateMachineRunningPerFrame() { SlowDebuffState nextState = SlowDebuffState.Idle; if (currentState == SlowDebuffState.Meet) { //spriteRenderer.color = Color.red; if (canAttack) { ProjectileMovement spawned = Instantiate <ProjectileMovement>(projectileBullet); spawned.Setup(transform.position, player.transform.position, 0.1f); canAttack = false; } if (!IsPlayerInMeetRange()) { nextState = SlowDebuffState.Idle; } else if (IsPlayerInEscapeRange()) { nextState = SlowDebuffState.Escape; } else { nextState = SlowDebuffState.Meet; } } else if (currentState == SlowDebuffState.Escape) { //spriteRenderer.color = Color.cyan; if (!IsPlayerInMeetRange()) { nextState = SlowDebuffState.Idle; } else if (!IsPlayerInEscapeRange()) { nextState = SlowDebuffState.Meet; } else { nextState = SlowDebuffState.Escape; } } else if (currentState == SlowDebuffState.Death) { if (stateCounter >= deathFrame) { nextState = SlowDebuffState.Death; monsterHealth.Die(); } else { stateCounter++; nextState = SlowDebuffState.Death; } } else if (currentState == SlowDebuffState.Hurt) { if (stateCounter >= hurtFrame) { nextState = SlowDebuffState.Meet; } else { stateCounter++; nextState = SlowDebuffState.Hurt; } } else { // Check if meet if (IsPlayerInMeetRange()) { nextState = SlowDebuffState.Meet; } else { nextState = SlowDebuffState.Idle; } } if (currentState != SlowDebuffState.Hurt && monsterHealth.IsHurt) { nextState = SlowDebuffState.Hurt; } if (currentState != SlowDebuffState.Death && monsterHealth.IsDie) { nextState = SlowDebuffState.Death; } if (nextState != currentState) { changeState(nextState); } }