public class User
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static float |
DEFAULT_SPEED_FACTOR
Для вычисления скорости юнита
GameMap.TILE_SIZE / DEFAULT_SPEED_FACTOR |
static int |
DOWN
Движение вниз
|
static int |
FIRE
Выстрел
|
static int |
FIRE_INTERVAL
Интервал выстрелов (по умолчанию 400 мс)
|
static int |
GEN_NEW_ID
Флаг для генерации нового ID
|
static int |
LEFT
Движение влево
|
static int |
MINE
Мина
|
static int |
MY_UNIT_COLOR |
static int |
RIGHT
Движение вправо
|
static int |
UP
Движение вверх
|
Constructor and Description |
---|
User(java.lang.String name,
long id,
java.lang.String ip)
Создать нового юзера (на клиенте или сервере)
|
Modifier and Type | Method and Description |
---|---|
void |
changeID(long id) |
void |
changeUnitColor(int color) |
void |
destroy()
Установить метку что юнит убит, затем мы сможем удалить с игры даного юнита
|
void |
draw(android.graphics.Canvas canvas)
Вызывается в игровом цикле после просчета нового состояния
|
boolean |
equals(java.lang.Object o)
Compares this instance with the specified object and indicates if they
are equal.
|
android.graphics.Rect |
getBoundsRect()
Место (квадрат) занимаемое юнитом
|
int |
getDirection() |
long |
getID() |
java.lang.String |
getIp() |
long |
getLastFire() |
int |
getLifeProgress() |
int |
getLifes() |
int |
getMinesCount() |
int |
getMove() |
java.lang.String |
getName() |
int |
getPower() |
float |
getX() |
float |
getY() |
void |
incrementLife() |
void |
intersectWith(User user2)
Если даный юнит пересекается с
user2 то отодвинуть его назад |
boolean |
isDestroyed() |
void |
loadResources(android.content.res.Resources res)
Предзагрузка картинок и т.п.
|
void |
move(int deltaTime)
Просчет новых координат юнита (вызывается в игровом цикле)
|
void |
setAlpha(int alpha) |
void |
setDirection(int direction)
Установить новую картинку в зависимости отт выбранного направления движения
|
void |
setIp(java.lang.String ip) |
void |
setMinesCount(int n) |
void |
setMove(int click)
Установить состояние движения в какую-то сторону или наоборот остановку.
|
void |
setMoveVolume(float moveVolume)
Установка громкости звука движения юнита
|
void |
setName(java.lang.String name) |
void |
setSpeed(float speed) |
void |
setX(float x) |
void |
setY(float y) |
void |
shot(Bullet bullet)
Пуля попала в даного юнита, снимаем жизни
|
java.lang.String |
toString()
Переопределено
|
void |
updateLastFire()
Обновить метку времени последнего выстрела
|
public static final int GEN_NEW_ID
public static final int LEFT
public static final int RIGHT
public static final int DOWN
public static final int UP
public static final int FIRE
public static final int MINE
public static final int FIRE_INTERVAL
public static final int MY_UNIT_COLOR
public static final float DEFAULT_SPEED_FACTOR
GameMap.TILE_SIZE / DEFAULT_SPEED_FACTOR
public User(java.lang.String name, long id, java.lang.String ip)
name
- отображаемое имяid
- если передано GEN_NEW_ID
то будет сгенерирован новый IDip
- IP юзера, или метка что это Вы или владелец сервераpublic void loadResources(android.content.res.Resources res)
res
- ресурсыpublic long getID()
public java.lang.String getName()
public void changeID(long id)
public void setName(java.lang.String name)
public java.lang.String getIp()
public void setIp(java.lang.String ip)
public void draw(android.graphics.Canvas canvas)
canvas
- public void move(int deltaTime)
deltaTime
- время в мс прошедшее после предыдущего вызова методаpublic void setMove(int click)
click
- NO_CLICK, User.LEFT, and other directionspublic int getMove()
public void setDirection(int direction)
direction
- User.LEFT, and other directionspublic int getDirection()
public android.graphics.Rect getBoundsRect()
public void intersectWith(User user2)
user2
то отодвинуть его назадuser2
- public float getX()
public void setX(float x)
public float getY()
public void setY(float y)
public void setSpeed(float speed)
public long getLastFire()
public void updateLastFire()
public int getLifes()
public int getLifeProgress()
public void shot(Bullet bullet)
bullet
- public void incrementLife()
public void setAlpha(int alpha)
public int getPower()
public int getMinesCount()
public void setMinesCount(int n)
public void destroy()
isDestroyed()
public boolean isDestroyed()
public void setMoveVolume(float moveVolume)
moveVolume
- 0..1public void changeUnitColor(int color)
public boolean equals(java.lang.Object o)
java.lang.Object
o
must represent the same object
as this instance using a class-specific comparison. The general contract
is that this comparison should be reflexive, symmetric, and transitive.
Also, no object reference other than null is equal to null.
The default implementation returns true
only if this ==
o
. See Writing a correct
equals
method
if you intend implementing your own equals
method.
The general contract for the equals
and Object.hashCode()
methods is that if equals
returns true
for
any two objects, then hashCode()
must return the same value for
these objects. This means that subclasses of Object
usually
override either both methods or neither of them.
equals
in class java.lang.Object
o
- the object to compare this instance with.true
if the specified object is equal to this Object
; false
otherwise.Object.hashCode()
public java.lang.String toString()
toString
in class java.lang.Object
name + " -> " + ip