package shooting.example.examplestage;

import java.util.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import shooting.core.*;

/// AĨTv
public class ExampleAI extends Player {
	public static final int DEFAULT_WIDTH = 30;	///< ftHg̕
	public static final int DEFAULT_HEIGHT = 30;	///< ftHg̍
	public static final int MAX_DAMAGE = 100;	///< ő_[W
	/// ̎擾
	/// @return 
	public int getWidth() { return getImage() != null ? getImage().getWidth(null) : DEFAULT_WIDTH; }
	/// ̎擾
	/// @return 
	public int getHeight() { return getImage() != null ? getImage().getHeight(null) : DEFAULT_HEIGHT; }
	/// ő_[W̎擾
	/// @return ő_[W
	public int getMaxDamage() { return MAX_DAMAGE; }

	/// RXgN^
	/// @param shooting ShootingNX̃IuWFNg
	/// @param team `[ԍ
	/// @param x zu鍶ォXW
	/// @param y zu鍶ォYW
	/// @param sx ˂̕EXW
	/// @param sy ˂̕EYW
	public ExampleAI(Shooting shooting, int team, int x, int y, int sx, int sy) {
		super(shooting, null, team, x, y, sx, sy);
	}

	/// RXgN^
	/// @param shooting ShootingNX̃IuWFNg
	/// @param image @̂̉摜
	/// @param team `[ԍ
	/// @param x zu鍶ォXW
	/// @param y zu鍶ォYW
	/// @param sx ˂̕EXW
	/// @param sy ˂̕EYW
	public ExampleAI(Shooting shooting, Image image, int team, int x, int y, int sx, int sy) {
		super(shooting, team, x, y, sx, sy);
		setImage(image);
		setWeapon(new ExampleWeapon(this));
		setMovingX(1);
	}

	/// C[vĂ΂ꂽxɈxs
	private static final int moveInterval = 10;
	/// moveIntervalɈxs𐧌䂷邽߂̃JE^
	private int moveIntervalCnt = 0;
	/// C[vĂ΂鏈
	///
	/// ł͈ړƒe̔ˏsĂ
	public void runMainLoopJob() {
		// 1/1000̊mŒe𔭎˂
		// (Weaponˉ\ԂłȂΔ˂Ȃ)
		if ((int)(Math.random()*1000) == 0) {
			getWeapon().shoot();
		}
		if (moveIntervalCnt == moveInterval) {
			// ȏ㍡̌֐i߂ȂȂ]
			if (!canMoveTo(getX()+getMovingX(), getY(), getWidth(), getHeight())) {
				setMovingX(-getMovingX());
			}
			setX(getX()+getMovingX());
			moveIntervalCnt = 0;
		}
		moveIntervalCnt++;
	}
}


@@ -943,37 +943,36 @@
 x, int sy) %7B%0D%0A%09%09
-super
+this
 (shooting, null,
@@ -1311,24 +1311,26 @@
 x, y, sx, sy
+*5
 );%0D%0A%09%09setIma

fix ExampleAI constructor