// Start is called before the first frame update void Start() { standingScale = new Vector4(-0.02f, 0.04f, 0.3f, 0.45f); crouchingScale = new Vector4(-0.02f, -0.01f, 0.3f, 0.35f); originalScale = transform.localScale; flipScale = new Vector3(-transform.localScale.x, transform.localScale.y, transform.localScale.z); playerPhysics = GetComponent <PlayerPhysicsMovement>(); sprRend = GetComponentInChildren <SpriteRenderer>(); abilities = GetComponent <AbilityManager>(); animationManager = GetComponentInChildren <AnimationManager>(); attackContainer = GetComponentInChildren <AttackContainer>(); }
protected AttackContainer PickRandomAttack(List <AttackContainer> attacks) { int chance = Random.Range(0, 100); float lowestPriority = 100; AttackContainer chosenAttack = attacks[0]; for (int i = 0; i < attacks.Count; i++) { var attack = attacks[i]; for (int j = 0; j < lastAtk.Count; j++) { if (lastAtk[j].func == attack.func) { attack.priority *= atkVarietyPercent + (1 - atkVarietyPercent) * j / lastAtk.Count; break; } } if (attack.priority > chance) { if (attack.priority < lowestPriority) { lowestPriority = attack.priority; chosenAttack = attack; } else if (attack.priority == lowestPriority) { if (Random.Range(0f, 1f) < 0.5f) { chosenAttack = attack; } } } } lastAtk.Insert(0, chosenAttack); if (lastAtk.Count > atkVariety) { lastAtk.RemoveAt(lastAtk.Count - 1); } return(chosenAttack); }
public void SetAttack(AttackContainer attack) { currentAttack = attack.func; currentAnim = attack.anim; }