using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Sowrd : WManager
{
public Vector3 attachPosition = new Vector3( 0f, 0.43f, 0f);
public Vector3 attachAngles = new Vector3( 0f, 0f, 0f);
public Vector3 attachScale = new Vector3( 1f, 1f, 1f);
Player player;
Animator animator;
Time60 time60;
Vector2 offset;
Vector3 effect_pos;
Vector3 player_pos;
int effectNum = 0;
int WaitTime = 0;
int attackLevel = 0;
[SerializeField]
private GameObject[] effects;
// Start is called before the first frame update
void Start()
{
GameObject playerObj = GameObject.FindGameObjectWithTag("Player");
player = playerObj.GetComponentInParent<Player>();
offset = new Vector2( player.offset.x, player.offset.y);
animator = playerObj.GetComponent<Animator>();
GManager gManager = GameObject.FindObjectsOfType<GManager>()[0];
time60 = gManager.GetComponent<Time60>();
}
protected override void Update()
{
if( time60.CheckFlame() != true ) return;
if( WaitTime > 0){
WaitTime--;
}else{
attackLevel = 0;
}
if( player.SetAttackFlag() != false){
if( (WaitTime < 15) && (attackLevel < 3)){
switch(attackLevel){
case 0:
animator.Play( "Slash1", 0, 0f);
attackLevel++;
break;
case 1:
animator.Play( "Slash2", 0, 0f);
attackLevel++;
break;
case 2:
animator.Play( "Slash3", 0, 0f);
attackLevel++;
break;
default:
break;
}
var effectObj = Instantiate<GameObject>(effects[effectNum]);
var effect = effectObj.GetComponent<EffSlash0>();
player_pos = player.transform.position;
effect_pos = new Vector3( player_pos.x + offset.x + 0.3f * player.flip,
player_pos.y + offset.y + 0.3f, player_pos.z);
effect.transform.position = new Vector3( effect_pos.x, effect_pos.y, player_pos.z);
effect.transform.localScale = new Vector3( 2.0f *player.flip, 2.0f, 2.0f);
WaitTime = 30;
}
}
}
}