void Update() { if (HealthPoint() == 0) { return; } if (stunTime_unit == 0 || stunTime == 0 || TimeEx.Cooldown(ref stunTime) == 0) { if (TimeEx.Cooldown(ref stateTime) == 0) { StateChange(); } StateUpdate(); } animator.SetBool("isHit", stunTime != 0); //시선처리용 코드 //릴리즈때 지워야댐 //raycast test RaycastHit2D rcHit = Physics2D.Raycast(transform.position, direction, 10000.0f, 1 << LayerMask.NameToLayer("Map")); if (rcHit.collider != null) { Vector2 dirst = direction * rcHit.distance; Vector3 collPos = transform.position + new Vector3(dirst.x, dirst.y, 0); Vector3 linePos = new Vector3(transform.position.x, transform.position.y, 0); Debug.DrawLine(linePos, collPos, Color.red); } }
void Update() { if (HealthPoint() == 0) { return; } if (hitCooldown > 0) { bool enable; if (TimeEx.Cooldown(ref hitCooldown) == 0) { enable = true; } else { enable = ((int)((hitCooldown_unit - hitCooldown) / hitEffect_unit) & 1) != 0; } spriteRenderer.enabled = enable; //자식 렌더러는 어케끄냐 } Vector2 movement = new Vector2(0, 0); if (Input.GetKey(KeyCode.A)) { movement.x--; } if (Input.GetKey(KeyCode.D)) { movement.x++; } if (Input.GetKey(KeyCode.W)) { movement.y++; } if (Input.GetKey(KeyCode.S)) { movement.y--; } movement *= velocity * Time.deltaTime; transform.position += new Vector3(movement.x, movement.y); animator.SetBool("isMoving", (movement.x != 0) || (0 != movement.y)); UpdateDirection(); if (Input.GetKey(KeyCode.Mouse0)) { myWeaponScript.WeaponFire(); } }
// Update is called once per frame void Update() { if (grenade.IsBraked()) { if (TimeEx.Cooldown(ref fuse) == 0) { GameObject explosion = Instantiate(explosionPrefab); explosion.transform.position = transform.position; Destroy(gameObject); } } }
protected override void StateUpdate() { if (BehaviorState.Bike_riding == state) { if (PlayerTracking()) { if (Vector2.Distance(Vector2ex.By3(GameObject.FindWithTag("Player").transform.position), Vector2ex.By3(transform.position)) < 100) { SetState_BikeOut(); animator.SetTrigger("isBikeFinish"); } } //으아 길찾기 if (TimeEx.Cooldown(ref astar_cooldown) == 0) { astar_cooldown = 0.5f; if ((astar_lastSucceeded = astarPathFinder.경로검색(GameObject.FindWithTag("Player").transform.position)) == true) { List <Astar.최단경로노드> path = astarPathFinder.GetPath(); astar_index = 0; astar_dir = Vector2ex.By3(path[0].월드위치) - Vector2ex.By3(transform.position); astar_remainDist = astar_dir.magnitude; astar_dir /= astar_remainDist; } } if (astar_lastSucceeded) { float movement = bikeSpeed * Time.deltaTime; while (true) { if (astar_remainDist < movement) { transform.position += Vector2ex.To3(astar_dir) * astar_remainDist; movement -= astar_remainDist; List <Astar.최단경로노드> path = astarPathFinder.GetPath(); astar_index++; if (astar_index >= path.Count) { astar_cooldown = 0; break; } astar_dir = Vector2ex.By3(path[astar_index].월드위치) - Vector2ex.By3(transform.position); astar_remainDist = astar_dir.magnitude; astar_dir /= astar_remainDist; } else { transform.position += Vector2ex.To3(astar_dir) * movement; astar_remainDist -= movement; break; } } } lrFliper.In(astar_dir); } else if (BehaviorState.Bike_out == state) { float movement = bikeSpeed * Time.deltaTime; transform.position += Vector2ex.To3(astar_dir) * movement; } else if (BehaviorState.Attack_machinegun == state || BehaviorState.Attack_machinegun_prefire == state || BehaviorState.Attack_grenadelauncher == state) { if (PlayerTracking()) { GameObject player = GameObject.FindWithTag("Player"); Vector2 destDir = (Vector2ex.By3(player.transform.position) - Vector2ex.By3(transform.position)).normalized; float angle = Vector2.Angle(destDir, direction); if (angle <= weaponRotateSpeed * Time.deltaTime) { if (state == BehaviorState.Attack_grenadelauncher) { weapon_GrenadeLauncher.WeaponFire(); } else { weapon_MG.WeaponFire(); } direction = destDir; } else { bool isRevClockwise = direction.x * destDir.y - direction.y * destDir.x >= 0; direction = Vector2ex.Rotate(direction, weaponRotateSpeed * Mathf.Deg2Rad * Time.deltaTime * (isRevClockwise ? 1 : -1)); } } else { if (BehaviorState.Attack_machinegun == state) { stateTime -= 1; if (stateTime <= 0) { SetState_Idle(); } else { SetState_AttackMachinegun_Prefire(); } } } } else if (BehaviorState.Moving == state) { transform.position += Vector2ex.To3(direction); } }
void Update() { lrFliper.In(weaponOwner.Direction()); TimeEx.Cooldown(ref cooldown); }