mise a jours uml + javadoc + suppretion de code inutile
This commit is contained in:
@@ -3,7 +3,6 @@ package Game <<Folder>> {
|
|||||||
package Cards <<Folder>> {
|
package Cards <<Folder>> {
|
||||||
abstract class Card {
|
abstract class Card {
|
||||||
{static}- frameBitmap : Bitmap
|
{static}- frameBitmap : Bitmap
|
||||||
- drawablecard :DrawableCard
|
|
||||||
--
|
--
|
||||||
+ Card(String UID,Context c)
|
+ Card(String UID,Context c)
|
||||||
+ onCardAttack(Board board,Card enemy) : void
|
+ onCardAttack(Board board,Card enemy) : void
|
||||||
@@ -31,6 +30,28 @@ package Game <<Folder>> {
|
|||||||
+ getHealth() : int
|
+ getHealth() : int
|
||||||
+ getName() : String
|
+ getName() : String
|
||||||
}
|
}
|
||||||
|
class PlayableZonesHandler
|
||||||
|
{
|
||||||
|
--
|
||||||
|
+ PlayableZonesHandler(Board board)
|
||||||
|
+ displayPlayableZones(Renderer renderer)
|
||||||
|
+ displayPlayableZonesOn(int i,Renderer renderer)
|
||||||
|
+ hidePlayableZones(Renderer renderer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
class Hand
|
||||||
|
{
|
||||||
|
--
|
||||||
|
+Hand()
|
||||||
|
+pickCardFromDeck(Deck deck,int amount)
|
||||||
|
+fillHand(Deck deck)
|
||||||
|
}
|
||||||
|
class TouchHandler
|
||||||
|
{
|
||||||
|
- TouchDeltaX : float
|
||||||
|
- TouchDeltaY : float
|
||||||
|
- originalPositionX : float
|
||||||
|
- originalPositionY : float
|
||||||
}
|
}
|
||||||
package Players <<Folder>> {
|
package Players <<Folder>> {
|
||||||
class Player
|
class Player
|
||||||
@@ -48,14 +69,7 @@ package Game <<Folder>> {
|
|||||||
class GameLogicThread
|
class GameLogicThread
|
||||||
{
|
{
|
||||||
- Context cont
|
- Context cont
|
||||||
- Renderer renderer
|
|
||||||
- boolean ready
|
- boolean ready
|
||||||
- TouchHandler touch
|
|
||||||
- GameActivity gameActivity
|
|
||||||
- Deck localPlayerDeck
|
|
||||||
- Hand localPlayerHand
|
|
||||||
- Board board
|
|
||||||
- PlayableZonesHandler playableZonesHandler
|
|
||||||
--
|
--
|
||||||
+ GameLogicThread(GameActivity gameActivity, Renderer renderer)
|
+ GameLogicThread(GameActivity gameActivity, Renderer renderer)
|
||||||
+ run()
|
+ run()
|
||||||
@@ -65,14 +79,36 @@ package Game <<Folder>> {
|
|||||||
+ onTouchEvent(MotionEvent event)
|
+ onTouchEvent(MotionEvent event)
|
||||||
}
|
}
|
||||||
class Board
|
class Board
|
||||||
|
{
|
||||||
|
--
|
||||||
|
+ Board()
|
||||||
|
+ playCard() : boolean
|
||||||
|
+ getPlayerCardsOnBoard() : Card[]
|
||||||
|
}
|
||||||
|
package Decks <<Folder>>
|
||||||
|
{
|
||||||
|
abstract class Deck
|
||||||
|
{
|
||||||
|
--
|
||||||
|
+shuffle()
|
||||||
|
+ abstract getDeckName()
|
||||||
|
}
|
||||||
|
class DeckDemo
|
||||||
|
{
|
||||||
|
--
|
||||||
|
+ DeckDemo(String id,Context context)
|
||||||
|
+ getCards() : Stack<Card>
|
||||||
|
{abstract}+ getDeckName() : String
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
package Video <<Folder>> {
|
package Video <<Folder>> {
|
||||||
package Drawables <<Folder>> {
|
package Drawables <<Folder>> {
|
||||||
class Drawable {
|
abstract class Drawable {
|
||||||
- x : int
|
- x : float
|
||||||
- y : int
|
- y : float
|
||||||
- name : String
|
- name : String
|
||||||
- bitmap : Bitmap
|
- bitmap : Bitmap
|
||||||
- p : Paint
|
- p : Paint
|
||||||
@@ -82,26 +118,31 @@ package Video <<Folder>> {
|
|||||||
+ equals(Object o) : boolean
|
+ equals(Object o) : boolean
|
||||||
+ setCoordinates(float x, float y) : void
|
+ setCoordinates(float x, float y) : void
|
||||||
# checkPaint() : void
|
# checkPaint() : void
|
||||||
|
# setBitmap(Bitmap bitmap) : void
|
||||||
}
|
}
|
||||||
class DrawableRectangle
|
class DrawableRectangle
|
||||||
{
|
{
|
||||||
# Drawable(Rectangle rectangle, String name, int color)
|
+ DrawableRectangle(Rectangle rectangle, String name, int color)
|
||||||
|
+ DrawableRectangle(Bitmap bitmap,Rectangle rectangle, String name, int color)
|
||||||
}
|
}
|
||||||
class DrawableBitmap
|
class DrawableBitmap
|
||||||
{
|
{
|
||||||
# Drawable(Bitmap bitmap, float x_pos, float y_pos, String name, float x_size, float y_size)
|
+ DrawableBitmap(Bitmap bitmap, float x_pos, float y_pos, String name, float x_size, float y_size)
|
||||||
# Drawable(Bitmap bitmap,Rectangle rectangle, String name, int color)
|
|
||||||
}
|
}
|
||||||
class DrawableText
|
class DrawableText
|
||||||
{
|
{
|
||||||
# Drawable(String text,float x_pos,float y_pos,String name, float x_size,float y_size,float textSize , int x_canvasRatio, int y_canvasRatio)
|
+ DrawableText(String text,float x_pos,float y_pos,String name, float x_size,float y_size,float textSize , int x_canvasRatio, int y_canvasRatio)
|
||||||
- cutText(int charPerLines,String text) : List<String>
|
- cutText(int charPerLines,String text) : List<String>
|
||||||
}
|
}
|
||||||
class DrawableCard
|
abstract class DrawableCard
|
||||||
{
|
{
|
||||||
|
- ratio : int
|
||||||
- onBoard : boolean
|
- onBoard : boolean
|
||||||
|
- draggable : boolean
|
||||||
--
|
--
|
||||||
+ DrawableCard(Card c, float x, float y, String name, Context context)
|
+ DrawableCard(Card c, float x, float y, String name, Context context)
|
||||||
|
+ DrawableCard(Card c, float x, float y, String name, Context context,int ratio)
|
||||||
|
+ DrawableCard(DrawableCard smallCArd, Context cont,int ratio)
|
||||||
+ updateHpAndAtk(Integer atk,Integer hp)
|
+ updateHpAndAtk(Integer atk,Integer hp)
|
||||||
- removeAlpha(String color)
|
- removeAlpha(String color)
|
||||||
+ drawOn(Canvas c, Paint p)
|
+ drawOn(Canvas c, Paint p)
|
||||||
@@ -112,22 +153,31 @@ package Video <<Folder>> {
|
|||||||
class Renderer {
|
class Renderer {
|
||||||
- holder : SurfaceHolder
|
- holder : SurfaceHolder
|
||||||
- p : Paint
|
- p : Paint
|
||||||
- drawingThread : DrawingThread
|
- needToUpdate : boolean
|
||||||
- engine : GameLogicThread
|
|
||||||
- toDraw : List<Drawable>
|
|
||||||
--
|
--
|
||||||
+ Renderer(Context context)
|
+ Renderer(Context context,GameActivity gameActivity)
|
||||||
+ surfaceCreated(SurfaceHolder holder) : void
|
+ surfaceCreated(SurfaceHolder holder) : void
|
||||||
+ surfaceChanged(urfaceHolder surfaceHolder, int i, int i1, int i2) : void
|
+ surfaceChanged(urfaceHolder surfaceHolder, int i, int i1, int i2) : void
|
||||||
+ surfaceDestroyed(SurfaceHolder surfaceHolder) : void
|
+ surfaceDestroyed(SurfaceHolder surfaceHolder) : void
|
||||||
+ onDraw(Canvas canvas) : void
|
+ onDraw(Canvas canvas) : void
|
||||||
|
+ updateFrame() : void
|
||||||
+ addToDraw(Drawable newElement) : boolean
|
+ addToDraw(Drawable newElement) : boolean
|
||||||
|
+ addToDrawWithoutUpdate(Drawable newElement) : boolean
|
||||||
+ moveToDraw(float x, float y, String name) : void
|
+ moveToDraw(float x, float y, String name) : void
|
||||||
|
+ removeToDrawWithoutUpdate(String name) : void
|
||||||
|
+ removeToDrawWithoutUpdate(Drawable drawable) : void
|
||||||
+ removeToDraw(String name) : void
|
+ removeToDraw(String name) : void
|
||||||
+ removeToDraw(Drawable toRemove) : void
|
+ removeToDraw(Drawable toRemove) : void
|
||||||
+ getDrawAble(String name) : Drawable
|
+ getDrawAble(String name) : Drawable
|
||||||
|
+ getCardOn(float x, float y) : DrawableCard
|
||||||
+ setEngine(GameLogicThread engine) : void
|
+ setEngine(GameLogicThread engine) : void
|
||||||
+ updateFrame() : void
|
}
|
||||||
|
class DrawingThread{
|
||||||
|
-renderer Renderer
|
||||||
|
+keepdrawing boolean
|
||||||
|
--
|
||||||
|
+DrawingThread(Renderer renderer)
|
||||||
|
+run()
|
||||||
}
|
}
|
||||||
class RectangleCanevas {
|
class RectangleCanevas {
|
||||||
--
|
--
|
||||||
@@ -141,6 +191,8 @@ package Video <<Folder>> {
|
|||||||
+ width : float
|
+ width : float
|
||||||
+ height : float
|
+ height : float
|
||||||
--
|
--
|
||||||
|
+ Rectange(float prostionX,float positionY,float width,float height)
|
||||||
|
- set(float positionX,float positionY,float width,float height)
|
||||||
+ scaleRectangleToScreen() : void
|
+ scaleRectangleToScreen() : void
|
||||||
+ bitmapRectangleBuilder(Bitmap bitmap, int color) : void
|
+ bitmapRectangleBuilder(Bitmap bitmap, int color) : void
|
||||||
}
|
}
|
||||||
@@ -159,35 +211,56 @@ Drawable <|-- DrawableRectangle
|
|||||||
Drawable <|-- DrawableBitmap
|
Drawable <|-- DrawableBitmap
|
||||||
Drawable <|-- DrawableText
|
Drawable <|-- DrawableText
|
||||||
|
|
||||||
|
Renderer "1" *-- DrawingThread : -drawingThread
|
||||||
|
Renderer "1" *-- GameLogicThread : -engine
|
||||||
|
Renderer "*" *-- Drawable : toDraw
|
||||||
|
|
||||||
Player <|-- PlayerBot
|
Player <|-- PlayerBot
|
||||||
Player <|-- PlayerLocal
|
Player <|-- PlayerLocal
|
||||||
Player <|-- PlayerAdversary
|
Player <|-- PlayerAdversary
|
||||||
|
|
||||||
|
DrawableCard o-- Drawable : frameDrawable
|
||||||
|
DrawableCard *-- Drawable : OpacityRectangleDrawable
|
||||||
|
DrawableCard *-- Drawable : PictureDrawable
|
||||||
|
DrawableCard *-- Drawable : cardOnBoardDrawable
|
||||||
|
DrawableCard *-- Drawable : cardDescription
|
||||||
|
DrawableCard *-- Drawable : cardTitle
|
||||||
|
DrawableCard *-- Drawable : cardHpDrawable
|
||||||
|
DrawableCard *-- Drawable : cardAtkDrawable
|
||||||
|
|
||||||
|
TouchHandler *-- DrawableCard : moveEventCard
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
PlayableZonesHandler "*" *-- Drawable : playableZones
|
||||||
|
PlayableZonesHandler "1" *-- Board : board
|
||||||
|
|
||||||
DrawableCard o-- Drawable : OpacityRectangleDrawable
|
|
||||||
DrawableCard o-- Drawable : PictureDrawable
|
|
||||||
DrawableCard o-- Drawable : cardOnBoardDrawable
|
|
||||||
DrawableCard o-- Drawable : cardDescription
|
|
||||||
DrawableCard o-- Drawable : cardTitle
|
|
||||||
DrawableCard o-- Drawable : cardHpDrawable
|
|
||||||
DrawableCard o-- Drawable : cardAtkDrawable
|
|
||||||
DrawableCard o-- Card : card
|
DrawableCard o-- Card : card
|
||||||
|
|
||||||
DrawableCard "1" *-- "1" Rectangle : cardOnBoardFrame
|
DrawableCard "1" *-- "1" Rectangle : cardOnBoardFrame
|
||||||
DrawableCard "1" *-- "1" Rectangle : cardOnBoardAtk
|
DrawableCard "1" *-- "1" Rectangle : cardOnBoardAtk
|
||||||
DrawableCard "1" *-- "1" Rectangle : cardOnBoardHp
|
DrawableCard "1" *-- "1" Rectangle : cardOnBoardHp
|
||||||
RectangleCanevas *-- Rectangle : +rectangle
|
|
||||||
|
Card "1" *-- DrawableCard : drawableCard
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Renderer "1" *-- "0_*" Drawable : toDraw
|
Renderer "1" *-- "0_*" Drawable : toDraw
|
||||||
|
|
||||||
GameActivity "1" *-- "1" Renderer : renderer
|
GameActivity "1" *-- "1" Renderer : renderer
|
||||||
|
|
||||||
GameLogicThread o-- Renderer
|
GameLogicThread *-- TouchHandler : touchHandler
|
||||||
GameLogicThread *-- Board
|
GameLogicThread o-- Renderer : renderer
|
||||||
|
GameLogicThread *-- Board : board
|
||||||
|
GameLogicThread *-- Deck : localPlayerDeck
|
||||||
|
GameLogicThread *-- Hand : fillHand
|
||||||
|
GameLogicThread *-- PlayableZonesHandler : playableZonesHandler
|
||||||
|
GameLogicThread *-- GameActivity : gameActivity
|
||||||
|
|
||||||
Board *-- PlayerLocal : player
|
Board *-- PlayerLocal : player
|
||||||
Board *-- Player : adversary
|
Board *-- Player : adversary
|
||||||
|
|
||||||
|
Deck <|-- DeckDemo
|
||||||
|
|
||||||
Renderer o-- GameLogicThread
|
Renderer o-- GameLogicThread
|
||||||
@enduml
|
@enduml
|
||||||
@@ -92,7 +92,7 @@ public abstract class Card {
|
|||||||
* retourne la culeur de la carte
|
* retourne la culeur de la carte
|
||||||
* la couleur s'affiche comme un filtre sur la carte
|
* la couleur s'affiche comme un filtre sur la carte
|
||||||
* /!\ attention a l'opacite /!\ le format n'est PAS rgba MAIS argb
|
* /!\ attention a l'opacite /!\ le format n'est PAS rgba MAIS argb
|
||||||
* #AARRGGBB
|
* #AARRGGB //TODOB
|
||||||
* je recomander une opaciter en 44 et 70
|
* je recomander une opaciter en 44 et 70
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -106,7 +106,6 @@ public abstract class Card {
|
|||||||
* @return la description
|
* @return la description
|
||||||
*/
|
*/
|
||||||
public abstract String getDescription();
|
public abstract String getDescription();
|
||||||
//TODO
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import java.util.Stack;
|
|||||||
public abstract class Deck {
|
public abstract class Deck {
|
||||||
public abstract Stack<Card> getCards();
|
public abstract Stack<Card> getCards();
|
||||||
|
|
||||||
public void suffle()
|
public void shuffle()
|
||||||
{
|
{
|
||||||
Collections.shuffle(getCards());
|
Collections.shuffle(getCards());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
package com.iutlaval.myapplication.Game.Decks;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class DeckRegister {
|
|
||||||
public static Deck getClassFromName(String name, Context context)
|
|
||||||
{
|
|
||||||
//switch case non utilisable MAIS c'est pas important car c'ette foction n'est que pour
|
|
||||||
//HandActivity
|
|
||||||
|
|
||||||
if(name.equals("demo"))
|
|
||||||
{
|
|
||||||
return new DeckDemo(name,context);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,7 +3,6 @@ package com.iutlaval.myapplication.Game;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.graphics.Color;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
|
|
||||||
@@ -11,17 +10,11 @@ import com.iutlaval.myapplication.Game.Cards.Card;
|
|||||||
import com.iutlaval.myapplication.Game.Decks.Deck;
|
import com.iutlaval.myapplication.Game.Decks.Deck;
|
||||||
import com.iutlaval.myapplication.Game.Decks.DeckDemo;
|
import com.iutlaval.myapplication.Game.Decks.DeckDemo;
|
||||||
import com.iutlaval.myapplication.GameActivity;
|
import com.iutlaval.myapplication.GameActivity;
|
||||||
import com.iutlaval.myapplication.InvalidDataException;
|
|
||||||
import com.iutlaval.myapplication.R;
|
import com.iutlaval.myapplication.R;
|
||||||
import com.iutlaval.myapplication.Video.Drawables.Drawable;
|
|
||||||
import com.iutlaval.myapplication.Video.Drawables.DrawableBitmap;
|
import com.iutlaval.myapplication.Video.Drawables.DrawableBitmap;
|
||||||
import com.iutlaval.myapplication.Video.Drawables.DrawableCard;
|
import com.iutlaval.myapplication.Video.Drawables.DrawableCard;
|
||||||
import com.iutlaval.myapplication.Video.Drawables.DrawableRectangle;
|
|
||||||
import com.iutlaval.myapplication.Video.Rectangle;
|
|
||||||
import com.iutlaval.myapplication.Video.Renderer;
|
import com.iutlaval.myapplication.Video.Renderer;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class GameLogicThread extends Thread{
|
public class GameLogicThread extends Thread{
|
||||||
|
|
||||||
private Context cont;
|
private Context cont;
|
||||||
@@ -34,6 +27,8 @@ public class GameLogicThread extends Thread{
|
|||||||
private Hand localPlayerHand;
|
private Hand localPlayerHand;
|
||||||
private Board board;
|
private Board board;
|
||||||
private PlayableZonesHandler playableZonesHandler;
|
private PlayableZonesHandler playableZonesHandler;
|
||||||
|
private DrawableCard currentlySelected = null;
|
||||||
|
private static final float SELECTING_OFFSET = 20F;
|
||||||
|
|
||||||
public GameLogicThread(GameActivity gameActivity, Renderer renderer)
|
public GameLogicThread(GameActivity gameActivity, Renderer renderer)
|
||||||
{
|
{
|
||||||
@@ -43,7 +38,7 @@ public class GameLogicThread extends Thread{
|
|||||||
this.renderer = renderer;
|
this.renderer = renderer;
|
||||||
touch = new TouchHandler(renderer);
|
touch = new TouchHandler(renderer);
|
||||||
localPlayerDeck = new DeckDemo("local",cont);
|
localPlayerDeck = new DeckDemo("local",cont);
|
||||||
localPlayerDeck.suffle();
|
localPlayerDeck.shuffle();
|
||||||
localPlayerHand = new Hand();
|
localPlayerHand = new Hand();
|
||||||
localPlayerHand.fillHand(localPlayerDeck);
|
localPlayerHand.fillHand(localPlayerDeck);
|
||||||
this.gameActivity=gameActivity;
|
this.gameActivity=gameActivity;
|
||||||
@@ -52,10 +47,6 @@ public class GameLogicThread extends Thread{
|
|||||||
GameActivity.setGameEngine(this);
|
GameActivity.setGameEngine(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private float i=0;
|
|
||||||
private float increm = 1F;
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
//affichage de l'arriere plan
|
//affichage de l'arriere plan
|
||||||
@@ -97,6 +88,7 @@ public class GameLogicThread extends Thread{
|
|||||||
* /!\ renderer.updateFrame(); va forcer le system a redessiner l'afficher qui ensuite reappelera onFrameDoneRendering() ce qui peut causer si le updateFrame() n'est pas proteger
|
* /!\ renderer.updateFrame(); va forcer le system a redessiner l'afficher qui ensuite reappelera onFrameDoneRendering() ce qui peut causer si le updateFrame() n'est pas proteger
|
||||||
* une utilisation de la batterie massive
|
* une utilisation de la batterie massive
|
||||||
*/
|
*/
|
||||||
|
//TODO : supprimer cette fonction si on a rien a en faire
|
||||||
public void onFrameDoneRendering()
|
public void onFrameDoneRendering()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -109,11 +101,6 @@ public class GameLogicThread extends Thread{
|
|||||||
return ready;
|
return ready;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private DrawableCard currentlySelected = null;
|
|
||||||
private static final float SELECTING_OFFSET = 20F;
|
|
||||||
/**
|
/**
|
||||||
* relais l'evenement directement au touch Handler
|
* relais l'evenement directement au touch Handler
|
||||||
* @param event
|
* @param event
|
||||||
@@ -154,7 +141,7 @@ public class GameLogicThread extends Thread{
|
|||||||
currentlySelected.setCoordinates(currentlySelected.getX(),currentlySelected.getY() + SELECTING_OFFSET);
|
currentlySelected.setCoordinates(currentlySelected.getX(),currentlySelected.getY() + SELECTING_OFFSET);
|
||||||
currentlySelected=null;
|
currentlySelected=null;
|
||||||
}
|
}
|
||||||
playableZonesHandler.HidePlayableZones(renderer);
|
playableZonesHandler.hidePlayableZones(renderer);
|
||||||
}else{
|
}else{
|
||||||
touch.onTouchEvent(event);
|
touch.onTouchEvent(event);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,12 +19,13 @@ public class Hand {
|
|||||||
|
|
||||||
public void pickCardFromDeck(Deck deck,int amount)
|
public void pickCardFromDeck(Deck deck,int amount)
|
||||||
{
|
{
|
||||||
for(int i = 0 ; i < NUMBER_OF_CARDS_IN_STARTING_HAND;i++)
|
for(int i = 0 ; i < amount;i++)
|
||||||
{
|
{
|
||||||
hand.add(deck.getCards().pop());
|
hand.add(deck.getCards().pop());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO check number of card in hand
|
||||||
public void fillHand(Deck deck)
|
public void fillHand(Deck deck)
|
||||||
{
|
{
|
||||||
pickCardFromDeck(deck,NUMBER_OF_CARDS_IN_STARTING_HAND);
|
pickCardFromDeck(deck,NUMBER_OF_CARDS_IN_STARTING_HAND);
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ public class PlayableZonesHandler {
|
|||||||
this.board=board;
|
this.board=board;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO verifier si elle ne sont pas deja afficher
|
||||||
public void displayPlayableZones(Renderer renderer)
|
public void displayPlayableZones(Renderer renderer)
|
||||||
{
|
{
|
||||||
Card[] cardsOnBoard = board.getPlayerCardsOnBoard();
|
Card[] cardsOnBoard = board.getPlayerCardsOnBoard();
|
||||||
@@ -50,7 +51,7 @@ public class PlayableZonesHandler {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HidePlayableZones(Renderer renderer)
|
public void hidePlayableZones(Renderer renderer)
|
||||||
{
|
{
|
||||||
for(Drawable d : playableZones)
|
for(Drawable d : playableZones)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,9 +4,7 @@ package com.iutlaval.myapplication;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
import android.graphics.Point;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
|
|
||||||
|
|||||||
@@ -101,10 +101,6 @@ public abstract class Drawable {
|
|||||||
p = new Paint();
|
p = new Paint();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void scale(float i) {
|
|
||||||
bitmap = Bitmap.createScaledBitmap(this.bitmap,(int)(bitmap.getWidth()*i),(int)(bitmap.getHeight()*i),GameActivity.bilinearFiltering);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* retourne si le drawable peut être deplacer en drag and drop
|
* retourne si le drawable peut être deplacer en drag and drop
|
||||||
* @return
|
* @return
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ import com.iutlaval.myapplication.Video.Rectangle;
|
|||||||
* TODO : tout mettre dans des finals
|
* TODO : tout mettre dans des finals
|
||||||
*/
|
*/
|
||||||
public class DrawableCard extends Drawable{
|
public class DrawableCard extends Drawable{
|
||||||
private int ratio;
|
//propriéte de base utilisé pour calculer toutes les tailles est positoins
|
||||||
|
//ces données ne sont pas dans les digrames car sa renderais la lecture impossible
|
||||||
private static final int CARD_WITH = 14;
|
private static final int CARD_WITH = 14;
|
||||||
private static final int CARD_HEIGHT = 40;
|
private static final int CARD_HEIGHT = 40;
|
||||||
private static final float HP_ATK_FONT_SIZE_OFFBOARD =60F;
|
private static final float HP_ATK_FONT_SIZE_OFFBOARD =60F;
|
||||||
@@ -33,7 +33,7 @@ public class DrawableCard extends Drawable{
|
|||||||
private static int TEXT_ATK_HP_X_RES = 110;
|
private static int TEXT_ATK_HP_X_RES = 110;
|
||||||
private static int TEXT_ATK_HP_Y_RES = 60;//60
|
private static int TEXT_ATK_HP_Y_RES = 60;//60
|
||||||
|
|
||||||
//des floats sont utiliser card ils prenne moin de ram que des doubles et que l'on a pas besoin de la precision supplementaire
|
//des floats sont utiliser car ils prenne moin de ram que des doubles et que l'on a pas besoin de la precision supplementaire
|
||||||
//dimentions
|
//dimentions
|
||||||
private static final float ONBOARD_RECTANGLE_ATK_HP_WIDTH = CARD_WITH * 0.5F;
|
private static final float ONBOARD_RECTANGLE_ATK_HP_WIDTH = CARD_WITH * 0.5F;
|
||||||
private static final float ONBOARD_RECTANGLE_ATK_HP_HEIGHT = CARD_HEIGHT * 0.2F;
|
private static final float ONBOARD_RECTANGLE_ATK_HP_HEIGHT = CARD_HEIGHT * 0.2F;
|
||||||
@@ -79,6 +79,11 @@ public class DrawableCard extends Drawable{
|
|||||||
private static final float CARD_ON_BOARD_DRAWABLE_WIDTH = CARD_WITH;
|
private static final float CARD_ON_BOARD_DRAWABLE_WIDTH = CARD_WITH;
|
||||||
private static final float CARD_ON_BOARD_DRAWABLE_HEIGHT = CARD_HEIGHT*0.667F;
|
private static final float CARD_ON_BOARD_DRAWABLE_HEIGHT = CARD_HEIGHT*0.667F;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ratio définissant la taille de l'objet
|
||||||
|
*/
|
||||||
|
private int ratio;
|
||||||
|
|
||||||
private Boolean onBoard;
|
private Boolean onBoard;
|
||||||
private Boolean draggable;
|
private Boolean draggable;
|
||||||
|
|
||||||
@@ -86,6 +91,7 @@ public class DrawableCard extends Drawable{
|
|||||||
private Drawable opacityRectangleDrawable;
|
private Drawable opacityRectangleDrawable;
|
||||||
private Drawable pictureDrawable;
|
private Drawable pictureDrawable;
|
||||||
|
|
||||||
|
//TODO : optimiser si la couleur est déja en mémoire
|
||||||
private Drawable cardOnBoardDrawable;
|
private Drawable cardOnBoardDrawable;
|
||||||
|
|
||||||
private Drawable cardDescription;
|
private Drawable cardDescription;
|
||||||
@@ -195,6 +201,13 @@ public class DrawableCard extends Drawable{
|
|||||||
setCoordinates(getX(), getY());
|
setCoordinates(getX(), getY());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* permet de crée une grande carte a partir d'une carte plus petite
|
||||||
|
* @param smallCArd car parante
|
||||||
|
* @param cont context
|
||||||
|
* @param ratio ratio de taille
|
||||||
|
* /!\ ne pas s'en servir pour juste changer la taille d'une carte/!\
|
||||||
|
*/
|
||||||
public DrawableCard(DrawableCard smallCArd, Context cont,int ratio) {
|
public DrawableCard(DrawableCard smallCArd, Context cont,int ratio) {
|
||||||
this(smallCArd.card,smallCArd.getX(),smallCArd.getY(),smallCArd.getName()+"BIG",cont,ratio);
|
this(smallCArd.card,smallCArd.getX(),smallCArd.getY(),smallCArd.getName()+"BIG",cont,ratio);
|
||||||
draggable =false;
|
draggable =false;
|
||||||
@@ -210,6 +223,7 @@ public class DrawableCard extends Drawable{
|
|||||||
* @param atk l'attaque de la carte
|
* @param atk l'attaque de la carte
|
||||||
* @param hp les point de vie de la carte
|
* @param hp les point de vie de la carte
|
||||||
*/
|
*/
|
||||||
|
//TODO supprimer la possibilité null si non utilisé
|
||||||
public void updateHpAndAtk(Integer atk,Integer hp)
|
public void updateHpAndAtk(Integer atk,Integer hp)
|
||||||
{
|
{
|
||||||
if(onBoard) {
|
if(onBoard) {
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ public class DrawableRectangle extends Drawable{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* ce constructeur n'est pas tres rapide donc a eviter il utilse pas mal de ram mais sava encore le gc de java s'en ocupe vite
|
* ce constructeur n'est pas tres rapide donc a eviter il utilse pas mal de ram mais sava encore le gc de java s'en ocupe vite
|
||||||
* ce constructeur dessine un rectangle avec la couleur donné" en argument
|
* ce constructeur dessine un rectangle avec la couleur donné en argument
|
||||||
* @param bitmap
|
* @param bitmap bitmap sur le quel dessiner
|
||||||
* @param rectangle recange cooresspondant a la surface a dessiner
|
* @param rectangle recange cooresspondant a la surface a dessiner
|
||||||
* @param name nom du drawable agit comme un identifiant mais doit être unique
|
* @param name nom du drawable agit comme un identifiant mais doit être unique
|
||||||
* @param color couleur du rectangle
|
* @param color couleur du rectangle
|
||||||
@@ -43,7 +43,7 @@ public class DrawableRectangle extends Drawable{
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public DrawableRectangle(Bitmap bitmap,Rectangle rectangle, String name, int color) throws InvalidDataException {
|
public DrawableRectangle(Bitmap bitmap,Rectangle rectangle, String name, int color) throws InvalidDataException {
|
||||||
super(rectangle.getPositionX(),rectangle.getPositionY(),name);
|
super(rectangle.getPositionX(),rectangle.getPositionY(),name);
|
||||||
if(rectangle.getHeight() <= 0 || rectangle.getWidth() <=0 || bitmap == null)throw new InvalidDataException(name,rectangle);
|
if(rectangle.isDrawable() || bitmap == null)throw new InvalidDataException(name,rectangle);
|
||||||
|
|
||||||
rectangle.scaleRectangleToScreen();
|
rectangle.scaleRectangleToScreen();
|
||||||
rectangle.bitmapRectangleBuilder(bitmap,color);
|
rectangle.bitmapRectangleBuilder(bitmap,color);
|
||||||
|
|||||||
@@ -10,6 +10,10 @@ import com.iutlaval.myapplication.GameActivity;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ce code a éte particuliérement dur a implementé de maniére correct
|
||||||
|
* tout modification de ce code doit passer par marc car seul moi sait a quel point il est complex
|
||||||
|
*/
|
||||||
public class DrawableText extends Drawable{
|
public class DrawableText extends Drawable{
|
||||||
/**TODO : corriger les deformation due au changement de ratio (x_size,y_size)
|
/**TODO : corriger les deformation due au changement de ratio (x_size,y_size)
|
||||||
* ce constructeur permet de rendre du texte
|
* ce constructeur permet de rendre du texte
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ public class FpsTime {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* atten exactement la durée d'une image a l'ecran a la vitesse optimal de l'ecran
|
* atten exactement la durée d'une image a l'ecran a la vitesse optimal de l'ecran
|
||||||
|
* prend en argument un offset qui permet de reduire l'attente si le systeme a pris beaucoup de temps a génerer une image
|
||||||
*/
|
*/
|
||||||
public static void waitFrameTime(long time){
|
public static void waitFrameTime(long time){
|
||||||
time = (System.nanoTime()-time)/1000;
|
time = (System.nanoTime()-time)/1000;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class Rectangle {
|
|||||||
* @param width une largeur
|
* @param width une largeur
|
||||||
* @param height une hauteur
|
* @param height une hauteur
|
||||||
*/
|
*/
|
||||||
public void set(float positionX,float positionY,float width,float height)
|
private void set(float positionX,float positionY,float width,float height)
|
||||||
{
|
{
|
||||||
this.positionX=positionX;
|
this.positionX=positionX;
|
||||||
this.positionY=positionY;
|
this.positionY=positionY;
|
||||||
@@ -85,4 +85,7 @@ public class Rectangle {
|
|||||||
|
|
||||||
c.drawRect(this,p);
|
c.drawRect(this,p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDrawable() {
|
||||||
|
return getHeight() <= 0 || getWidth() <=0;}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public class Renderer extends SurfaceView implements SurfaceHolder.Callback {
|
|||||||
private DrawingThread drawingThread;
|
private DrawingThread drawingThread;
|
||||||
private GameLogicThread engine;
|
private GameLogicThread engine;
|
||||||
private GameActivity gameActivity;
|
private GameActivity gameActivity;
|
||||||
private boolean contentChanged;
|
private boolean needToUpdate;
|
||||||
|
|
||||||
private List<Drawable> toDraw;
|
private List<Drawable> toDraw;
|
||||||
|
|
||||||
@@ -65,6 +65,7 @@ public class Renderer extends SurfaceView implements SurfaceHolder.Callback {
|
|||||||
* cette fonction est appeler a chaque fois que l'utilisateur tourne son ecran
|
* cette fonction est appeler a chaque fois que l'utilisateur tourne son ecran
|
||||||
* this function is unused since the screen is locked
|
* this function is unused since the screen is locked
|
||||||
*/
|
*/
|
||||||
|
//TODO : a supprimer si elle set a rien (surment importante avec la veille)
|
||||||
@Override
|
@Override
|
||||||
public void surfaceChanged(@NonNull SurfaceHolder surfaceHolder, int i, int i1, int i2) {
|
public void surfaceChanged(@NonNull SurfaceHolder surfaceHolder, int i, int i1, int i2) {
|
||||||
}
|
}
|
||||||
@@ -72,7 +73,7 @@ public class Renderer extends SurfaceView implements SurfaceHolder.Callback {
|
|||||||
/**
|
/**
|
||||||
* on surface destruction stop the thread
|
* on surface destruction stop the thread
|
||||||
* la surface ce fait detruire aussi quand le jeu est en pause
|
* la surface ce fait detruire aussi quand le jeu est en pause
|
||||||
* TODO kill proprement le thread et ajouter une relance sur le GameActivity
|
* TODO ajouter une relance sur le GameActivity
|
||||||
* @param surfaceHolder
|
* @param surfaceHolder
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -102,7 +103,7 @@ public class Renderer extends SurfaceView implements SurfaceHolder.Callback {
|
|||||||
* demander au moteur de faire sont travaille
|
* demander au moteur de faire sont travaille
|
||||||
*/
|
*/
|
||||||
public void updateFrame() {
|
public void updateFrame() {
|
||||||
contentChanged=true;
|
needToUpdate =true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -151,7 +152,7 @@ public class Renderer extends SurfaceView implements SurfaceHolder.Callback {
|
|||||||
//sauve de la baterie
|
//sauve de la baterie
|
||||||
FpsTime.waitFrameTime(time);
|
FpsTime.waitFrameTime(time);
|
||||||
if(engine != null && engine.isReady())engine.onFrameDoneRendering();
|
if(engine != null && engine.isReady())engine.onFrameDoneRendering();
|
||||||
while(!contentChanged)
|
while(!needToUpdate)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
Thread.sleep(20);
|
Thread.sleep(20);
|
||||||
@@ -159,7 +160,7 @@ public class Renderer extends SurfaceView implements SurfaceHolder.Callback {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentChanged=false;
|
needToUpdate =false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -170,7 +171,7 @@ public class Renderer extends SurfaceView implements SurfaceHolder.Callback {
|
|||||||
*/
|
*/
|
||||||
public boolean addToDraw(Drawable newElement){
|
public boolean addToDraw(Drawable newElement){
|
||||||
boolean returnValue = addToDrawWithoutUpdate(newElement);
|
boolean returnValue = addToDrawWithoutUpdate(newElement);
|
||||||
contentChanged=true;
|
updateFrame();
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,7 +204,7 @@ public class Renderer extends SurfaceView implements SurfaceHolder.Callback {
|
|||||||
if(d.getName().equals(name))
|
if(d.getName().equals(name))
|
||||||
{
|
{
|
||||||
d.setCoordinates(x,y);
|
d.setCoordinates(x,y);
|
||||||
contentChanged=true;
|
updateFrame();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -234,7 +235,7 @@ public class Renderer extends SurfaceView implements SurfaceHolder.Callback {
|
|||||||
*/
|
*/
|
||||||
public void removeToDraw(String name){
|
public void removeToDraw(String name){
|
||||||
removeToDrawWithoutUpdate(name);
|
removeToDrawWithoutUpdate(name);
|
||||||
contentChanged=true;
|
updateFrame();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* remove the element from the draw list
|
* remove the element from the draw list
|
||||||
@@ -242,7 +243,7 @@ public class Renderer extends SurfaceView implements SurfaceHolder.Callback {
|
|||||||
*/
|
*/
|
||||||
public void removeToDraw(Drawable toRemove){
|
public void removeToDraw(Drawable toRemove){
|
||||||
toDraw.remove(toRemove);
|
toDraw.remove(toRemove);
|
||||||
contentChanged=true;
|
updateFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -264,10 +265,6 @@ public class Renderer extends SurfaceView implements SurfaceHolder.Callback {
|
|||||||
return drawable;
|
return drawable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEngine(GameLogicThread engine) {
|
|
||||||
this.engine = engine;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* retourne une carte au coodonés donné
|
* retourne une carte au coodonés donné
|
||||||
* MAIS ne met pas ajour le rendu
|
* MAIS ne met pas ajour le rendu
|
||||||
|
|||||||
Reference in New Issue
Block a user