working
This commit is contained in:
parent
4e91f448c9
commit
1b2611e5a9
90 changed files with 7029 additions and 2762 deletions
|
@ -1,39 +0,0 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class BoomLazer : MonoBehaviour
|
||||
{
|
||||
private float i = 0.0f;
|
||||
Rigidbody rib;
|
||||
[SerializeField] float explosionRadius;
|
||||
[SerializeField] float explosionForce;
|
||||
private float upwardModifier = 0.0f;
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
private void Start()
|
||||
{
|
||||
rib=GetComponent<Rigidbody>();
|
||||
}
|
||||
|
||||
|
||||
//Prend tout les rigidbody sauf le sien et leurs applique une force pour les expulser
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
//Uniformisation des codes de balles, pour la détruire au 2e impact avec un collider dû au fait qu'elle spawn DANS un collider
|
||||
//Reste clairement Junky et est sujet à amélioration
|
||||
i += 1;
|
||||
if (i > 0)
|
||||
{
|
||||
Vector3 explosionPosition = transform.position;
|
||||
Collider[] colliders = Physics.OverlapSphere(explosionPosition, explosionRadius);
|
||||
|
||||
foreach (Collider collider in colliders)
|
||||
{
|
||||
Rigidbody rb = collider.GetComponent<Rigidbody>();
|
||||
if (rb != null & rb != rib)
|
||||
{
|
||||
rb.AddExplosionForce(explosionForce, explosionPosition, explosionRadius, upwardModifier, ForceMode.Impulse);
|
||||
}
|
||||
}
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 30612f05fd9747843853fc490546942a
|
|
@ -1,101 +0,0 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class CameraFly : MonoBehaviour
|
||||
{
|
||||
[SerializeField] float mainSpeed; //regular speed
|
||||
[SerializeField] float shiftAdd; //multiplied by how long shift is held. Basically running
|
||||
[SerializeField] float maxShift; //Maximum speed when holdin gshift
|
||||
[SerializeField] float camVelocity; //How sensitive it with mouse
|
||||
private Vector3 lastMouse = new Vector3(255, 255, 255); //kind of in the middle of the screen, rather than at the top (play)
|
||||
private float totalRun = 1.0f;
|
||||
|
||||
void Update()
|
||||
{
|
||||
Vector3 r = GetRotInput();
|
||||
lastMouse = new Vector3(transform.eulerAngles.x + r.x, transform.eulerAngles.y + r.y, 0);
|
||||
//transform.eulerAngles = lastMouse;
|
||||
transform.rotation = Quaternion.Euler(lastMouse);
|
||||
//Mouse camera angle done.
|
||||
|
||||
//Keyboard commands
|
||||
//float f = 0.0f;
|
||||
Vector3 p = GetBaseInput();
|
||||
if (p.sqrMagnitude > 0)
|
||||
{ // only move while a direction key is pressed
|
||||
if (Input.GetKey(KeyCode.LeftShift))
|
||||
{
|
||||
totalRun += Time.deltaTime;
|
||||
p = p * totalRun * shiftAdd;
|
||||
p.x = Mathf.Clamp(p.x, -maxShift, maxShift);
|
||||
p.y = Mathf.Clamp(p.y, -maxShift, maxShift);
|
||||
p.z = Mathf.Clamp(p.z, -maxShift, maxShift);
|
||||
}
|
||||
else
|
||||
{
|
||||
totalRun = Mathf.Clamp(totalRun * 0.5f, 1f, 1000f);
|
||||
p = p * mainSpeed;
|
||||
}
|
||||
|
||||
p = p * Time.deltaTime;
|
||||
Vector3 newPosition = transform.position;
|
||||
if (Input.GetKey(KeyCode.Space))
|
||||
{ //If player wants to move on X and Z axis only
|
||||
transform.Translate(p);
|
||||
newPosition.x = transform.position.x;
|
||||
newPosition.z = transform.position.z;
|
||||
transform.position = newPosition;
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.Translate(p);
|
||||
}
|
||||
}
|
||||
Debug.Log(r);
|
||||
Debug.Log(p);
|
||||
}
|
||||
|
||||
private Vector3 GetBaseInput()
|
||||
{ //returns the basic values, if it's 0 than it's not active.
|
||||
Vector3 p_Velocity = new Vector3();
|
||||
if (Input.GetKey(KeyCode.UpArrow))
|
||||
{
|
||||
p_Velocity += new Vector3(0, 0, 1);
|
||||
}
|
||||
if (Input.GetKey(KeyCode.DownArrow))
|
||||
{
|
||||
p_Velocity += new Vector3(0, 0, -1);
|
||||
}
|
||||
if (Input.GetKey(KeyCode.LeftArrow))
|
||||
{
|
||||
p_Velocity += new Vector3(-1, 0, 0);
|
||||
}
|
||||
if (Input.GetKey(KeyCode.RightArrow))
|
||||
{
|
||||
p_Velocity += new Vector3(1, 0, 0);
|
||||
}
|
||||
return p_Velocity;
|
||||
}
|
||||
|
||||
private Vector3 GetRotInput()
|
||||
{ //returns the basic values, if it's 0 than it's not active.
|
||||
Vector3 r_Velocity = new Vector3();
|
||||
if (Input.GetKey(KeyCode.Z))
|
||||
{
|
||||
r_Velocity += new Vector3(0, 1,0);
|
||||
}
|
||||
if (Input.GetKey(KeyCode.S))
|
||||
{
|
||||
r_Velocity += new Vector3(0, -1, 0);
|
||||
}
|
||||
if (Input.GetKey(KeyCode.Q))
|
||||
{
|
||||
r_Velocity += new Vector3(-1, 0, 0);
|
||||
}
|
||||
if (Input.GetKey(KeyCode.D))
|
||||
{
|
||||
r_Velocity += new Vector3(1, 0, 0);
|
||||
}
|
||||
return camVelocity*r_Velocity;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5c1167af3b3e2714d8cfcbaaf894d1ed
|
|
@ -1,38 +0,0 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class CameraMovementFlat : MonoBehaviour
|
||||
{
|
||||
[SerializeField] float cameraMovementSpeed;
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
//avancer reculer
|
||||
if (Input.GetKey(KeyCode.UpArrow))
|
||||
{
|
||||
//Debug.Log("avancer");
|
||||
transform.Translate(Vector3.forward * Time.deltaTime * cameraMovementSpeed, Space.World);
|
||||
}
|
||||
if (Input.GetKey(KeyCode.DownArrow))
|
||||
{
|
||||
//Debug.Log("reculer");
|
||||
transform.Translate(-Vector3.forward * Time.deltaTime * cameraMovementSpeed, Space.World);
|
||||
}
|
||||
if (Input.GetKey(KeyCode.LeftArrow))
|
||||
{
|
||||
//Debug.Log("gauche");
|
||||
transform.Translate(-Vector3.right * Time.deltaTime * cameraMovementSpeed, Space.World);
|
||||
}
|
||||
if (Input.GetKey(KeyCode.RightArrow))
|
||||
{
|
||||
//Debug.Log("droite");
|
||||
transform.Translate(Vector3.right * Time.deltaTime * cameraMovementSpeed, Space.World);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 925cd4cabe50f39309d22502c750e5a7
|
|
@ -1,47 +0,0 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class Duck : MonoBehaviour
|
||||
{
|
||||
|
||||
[SerializeField] protected float baseMovementSpeed;
|
||||
[SerializeField] protected int baseHP;
|
||||
[SerializeField] protected int baseArmor;
|
||||
|
||||
|
||||
[SerializeField] protected float baseAttackSpeed;
|
||||
[SerializeField] protected int manaToSpecialAttack;
|
||||
[SerializeField] protected Weapon weapon;
|
||||
|
||||
protected float currentMovementSpeed;
|
||||
protected int currentHP;
|
||||
protected int currentArmor;
|
||||
protected float currentAttackSpeed;
|
||||
|
||||
|
||||
//TODO WEAPON
|
||||
//TODO Special Ability
|
||||
|
||||
public virtual void activateSpecialAbility(){
|
||||
|
||||
}
|
||||
|
||||
public virtual void takeDamage(int damage){
|
||||
currentHP -= (damage > currentArmor) ? (damage - currentArmor) : 0;
|
||||
}
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
currentMovementSpeed = baseMovementSpeed;
|
||||
currentHP = baseHP;
|
||||
currentArmor = baseArmor;
|
||||
currentAttackSpeed = baseAttackSpeed;
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: faa3fb39c1a2816728c5f5ab89a77e88
|
|
@ -43,7 +43,7 @@ public class AttackCAC : MonoBehaviour
|
|||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (baseDuckScript.getGameManagerScript().combatPhase)
|
||||
if (GameManager.Instance.fightStarted)
|
||||
{
|
||||
if (canAttack)
|
||||
{
|
||||
|
@ -55,35 +55,21 @@ public class AttackCAC : MonoBehaviour
|
|||
{
|
||||
Vector3 directionToTarget = hit.transform.position - transform.position;
|
||||
float distanceToTarget = directionToTarget.magnitude;
|
||||
if (baseDuckScript.getAttackMode() == 3)
|
||||
{
|
||||
distanceToTarget = Vector3.Distance(baseDuckScript.getArmyManagerScript().getCrownDuck(baseDuckScript.getTeam()).transform.position, hit.transform.position);
|
||||
}
|
||||
|
||||
if (!Physics.Raycast(transform.position, directionToTarget.normalized, distanceToTarget,
|
||||
wallLayer))
|
||||
{
|
||||
if (baseDuckScript.getArmyManagerScript().getArmy(!baseDuckScript.getTeam()).Contains(hit.gameObject))
|
||||
if (ArmyManager.getArmy(!baseDuckScript.getTeam()).Contains(hit.GetComponent<AbstractUnit>()))
|
||||
{
|
||||
if (baseDuckScript.getAttackMode() == 1)
|
||||
{
|
||||
if (baseDuckScript.getArmyManagerScript().getCrownDuck(!baseDuckScript.getTeam()) ==
|
||||
if (ArmyManager.getCrownDuck(!baseDuckScript.getTeam()) ==
|
||||
hit.gameObject)
|
||||
{
|
||||
targetToAttack = hit.gameObject;
|
||||
targetFound = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (baseDuckScript.getAttackMode() == 2 || baseDuckScript.getAttackMode() == 3)
|
||||
{
|
||||
if (distanceToTarget < distanceToChosenTarget)
|
||||
{
|
||||
distanceToChosenTarget = distanceToTarget;
|
||||
targetToAttack = hit.gameObject;
|
||||
targetFound = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,8 +90,8 @@ public class AttackCAC : MonoBehaviour
|
|||
private void AttackC(GameObject targetToAttack)
|
||||
{
|
||||
StartCoroutine(coolDown());
|
||||
targetToAttack.GetComponent<BaseDuckScript>().TakeDamage(damage);
|
||||
Debug.Log("Corps à corps");
|
||||
targetToAttack.GetComponent<AbstractUnit>().TakeDamage(damage);
|
||||
Debug.Log("Corps <EFBFBD> corps");
|
||||
ATTACK.Invoke();
|
||||
}
|
||||
|
||||
|
|
|
@ -3,17 +3,14 @@ using UnityEngine.AI;
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class BaseDuckScript : MonoBehaviour
|
||||
public class BaseDuckScript : AbstractUnit
|
||||
{
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
private bool isEnemy = true;
|
||||
[SerializeField] public bool hasCrown = false;
|
||||
[SerializeField] GameObject armyManagerEntity;
|
||||
[SerializeField] GameObject gameManagerEntity;
|
||||
private ArmyManager armyManagerScript;
|
||||
private GameManager gameManagerScript;
|
||||
|
||||
[SerializeField] GameObject crownPrefab;
|
||||
[SerializeField] private int attackMode = 0; //0 do Nothing, 1 offense, 2 Neutre, 3 Défense
|
||||
|
||||
NavMeshAgent agent;
|
||||
private Rigidbody duckRB;
|
||||
Vector3 destination;
|
||||
|
@ -38,17 +35,11 @@ public class BaseDuckScript : MonoBehaviour
|
|||
void Start()
|
||||
{
|
||||
health = baseHealth;
|
||||
armyManagerScript = armyManagerEntity.GetComponent<ArmyManager>();
|
||||
gameManagerScript = gameManagerEntity.GetComponent<GameManager>();
|
||||
armyManagerScript.addTroopToArmy(isEnemy, gameObject);
|
||||
|
||||
agent = GetComponent<NavMeshAgent>();
|
||||
duckRB = gameObject.GetComponent<Rigidbody>();
|
||||
healthCanvasRect = healthCanvas.GetComponent<RectTransform>();
|
||||
|
||||
if (hasCrown){
|
||||
becomeCrownDuck();
|
||||
}
|
||||
|
||||
DuckHeight = transform.Find("TigeUI").GetComponent<Renderer>().bounds.size.y;
|
||||
allGroundLayers = LayerMask.GetMask("Dirt") | LayerMask.GetMask("Sand");
|
||||
}
|
||||
|
@ -62,8 +53,7 @@ public class BaseDuckScript : MonoBehaviour
|
|||
transform.LookAt(GetComponent<AttackCAC>().GetTarget().transform);
|
||||
}
|
||||
|
||||
|
||||
if (gameManagerScript.combatPhase)
|
||||
if (GameManager.Instance.fightStarted)
|
||||
{
|
||||
updateMovement();
|
||||
}
|
||||
|
@ -118,95 +108,20 @@ public class BaseDuckScript : MonoBehaviour
|
|||
public void updateMovement()
|
||||
{
|
||||
duckRB.isKinematic = false;
|
||||
if (attackMode == 1 && armyManagerScript.getCrownDuck(!isEnemy))
|
||||
if (attackMode == 1 && ArmyManager.getCrownDuck(!isEnemy))
|
||||
{
|
||||
destination = armyManagerScript.getCrownDuck(!isEnemy).transform.position;
|
||||
destination = ArmyManager.getCrownDuck(!isEnemy).transform.position;
|
||||
agent.destination = destination;
|
||||
}
|
||||
|
||||
if (attackMode == 2)
|
||||
{
|
||||
List<GameObject> opposingArmy = armyManagerScript.getArmy(!isEnemy);
|
||||
if (opposingArmy.Count > 0){
|
||||
GameObject closestOpponent = opposingArmy[0];
|
||||
float closestDistance = Vector3.Distance(opposingArmy[0].transform.position, transform.position);
|
||||
foreach (GameObject opposingDuck in opposingArmy)
|
||||
{
|
||||
if (Vector3.Distance(opposingDuck.transform.position, transform.position) < closestDistance)
|
||||
{
|
||||
closestOpponent = opposingDuck;
|
||||
closestDistance = Vector3.Distance(opposingDuck.transform.position, transform.position);
|
||||
}
|
||||
}
|
||||
destination = closestOpponent.transform.position;
|
||||
agent.destination = destination;
|
||||
}
|
||||
}
|
||||
|
||||
if (attackMode == 3)
|
||||
{
|
||||
List<GameObject> opposingArmy = armyManagerScript.getArmy(!isEnemy);
|
||||
if (opposingArmy.Count > 0){
|
||||
GameObject closestOpponent = opposingArmy[0];
|
||||
float closestDistance = Vector3.Distance(opposingArmy[0].transform.position, armyManagerScript.getCrownDuck(isEnemy).transform.position);
|
||||
foreach (GameObject opposingDuck in opposingArmy)
|
||||
{
|
||||
if (Vector3.Distance(opposingDuck.transform.position, armyManagerScript.getCrownDuck(isEnemy).transform.position) < closestDistance)
|
||||
{
|
||||
closestOpponent = opposingDuck;
|
||||
closestDistance = Vector3.Distance(opposingDuck.transform.position, armyManagerScript.getCrownDuck(isEnemy).transform.position);
|
||||
}
|
||||
}
|
||||
destination = closestOpponent.transform.position;
|
||||
agent.destination = destination;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setTeam(bool isOnEnemyTeam){
|
||||
isEnemy = isOnEnemyTeam;
|
||||
}
|
||||
|
||||
public void giveCrown(){
|
||||
hasCrown = true;
|
||||
}
|
||||
|
||||
public void setArmyManager(GameObject armyManagerEntity)
|
||||
{
|
||||
this.armyManagerEntity = armyManagerEntity;
|
||||
}
|
||||
|
||||
public ArmyManager getArmyManagerScript()
|
||||
{
|
||||
return armyManagerScript;
|
||||
}
|
||||
public void setGameManager(GameObject gameManagerEntity)
|
||||
{
|
||||
this.gameManagerEntity = gameManagerEntity;
|
||||
}
|
||||
|
||||
public void becomeCrownDuck()
|
||||
{
|
||||
hasCrown = true;
|
||||
armyManagerScript.setCrownDuck(isEnemy, gameObject);
|
||||
crown = Instantiate(crownPrefab, this.transform);
|
||||
}
|
||||
|
||||
public void loseMyCrown()
|
||||
{
|
||||
hasCrown = false;
|
||||
armyManagerScript.removeCrownDuck(isEnemy);
|
||||
Destroy(crown);
|
||||
}
|
||||
|
||||
public void despawn()
|
||||
{
|
||||
if (hasCrown)
|
||||
{
|
||||
armyManagerScript.removeCrownDuck(isEnemy);
|
||||
}
|
||||
armyManagerScript.removeTroopFromArmy(isEnemy, gameObject);
|
||||
gameManagerScript.refundCoins(cost);
|
||||
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
|
@ -228,7 +143,7 @@ public class BaseDuckScript : MonoBehaviour
|
|||
*/
|
||||
}
|
||||
|
||||
public void TakeDamage(float damage)
|
||||
public override void TakeDamage(float damage)
|
||||
{
|
||||
float damageReallyTaken = Mathf.Max(0, damage - armor);
|
||||
health -= damageReallyTaken;
|
||||
|
@ -239,12 +154,28 @@ public class BaseDuckScript : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
public void Heal(float value)
|
||||
public override void Heal(float value)
|
||||
{
|
||||
health += value;
|
||||
health = (health > baseHealth) ? baseHealth : health;
|
||||
}
|
||||
|
||||
public override void AddArmor(float armor)
|
||||
{
|
||||
// Nothing
|
||||
}
|
||||
|
||||
public override void RemoveArmor(float armor)
|
||||
{
|
||||
// Nothing
|
||||
}
|
||||
|
||||
public override void StartFight()
|
||||
{
|
||||
// Nothing
|
||||
}
|
||||
|
||||
|
||||
public float getHealth()
|
||||
{
|
||||
return health;
|
||||
|
@ -257,7 +188,6 @@ public class BaseDuckScript : MonoBehaviour
|
|||
private void die()
|
||||
{
|
||||
Destroy(healthBar);
|
||||
armyManagerScript.kill(isEnemy, gameObject, hasCrown);
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
|
@ -286,8 +216,4 @@ public class BaseDuckScript : MonoBehaviour
|
|||
this.healthCanvas = healthCanvas;
|
||||
}
|
||||
|
||||
public GameManager getGameManagerScript()
|
||||
{
|
||||
return(gameManagerScript);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,89 +0,0 @@
|
|||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
public class CharDuck : MonoBehaviour
|
||||
{
|
||||
private Rigidbody rib;
|
||||
[SerializeField] GameObject Lazer;
|
||||
[SerializeField] GameObject LazerBoom;
|
||||
[SerializeField] GameObject Gauche;
|
||||
[SerializeField] GameObject Droit;
|
||||
[SerializeField] GameObject Tete;
|
||||
[SerializeField] float ForceTir;
|
||||
private bool Shoot=true;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
GetComponent<AttackCAC>().changeCACouDistance(false);
|
||||
AttackCAC.ATTACK += Attack;
|
||||
}
|
||||
|
||||
void Attack()
|
||||
{
|
||||
if (Shoot)
|
||||
{
|
||||
Debug.Log("Attaque");
|
||||
StartCoroutine(Lasers());
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
/*
|
||||
//à supprimer
|
||||
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.B))
|
||||
{
|
||||
if (Shoot)
|
||||
{
|
||||
Debug.Log("Attack !!");
|
||||
StartCoroutine(Lasers());
|
||||
}
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.P))
|
||||
{
|
||||
Debug.Log("Explosion");
|
||||
StartCoroutine(Special());
|
||||
|
||||
}
|
||||
*/
|
||||
}
|
||||
//Tire des Lasers des yeux du pion vers la cible (Target). Donc rbg=RigidBodyGauche par exemple.
|
||||
IEnumerator Lasers()
|
||||
{
|
||||
Shoot = false;
|
||||
GameObject Target = GetComponent<AttackCAC>().GetTarget();
|
||||
Vector3 Destination = Vector3.Normalize(Target.transform.position-transform.position);
|
||||
GameObject LazGauche = Instantiate(Lazer, Gauche.transform.position, Gauche.transform.rotation);
|
||||
Rigidbody rbg = LazGauche.GetComponent<Rigidbody>();
|
||||
rbg.AddForce(Destination * ForceTir, ForceMode.Impulse);
|
||||
GameObject LazDroite = Instantiate(Lazer, Droit.transform.position, Droit.transform.rotation);
|
||||
Rigidbody rbd = LazDroite.GetComponent<Rigidbody>();
|
||||
rbd.AddForce(Destination * ForceTir, ForceMode.Impulse);
|
||||
yield return null;
|
||||
Shoot = true;
|
||||
}
|
||||
//Génere une sphère qui se dirige vers sa cible (Target) pour faire une explosion
|
||||
IEnumerator Special()
|
||||
{
|
||||
Shoot = false;
|
||||
GameObject Target = GetComponent<AttackCAC>().GetTarget();
|
||||
Vector3 Destination = Vector3.Normalize(Target.transform.position - transform.position);
|
||||
//Vector3 Salse = new Vector3(0, -1, 0);
|
||||
GameObject Laz = Instantiate(LazerBoom, Tete.transform.position, Tete.transform.rotation);
|
||||
Rigidbody rb = Laz.GetComponent<Rigidbody>();
|
||||
rb.AddForce(Destination * ForceTir, ForceMode.Impulse);
|
||||
//rb.AddForce(Salse * ForceTir, ForceMode.Impulse);
|
||||
yield return null;
|
||||
Shoot = true;
|
||||
}
|
||||
//On tue le signal pour éviter tout problèmes (conseil de Game Jam)
|
||||
void OnDestroy()
|
||||
{
|
||||
AttackCAC.ATTACK -= Attack;
|
||||
}
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7c6232b4da47c4448b112c51f245a9f7
|
|
@ -1,89 +0,0 @@
|
|||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
public class ExplosifDuck : MonoBehaviour
|
||||
{
|
||||
|
||||
private Rigidbody rib;
|
||||
float Speed;
|
||||
float Cooldown=10.0f;
|
||||
[SerializeField] float explosionRadius;
|
||||
[SerializeField] float explosionForce;
|
||||
[SerializeField] float RangeExplosion;
|
||||
private float upwardModifier = 0.0f;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
GetComponent<AttackCAC>().changeCACouDistance(true);
|
||||
Speed = GetComponent<BaseDuckScript>().getSpeed();
|
||||
AttackCAC.ATTACK += Attack;
|
||||
}
|
||||
|
||||
void Attack()
|
||||
{
|
||||
Debug.Log("Attaque");
|
||||
Explode();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
GameObject Target = GetComponent<AttackCAC>().GetTarget();
|
||||
if (Target != null)
|
||||
{
|
||||
Vector3 RangeWeapon = Target.transform.position - transform.position;
|
||||
if (RangeWeapon.magnitude < RangeExplosion)
|
||||
{
|
||||
Attack();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (Input.GetKey(KeyCode.B))
|
||||
{
|
||||
StartCoroutine(Boost());
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.P))
|
||||
{
|
||||
Debug.Log("Explosion");
|
||||
Explode();
|
||||
|
||||
}
|
||||
}
|
||||
//Le speed est utilisé ici pour son spécial lui permettant de boost. On peut créer une fonction public dans BaseDuckScript getSpeed
|
||||
//Et changeSpeed permettant de manipuler la Speed du duck. Vestige de l'ancien code qui ne mérite pas d'être supprimé actuellement
|
||||
//C'est un cut content, donc ça passe
|
||||
IEnumerator Boost()
|
||||
{
|
||||
Speed=12.0f;
|
||||
yield return new WaitForSeconds(Cooldown);
|
||||
Speed = 6.0f;
|
||||
|
||||
}
|
||||
//Prend tout les rigidbody sauf le sien et leurs applique une force pour les expulser
|
||||
void Explode()
|
||||
{
|
||||
rib = GetComponent<Rigidbody>();
|
||||
Vector3 explosionPosition = transform.position;
|
||||
Collider[] colliders = Physics.OverlapSphere(explosionPosition, explosionRadius);
|
||||
|
||||
foreach (Collider collider in colliders)
|
||||
{
|
||||
Rigidbody rb = collider.GetComponent<Rigidbody>();
|
||||
if (rb != null & rb != rib)
|
||||
{
|
||||
rb.AddExplosionForce(explosionForce, explosionPosition, explosionRadius, upwardModifier, ForceMode.Impulse);
|
||||
}
|
||||
}
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
|
||||
//On tue le signal pour eviter tout problemes (conseil de Game Jam)
|
||||
void OnDestroy()
|
||||
{
|
||||
AttackCAC.ATTACK -= Attack;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3c634d25b1c457f42ade841848d6f3ff
|
|
@ -1,82 +0,0 @@
|
|||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class SniperDuck : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject Bout;
|
||||
[SerializeField] private GameObject Balle;
|
||||
private float Cooldown;
|
||||
[SerializeField] private float ForceTir;
|
||||
private Rigidbody rib;
|
||||
private bool Shoot = true;
|
||||
Vector3 STAY;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
GetComponent<AttackCAC>().changeCACouDistance(false);
|
||||
AttackCAC.ATTACK += Attack;
|
||||
STAY=transform.position;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
|
||||
void Attack()
|
||||
{
|
||||
if(Shoot)
|
||||
{
|
||||
Debug.Log("Attaque");
|
||||
StartCoroutine(Tir());
|
||||
}
|
||||
}
|
||||
void Update()
|
||||
{
|
||||
transform.position = STAY;
|
||||
rib = GetComponent<Rigidbody>();
|
||||
//rib.linearVelocity = Vector3.zero;
|
||||
/*
|
||||
if (Input.GetKeyDown(KeyCode.R))
|
||||
{
|
||||
|
||||
if (Shoot)
|
||||
{
|
||||
Debug.Log("Attaque");
|
||||
StartCoroutine(Tir());
|
||||
}
|
||||
|
||||
}
|
||||
if (Input.GetKeyDown(KeyCode.P))
|
||||
{
|
||||
Debug.Log("Special");
|
||||
StartCoroutine(Special());
|
||||
}
|
||||
*/
|
||||
}
|
||||
//Tir. La variable Shoot est le garde-fou pour <20>viter de tirer sans prendre en compte le cooldown
|
||||
IEnumerator Tir()
|
||||
{
|
||||
Shoot = false;
|
||||
GameObject BULLET = Instantiate(Balle, Bout.transform.position, Bout.transform.rotation);
|
||||
BULLET.GetComponent<Lazer>().parent = this.gameObject;
|
||||
BULLET.GetComponent<Lazer>().damage = GetComponent<AttackCAC>().GetDamage();
|
||||
Rigidbody rb = BULLET.GetComponent<Rigidbody>();
|
||||
rb.AddForce(transform.forward * ForceTir, ForceMode.Impulse);
|
||||
yield return null;
|
||||
Shoot = true;
|
||||
}
|
||||
//Le cooldown est utilisé ici pour son spécial lui permettant de mitrailler. On peut créer une fonction public dans BaseDuckScript getCooldown
|
||||
//Et changeCooldown permettant de manipuler le cooldown du duck. Vestige de l'ancien code qui ne mérite pas d'être supprimé actuellement
|
||||
//C'est un cut content, donc ça passe
|
||||
IEnumerator Special()
|
||||
{
|
||||
float BackupCooldown = Cooldown;
|
||||
Cooldown = 1.0f;
|
||||
yield return new WaitForSeconds(5.0f);
|
||||
Cooldown = BackupCooldown;
|
||||
}
|
||||
//On tue le signal pour eviter tout problemes (conseil de Game Jam)
|
||||
void OnDestroy()
|
||||
{
|
||||
AttackCAC.ATTACK -= Attack;
|
||||
}
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: eb4b255c02b8f984c82ab2f6417b637c
|
|
@ -1,51 +0,0 @@
|
|||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class TankDuck : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject Bout;
|
||||
[SerializeField] private GameObject Balle;
|
||||
[SerializeField] private float ForceTir;
|
||||
private bool Shoot = true;
|
||||
private Rigidbody rib;
|
||||
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
GetComponent<AttackCAC>().changeCACouDistance(false);
|
||||
AttackCAC.ATTACK += Attack;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Attack()
|
||||
{
|
||||
if (Shoot)
|
||||
{
|
||||
Debug.Log("Attaque");
|
||||
StartCoroutine(Tir());
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator Tir()
|
||||
{
|
||||
Shoot = false;
|
||||
GameObject BULLET = Instantiate(Balle, Bout.transform.position, Bout.transform.rotation);
|
||||
Rigidbody rb = BULLET.GetComponent<Rigidbody>();
|
||||
rb.AddForce(transform.forward * ForceTir, ForceMode.Impulse);
|
||||
yield return null;
|
||||
Shoot = true;
|
||||
}
|
||||
//On tue le signal pour eviter tout problemes (conseil de Game Jam)
|
||||
void OnDestroy()
|
||||
{
|
||||
AttackCAC.ATTACK -= Attack;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f0d84792271c3c847ad22f08b0cc2fcd
|
|
@ -1,98 +0,0 @@
|
|||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
public class TimeDuck: MonoBehaviour
|
||||
{
|
||||
|
||||
private Rigidbody rib;
|
||||
float Speed;
|
||||
private float cooldown = 5.0f;
|
||||
[SerializeField] float explosionRadius;
|
||||
[SerializeField] float RangeExplosion;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
Speed = GetComponent<BaseDuckScript>().getSpeed();
|
||||
GetComponent<AttackCAC>().changeCACouDistance(true);
|
||||
AttackCAC.ATTACK += Attack;
|
||||
}
|
||||
|
||||
void Attack()
|
||||
{
|
||||
Debug.Log("Attaque TIME");
|
||||
StartCoroutine(Explode());
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
//Prend sa cible et regarde sa distance pour voir quelle arme prendre contre lui
|
||||
GameObject Target = GetComponent<AttackCAC>().GetTarget();
|
||||
if (Target != null)
|
||||
{
|
||||
Vector3 RangeWeapon = Target.transform.position - transform.position;
|
||||
if (RangeWeapon.magnitude < RangeExplosion)
|
||||
{
|
||||
Attack();
|
||||
}
|
||||
}
|
||||
/*
|
||||
//à supprimer
|
||||
if (Input.GetKey(KeyCode.B))
|
||||
{
|
||||
StartCoroutine(Boost());
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.P))
|
||||
{
|
||||
Debug.Log("Explosion");
|
||||
StartCoroutine(Explode());
|
||||
}
|
||||
*/
|
||||
}
|
||||
//Le speed est utilisé ici pour son spécial lui permettant de boost. On peut créer une fonction public dans BaseDuckScript getSpeed
|
||||
//Et changeSpeed permettant de manipuler la Speed du duck. Vestige de l'ancien code qui ne mérite pas d'être supprimé actuellement
|
||||
//C'est un cut content, donc ça passe
|
||||
IEnumerator Boost()
|
||||
{
|
||||
Speed = 12.0f;
|
||||
yield return null;
|
||||
Speed = 5.0f;
|
||||
|
||||
}
|
||||
|
||||
IEnumerator Explode()
|
||||
{
|
||||
rib = GetComponent<Rigidbody>();
|
||||
Vector3 explosionPosition = transform.position;
|
||||
Collider[] colliders = Physics.OverlapSphere(explosionPosition, explosionRadius);
|
||||
foreach (Collider collider in colliders)
|
||||
{
|
||||
Rigidbody rb = collider.GetComponent<Rigidbody>();
|
||||
if (LayerMask.LayerToName(collider.gameObject.layer)=="duck")
|
||||
{
|
||||
if (rb != null & rb != rib)
|
||||
{
|
||||
rb.isKinematic = true;
|
||||
collider.GetComponent<AttackCAC>().enabled = false;
|
||||
rb.linearVelocity = Vector3.zero;
|
||||
yield return new WaitForSeconds(cooldown);
|
||||
rb.isKinematic = false;
|
||||
collider.GetComponent<AttackCAC>().enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Destroy(this.gameObject);
|
||||
|
||||
}
|
||||
|
||||
//On tue le signal pour eviter tout problemes (conseil de Game Jam)
|
||||
void OnDestroy()
|
||||
{
|
||||
AttackCAC.ATTACK -= Attack;
|
||||
}
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 983a511a5a7517b478b8909da220e895
|
|
@ -1,23 +0,0 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class Lazer : MonoBehaviour
|
||||
{
|
||||
private float i = 0.0f;
|
||||
public float damage;
|
||||
public GameObject parent;
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
//Uniformisation des codes de balles, pour la détruire au 2e impact avec un collider dû au fait qu'elle spawn DANS un collider
|
||||
//Reste clairement Junky et est sujet à amélioration
|
||||
i += 1;
|
||||
if (i>0)
|
||||
{
|
||||
if (LayerMask.LayerToName(other.gameObject.layer) == "Duck")
|
||||
{
|
||||
other.gameObject.GetComponent<BaseDuckScript>().TakeDamage(damage);
|
||||
}
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: bc1391a204a039347a760eb627956852
|
|
@ -2,106 +2,25 @@ using UnityEngine;
|
|||
using System.Collections.Generic;
|
||||
|
||||
|
||||
public class ArmyManager : MonoBehaviour
|
||||
public static class ArmyManager
|
||||
{
|
||||
private List<GameObject> enemyArmy = new List<GameObject>();
|
||||
private List<GameObject> playerArmy = new List<GameObject>();
|
||||
private GameObject enemyCrownDuck = null;
|
||||
private GameObject playerCrownDuck = null;
|
||||
[SerializeField] private GameManager gameManagerScript;
|
||||
private static List<GameObject> enemyArmy = new List<GameObject>();
|
||||
private static List<GameObject> playerArmy = new List<GameObject>();
|
||||
private static GameObject enemyCrownDuck = null;
|
||||
private static GameObject playerCrownDuck = null;
|
||||
|
||||
|
||||
public static List<AbstractUnit> getArmy(bool isEnemy)
|
||||
{
|
||||
List<AbstractUnit> units = (isEnemy ? GlobalsVariable.AliveUnitsTeamB : GlobalsVariable.AliveUnitsTeamA);
|
||||
return units;
|
||||
}
|
||||
|
||||
|
||||
public static GameObject getCrownDuck(bool isEnemy)
|
||||
{
|
||||
return(isEnemy ? GlobalsVariable.QueenB.gameObject : GlobalsVariable.QueenA.gameObject);
|
||||
}
|
||||
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
//Debug.Log("Enemy Count : " + enemyArmy.Count);
|
||||
//Debug.Log("Player Count : " + playerArmy.Count);
|
||||
//Debug.Log(playerCrownDuck);
|
||||
}
|
||||
|
||||
public List<GameObject> getArmy(bool isEnemy){
|
||||
return(isEnemy ? enemyArmy : playerArmy);
|
||||
}
|
||||
|
||||
public void addTroopToArmy(bool isEnemy, GameObject Duck){
|
||||
(isEnemy ? enemyArmy : playerArmy).Add(Duck);
|
||||
}
|
||||
|
||||
public void removeTroopFromArmy(bool isEnemy, GameObject Duck)
|
||||
{
|
||||
(isEnemy ? enemyArmy : playerArmy).Remove(Duck);
|
||||
}
|
||||
|
||||
public void setCrownDuck(bool isEnemy, GameObject CrownDuck)
|
||||
{
|
||||
if (isEnemy) {
|
||||
enemyCrownDuck = CrownDuck;
|
||||
} else {
|
||||
playerCrownDuck = CrownDuck;
|
||||
}
|
||||
}
|
||||
|
||||
public void removeCrownDuck(bool isEnemy)
|
||||
{
|
||||
if (isEnemy)
|
||||
{
|
||||
enemyCrownDuck = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
playerCrownDuck = null;
|
||||
}
|
||||
}
|
||||
|
||||
public GameObject getCrownDuck(bool isEnemy)
|
||||
{
|
||||
return(isEnemy ? enemyCrownDuck : playerCrownDuck);
|
||||
}
|
||||
|
||||
public void kill(bool isEnemy, GameObject Duck, bool hasCrown)
|
||||
{
|
||||
removeTroopFromArmy(isEnemy, Duck);
|
||||
if (hasCrown)
|
||||
{
|
||||
gameManagerScript.endOfLevel(isEnemy);
|
||||
}
|
||||
removeTroopFromArmy(isEnemy, gameObject);
|
||||
}
|
||||
|
||||
public void giveCrownDuckTo(bool isEnemy, GameObject duckToCrown)
|
||||
{
|
||||
if ((isEnemy ? enemyCrownDuck : playerCrownDuck) != null)
|
||||
{
|
||||
(isEnemy ? enemyCrownDuck : playerCrownDuck).GetComponent<BaseDuckScript>().loseMyCrown();
|
||||
if (isEnemy)
|
||||
{
|
||||
enemyCrownDuck = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
playerCrownDuck = null;
|
||||
}
|
||||
}
|
||||
|
||||
//becomeCrownDuck will call army manager later and set it locally
|
||||
duckToCrown.GetComponent<BaseDuckScript>().becomeCrownDuck();
|
||||
}
|
||||
|
||||
public void removeCrownDuckFrom(bool isEnemy, GameObject duckToRemoveCrown)
|
||||
{
|
||||
(isEnemy ? enemyCrownDuck : playerCrownDuck).GetComponent<BaseDuckScript>().loseMyCrown();
|
||||
if (isEnemy)
|
||||
{
|
||||
enemyCrownDuck = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
playerCrownDuck = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,211 +0,0 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
using UnityEngine.SceneManagement;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class GameManager : MonoBehaviour
|
||||
{
|
||||
public bool difficultySelectionPhase = true;
|
||||
public bool spawningPhase = false;
|
||||
|
||||
public bool combatPhase = false;
|
||||
public bool endOfGamePhase = false;
|
||||
|
||||
public bool foundWinner = false;
|
||||
|
||||
public bool playerWon;
|
||||
[SerializeField] public int currentLevel;
|
||||
[SerializeField] public int difficulty;
|
||||
[SerializeField] public ArmyManager armyManager;
|
||||
[SerializeField] public UnlockedLevelsManager unlockedLevelsManager;
|
||||
[SerializeField] public int baseCoins;
|
||||
[SerializeField] public int currentCoins;
|
||||
[SerializeField] private GameObject coinDisplay;
|
||||
private TextMeshProUGUI coinDisplayMesh;
|
||||
[SerializeField] public GameObject healthCanvas;
|
||||
[SerializeField] public GameObject wonCanvas;
|
||||
[SerializeField] public GameObject lostCanvas;
|
||||
[SerializeField] private GameObject coinDisplayCanvas;
|
||||
[SerializeField] private GameObject difficultySelectionCanvas;
|
||||
[SerializeField] private GameObject troopSelectionCanvas;
|
||||
[SerializeField] private RawImage highScoreImage;
|
||||
[SerializeField] private RawImage winHighScoreImage;
|
||||
[SerializeField] private RawImage loseHighScoreImage;
|
||||
[SerializeField] private Texture bronzeSprite;
|
||||
[SerializeField] private Texture silverSprite;
|
||||
[SerializeField] private Texture goldSprite;
|
||||
[SerializeField] private Texture notBeatenSprite;
|
||||
[SerializeField] public List<string> levels;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
wonCanvas.SetActive(false);
|
||||
lostCanvas.SetActive(false);
|
||||
coinDisplayCanvas.SetActive(false);
|
||||
troopSelectionCanvas.SetActive(false);
|
||||
coinDisplayMesh = coinDisplay.GetComponent<TextMeshProUGUI>();
|
||||
|
||||
int highScore = unlockedLevelsManager.getLevelStatus(currentLevel);
|
||||
switch (highScore)
|
||||
{
|
||||
case 0:
|
||||
highScoreImage.texture = notBeatenSprite;
|
||||
break;
|
||||
case 1:
|
||||
highScoreImage.texture = notBeatenSprite;
|
||||
break;
|
||||
case 2:
|
||||
highScoreImage.texture = bronzeSprite;
|
||||
break;
|
||||
case 3:
|
||||
highScoreImage.texture = silverSprite;
|
||||
break;
|
||||
case 4:
|
||||
highScoreImage.texture = goldSprite;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
coinDisplayMesh.text = currentCoins.ToString();
|
||||
/*
|
||||
if (Input.GetKeyDown(KeyCode.Return))
|
||||
{
|
||||
if (spawningPhase)
|
||||
{
|
||||
startFight();
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public void startFight()
|
||||
{
|
||||
troopSelectionCanvas.SetActive(false);
|
||||
spawningPhase = false;
|
||||
combatPhase = true;
|
||||
if (armyManager.getArmy(true).Count == 0)
|
||||
{
|
||||
foundWinner = true;
|
||||
playerWon = true;
|
||||
} else if (armyManager.getArmy(false).Count == 0)
|
||||
{
|
||||
foundWinner = true;
|
||||
playerWon = false;
|
||||
} else {
|
||||
if (!armyManager.getCrownDuck(true))
|
||||
{
|
||||
armyManager.getArmy(true)[0].GetComponent<BaseDuckScript>().becomeCrownDuck();
|
||||
}
|
||||
if (!armyManager.getCrownDuck(false))
|
||||
{
|
||||
armyManager.getArmy(false)[0].GetComponent<BaseDuckScript>().becomeCrownDuck();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void endOfLevel(bool thePlayerWon)
|
||||
{
|
||||
combatPhase = false;
|
||||
endOfGamePhase = true;
|
||||
foundWinner = true;
|
||||
playerWon = thePlayerWon;
|
||||
coinDisplayCanvas.SetActive(false);
|
||||
healthCanvas.SetActive(false);
|
||||
if (playerWon)
|
||||
{
|
||||
unlockedLevelsManager.beatCurrentLevel(currentLevel, difficulty);
|
||||
wonCanvas.SetActive(true);
|
||||
int highScore = unlockedLevelsManager.getLevelStatus(currentLevel);
|
||||
switch (highScore)
|
||||
{
|
||||
case 0:
|
||||
winHighScoreImage.texture = notBeatenSprite;
|
||||
break;
|
||||
case 1:
|
||||
winHighScoreImage.texture = notBeatenSprite;
|
||||
break;
|
||||
case 2:
|
||||
winHighScoreImage.texture = bronzeSprite;
|
||||
break;
|
||||
case 3:
|
||||
winHighScoreImage.texture = silverSprite;
|
||||
break;
|
||||
case 4:
|
||||
winHighScoreImage.texture = goldSprite;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lostCanvas.SetActive(true);
|
||||
int highScore = unlockedLevelsManager.getLevelStatus(currentLevel);
|
||||
switch (highScore)
|
||||
{
|
||||
case 0:
|
||||
loseHighScoreImage.texture = notBeatenSprite;
|
||||
break;
|
||||
case 1:
|
||||
loseHighScoreImage.texture = notBeatenSprite;
|
||||
break;
|
||||
case 2:
|
||||
loseHighScoreImage.texture = bronzeSprite;
|
||||
break;
|
||||
case 3:
|
||||
loseHighScoreImage.texture = silverSprite;
|
||||
break;
|
||||
case 4:
|
||||
loseHighScoreImage.texture = goldSprite;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool spendCoins(int amount)
|
||||
{
|
||||
if (currentCoins >= amount)
|
||||
{
|
||||
currentCoins -= amount;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void refundCoins(int amount)
|
||||
{
|
||||
currentCoins += amount;
|
||||
}
|
||||
|
||||
public void SelectDifficulty(int selectedDifficulty)
|
||||
{
|
||||
difficultySelectionPhase = false;
|
||||
spawningPhase = true;
|
||||
difficulty = selectedDifficulty;
|
||||
coinDisplayCanvas.SetActive(true);
|
||||
troopSelectionCanvas.SetActive(true);
|
||||
difficultySelectionCanvas.SetActive(false);
|
||||
currentCoins = (int)(baseCoins * (difficulty == 1 ? 1.2f : (difficulty == 3 ? 0.8f : 1f)));
|
||||
}
|
||||
|
||||
public void backToMainMenu()
|
||||
{
|
||||
SceneManager.LoadScene(0);
|
||||
}
|
||||
|
||||
public void goToNextLevel()
|
||||
{
|
||||
SceneManager.LoadScene(levels[currentLevel]);
|
||||
}
|
||||
|
||||
public void replayLevel()
|
||||
{
|
||||
SceneManager.LoadScene(levels[currentLevel-1]);
|
||||
}
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6b44c52b4de179af282b4cf5f073b748
|
|
@ -1,95 +0,0 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class MenuManager : MonoBehaviour
|
||||
{
|
||||
[SerializeField] public GameObject mainPanel;
|
||||
[SerializeField] public GameObject settingsPanel;
|
||||
[SerializeField] public GameObject levelsPanel;
|
||||
[SerializeField] public UnlockedLevelsManager unlockedLevelsManager;
|
||||
[SerializeField] public List<GameObject> levelButtons;
|
||||
[SerializeField] public GameObject lockPrefab;
|
||||
[SerializeField] public GameObject bronzeStarPrefab;
|
||||
[SerializeField] public GameObject silverStarPrefab;
|
||||
[SerializeField] public GameObject goldStarPrefab;
|
||||
[SerializeField] public List<string> levels;
|
||||
|
||||
void Start()
|
||||
{
|
||||
mainPanel.SetActive(true);
|
||||
settingsPanel.SetActive(false);
|
||||
levelsPanel.SetActive(false);
|
||||
|
||||
for (int i = 0; i < levelButtons.Count; i++)
|
||||
{
|
||||
bool didSpawn = false;
|
||||
GameObject spawnedUI = null;
|
||||
switch (unlockedLevelsManager.getLevelStatus(i+1))
|
||||
{
|
||||
case 0:
|
||||
didSpawn = true;
|
||||
spawnedUI = Instantiate(lockPrefab);
|
||||
break;
|
||||
case 2:
|
||||
didSpawn = true;
|
||||
spawnedUI = Instantiate(bronzeStarPrefab);
|
||||
break;
|
||||
case 3:
|
||||
didSpawn = true;
|
||||
spawnedUI = Instantiate(silverStarPrefab);
|
||||
break;
|
||||
case 4:
|
||||
didSpawn = true;
|
||||
spawnedUI = Instantiate(goldStarPrefab);
|
||||
break;
|
||||
}
|
||||
|
||||
if (didSpawn)
|
||||
{
|
||||
spawnedUI.transform.SetParent(levelButtons[i].transform, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void StartGame()
|
||||
{
|
||||
mainPanel.SetActive(false);
|
||||
levelsPanel.SetActive(true);
|
||||
//SceneManager.LoadScene("GameScene"); // Replace "GameScene" with your scene name
|
||||
}
|
||||
|
||||
public void OpenSettings()
|
||||
{
|
||||
mainPanel.SetActive(false);
|
||||
settingsPanel.SetActive(true);
|
||||
}
|
||||
|
||||
public void QuitGame()
|
||||
{
|
||||
Debug.Log("Quit Game"); // This won't quit the editor but will work in a built application
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
public void backToMenu()
|
||||
{
|
||||
mainPanel.SetActive(true);
|
||||
settingsPanel.SetActive(false);
|
||||
levelsPanel.SetActive(false);
|
||||
Debug.Log("Back To Menu"); // This won't quit the editor but will work in a built application
|
||||
}
|
||||
|
||||
public void goToLevel(int level)
|
||||
{
|
||||
//Debug.Log(unlockedLevelsManager.getLevelStatus(level));
|
||||
if (unlockedLevelsManager.getLevelStatus(level) != 0)
|
||||
{
|
||||
SceneManager.LoadScene(levels[level - 1]);
|
||||
Debug.Log("Go To Level " + level);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e2f8d5c10ecc0fc1984f4b0913b0db37
|
|
@ -1,93 +0,0 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class PastilleManager : MonoBehaviour
|
||||
{
|
||||
[SerializeField] ArmyManager armyManagerScript;
|
||||
[SerializeField] SpawnDucks spawnManagerScript;
|
||||
[SerializeField] GameObject enemyPastillePrefab;
|
||||
[SerializeField] GameObject playerPastillePrefab;
|
||||
[SerializeField] GameObject selectedPastillePrefab;
|
||||
[SerializeField] GameManager gameManagerScript;
|
||||
|
||||
private bool removedPastilles = false;
|
||||
private bool addedInitialPastilles = false;
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
|
||||
if (!addedInitialPastilles && gameManagerScript.spawningPhase)
|
||||
{
|
||||
addedInitialPastilles = true;
|
||||
setEnemyPastilles();
|
||||
}
|
||||
|
||||
if (addedInitialPastilles && !removedPastilles && !gameManagerScript.spawningPhase)
|
||||
{
|
||||
removedPastilles = true;
|
||||
removeEnemyPastilles();
|
||||
removeTeamPastilles();
|
||||
};
|
||||
}
|
||||
|
||||
public void setEnemyPastilles()
|
||||
{
|
||||
foreach (GameObject enemyDuck in armyManagerScript.getArmy(true))
|
||||
{
|
||||
giveXPastilleToY(enemyPastillePrefab, enemyDuck);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeTeamPastilles()
|
||||
{
|
||||
foreach (GameObject playerDuck in armyManagerScript.getArmy(false))
|
||||
{
|
||||
removeTroopsPastilles(playerDuck);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeEnemyPastilles()
|
||||
{
|
||||
foreach (GameObject enemyDuck in armyManagerScript.getArmy(true))
|
||||
{
|
||||
removeTroopsPastilles(enemyDuck);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setSelectedPastille(GameObject troop)
|
||||
{
|
||||
removeTroopsPastilles(troop);
|
||||
giveXPastilleToY(selectedPastillePrefab, troop);
|
||||
}
|
||||
|
||||
public void setPlayerPastille(GameObject troop)
|
||||
{
|
||||
removeTroopsPastilles(troop);
|
||||
giveXPastilleToY(playerPastillePrefab, troop);
|
||||
}
|
||||
|
||||
public void removeTroopsPastilles(GameObject troop)
|
||||
{
|
||||
Transform PastilleSpawner = troop.transform.Find("pastilleSpawner");
|
||||
foreach (Transform child in PastilleSpawner)
|
||||
{
|
||||
if (child.CompareTag("Pastille"))
|
||||
{
|
||||
Destroy(child.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void giveXPastilleToY(GameObject pastille, GameObject troop)
|
||||
{
|
||||
Instantiate(pastille, troop.transform.Find("pastilleSpawner").transform);
|
||||
}
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 91334ba5025ad505fb2c78f519e24dec
|
|
@ -1,198 +0,0 @@
|
|||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
|
||||
public class SpawnDucks : MonoBehaviour
|
||||
{
|
||||
[SerializeField] GameObject armyManagerEntity;
|
||||
[SerializeField] GameObject gameManagerEntity;
|
||||
private GameManager gameManagerScript;
|
||||
private ArmyManager armyManagerScript;
|
||||
[SerializeField] private List<GameObject> duckPrefabs;
|
||||
[SerializeField] GameObject theCamera;
|
||||
[SerializeField] GameObject healthCanvas;
|
||||
[SerializeField] GameObject troopSelectionCanvas;
|
||||
//[SerializeField] private List<Sprite> duckImages;
|
||||
[SerializeField] private List<GameObject> troopIcons;
|
||||
[SerializeField] private Sprite chosenCadre;
|
||||
[SerializeField] private Sprite unchosenCadre;
|
||||
private LayerMask groundLayerMask;
|
||||
private LayerMask duckLayerMask;
|
||||
private LayerMask noSpawnLayerMask;
|
||||
private bool didHitGround;
|
||||
|
||||
private RaycastHit hitGround;
|
||||
private RaycastHit hitDuck;
|
||||
private RaycastHit hitNoSpawn;
|
||||
|
||||
private Vector3 directionToMouse;
|
||||
private int whichTroopToSpawn = 0;
|
||||
private GameObject currentlySpawningTroop;
|
||||
private GameObject selectedTroop;
|
||||
[SerializeField] public GameObject troopEditPanel;
|
||||
[SerializeField] private Button crownButton;
|
||||
[SerializeField] private Sprite hasCrownButton;
|
||||
[SerializeField] private Sprite noCrownButton;
|
||||
|
||||
[SerializeField] private Button offenseModeButton;
|
||||
[SerializeField] private Button randomModeButton;
|
||||
[SerializeField] private Button defenseModeButton;
|
||||
|
||||
[SerializeField] private Sprite offenseModeOff;
|
||||
[SerializeField] private Sprite offenseModeOn;
|
||||
[SerializeField] private Sprite randomModeOff;
|
||||
[SerializeField] private Sprite randomModeOn;
|
||||
[SerializeField] private Sprite defenseModeOff;
|
||||
[SerializeField] private Sprite defenseModeOn;
|
||||
private BaseDuckScript selectedTroopScript;
|
||||
[SerializeField] private PastilleManager pastilleManager;
|
||||
|
||||
[SerializeField] private TextMeshProUGUI priceTagMesh;
|
||||
[SerializeField] private TextMeshProUGUI healthTagMesh;
|
||||
[SerializeField] private TextMeshProUGUI movSpeedTagMesh;
|
||||
[SerializeField] private TextMeshProUGUI armorTagMesh;
|
||||
[SerializeField] private TextMeshProUGUI damageTagMesh;
|
||||
[SerializeField] private TextMeshProUGUI attackSpeedTagMesh;
|
||||
[SerializeField] private TextMeshProUGUI descriptionTagMesh;
|
||||
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
troopEditPanel.SetActive(false);
|
||||
groundLayerMask = LayerMask.GetMask("Dirt") | LayerMask.GetMask("Sand");
|
||||
duckLayerMask = LayerMask.GetMask("Duck");
|
||||
noSpawnLayerMask = LayerMask.GetMask("Water") | LayerMask.GetMask("Wall");
|
||||
currentlySpawningTroop = duckPrefabs[0];
|
||||
ActivateDuckCadre(0);
|
||||
updateTroopStats();
|
||||
gameManagerScript = gameManagerEntity.GetComponent<GameManager>();
|
||||
armyManagerScript = armyManagerEntity.GetComponent<ArmyManager>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
choseIfShowTroopEditPanel();
|
||||
if (Input.GetKeyDown(KeyCode.C))
|
||||
{
|
||||
deactivateDuckCadre(whichTroopToSpawn);
|
||||
whichTroopToSpawn++;
|
||||
whichTroopToSpawn = whichTroopToSpawn % troopIcons.Count;
|
||||
ActivateDuckCadre(whichTroopToSpawn);
|
||||
currentlySpawningTroop = duckPrefabs[whichTroopToSpawn];
|
||||
updateTroopStats();
|
||||
}
|
||||
|
||||
if (gameManagerScript.spawningPhase && Input.GetMouseButtonDown(0))
|
||||
{
|
||||
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
||||
didHitGround = Physics.Raycast(ray, out hitGround, Mathf.Infinity, groundLayerMask);
|
||||
bool didHitNoSpawn = Physics.Raycast(ray, out hitNoSpawn, Mathf.Infinity, noSpawnLayerMask);
|
||||
bool didHitDuck = Physics.Raycast(ray, out hitDuck, Mathf.Infinity, duckLayerMask);
|
||||
if (didHitDuck && (!didHitNoSpawn || hitDuck.distance < hitNoSpawn.distance) && (!didHitGround || hitDuck.distance <= hitGround.distance))
|
||||
{
|
||||
if (!hitDuck.transform.gameObject.GetComponent<BaseDuckScript>().getTeam())
|
||||
{
|
||||
setSelectedTroop(hitDuck.transform.gameObject);
|
||||
}
|
||||
} else if(didHitGround && (!didHitNoSpawn || hitGround.distance < hitNoSpawn.distance) && (!didHitDuck || hitGround.distance < hitDuck.distance)){
|
||||
if (currentlySpawningTroop.GetComponent<BaseDuckScript>().cost <= gameManagerScript.currentCoins)
|
||||
{
|
||||
GameObject newDuck = Instantiate(currentlySpawningTroop, (hitGround.point + new Vector3(0f, currentlySpawningTroop.transform.Find("TigeUI").GetComponent<Renderer>().bounds.size.y * 0.8f,0f)), Quaternion.identity);
|
||||
BaseDuckScript duckScript = newDuck.GetComponent<BaseDuckScript>();
|
||||
duckScript.setTeam(false);
|
||||
duckScript.setArmyManager(armyManagerEntity);
|
||||
duckScript.setGameManager(gameManagerEntity);
|
||||
duckScript.setHealthCanvas(healthCanvas);
|
||||
gameManagerScript.spendCoins(duckScript.cost);
|
||||
setSelectedTroop(newDuck);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateTroopStats()
|
||||
{
|
||||
List<string> troopStats = currentlySpawningTroop.GetComponent<BaseDuckScript>().troopStats;
|
||||
priceTagMesh.text = "Prix : " + troopStats[0];
|
||||
healthTagMesh.text = "PV : " + troopStats[1];
|
||||
movSpeedTagMesh.text = "Vitesse (Déplacement) : " + troopStats[2];
|
||||
armorTagMesh.text = "Armure : " + troopStats[3];
|
||||
damageTagMesh.text = "Dégats : " + troopStats[4];
|
||||
attackSpeedTagMesh.text = "Vitesse (Attaque) : " + troopStats[5];
|
||||
descriptionTagMesh.text = "Description : " + troopStats[6];
|
||||
}
|
||||
|
||||
public void choseIfShowTroopEditPanel()
|
||||
{
|
||||
if (selectedTroop != null)
|
||||
{
|
||||
troopEditPanel.SetActive(true);
|
||||
crownButton.image.sprite = (selectedTroopScript.hasCrown) ? hasCrownButton : noCrownButton;
|
||||
offenseModeButton.image.sprite = ((selectedTroopScript.getAttackMode() == 1) ? offenseModeOn : offenseModeOff);
|
||||
randomModeButton.image.sprite = ((selectedTroopScript.getAttackMode() == 2) ? randomModeOn : randomModeOff);
|
||||
defenseModeButton.image.sprite = ((selectedTroopScript.getAttackMode() == 3) ? defenseModeOn : defenseModeOff);
|
||||
}
|
||||
else
|
||||
{
|
||||
troopEditPanel.SetActive(false);
|
||||
}
|
||||
|
||||
}
|
||||
public void despawnSelectedDuck()
|
||||
{
|
||||
selectedTroopScript.despawn();
|
||||
selectedTroop = null;
|
||||
}
|
||||
|
||||
public void ActivateDuckCadre(int duck)
|
||||
{
|
||||
troopIcons[duck].gameObject.transform.GetChild(1).GetComponent<Image>().sprite = chosenCadre;
|
||||
}
|
||||
|
||||
public void deactivateDuckCadre(int duck)
|
||||
{
|
||||
troopIcons[duck].gameObject.transform.GetChild(1).GetComponent<Image>().sprite = unchosenCadre;
|
||||
}
|
||||
|
||||
public void giveCrownToSelected()
|
||||
{
|
||||
armyManagerScript.giveCrownDuckTo(false, selectedTroop);
|
||||
}
|
||||
|
||||
public void removeCrownFromSelected()
|
||||
{
|
||||
armyManagerScript.removeCrownDuckFrom(false, selectedTroop);
|
||||
}
|
||||
|
||||
public void toggleCrownFromSelected()
|
||||
{
|
||||
if (selectedTroopScript.hasCrown)
|
||||
{
|
||||
removeCrownFromSelected();
|
||||
}
|
||||
else
|
||||
{
|
||||
giveCrownToSelected();
|
||||
}
|
||||
}
|
||||
|
||||
public void setSelectedDuckMode(int mode)
|
||||
{
|
||||
selectedTroopScript.setAttackMode(mode);
|
||||
}
|
||||
|
||||
public void setSelectedTroop(GameObject troop)
|
||||
{
|
||||
if (selectedTroop != null)
|
||||
{
|
||||
pastilleManager.setPlayerPastille(selectedTroop);
|
||||
}
|
||||
selectedTroop = troop;
|
||||
selectedTroopScript = selectedTroop.GetComponent<BaseDuckScript>();
|
||||
pastilleManager.setSelectedPastille(troop);
|
||||
}
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0ed16af9570d167a2b8823760227756a
|
|
@ -1,68 +0,0 @@
|
|||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
public class UnlockedLevelsManager : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private bool mainMenuLevel;
|
||||
static public List<int> unlockedLevels = null; //0 = locked, 1 = unlocked not beaten, 2 = beaten easy, 3 = beaten medium, 4 = beaten hard
|
||||
private int howManyLevels = 5;
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
if (mainMenuLevel)
|
||||
{
|
||||
if (unlockedLevels == null){
|
||||
unlockedLevels = new List<int>();
|
||||
for (int i = 0; i < howManyLevels; i++)
|
||||
{
|
||||
unlockedLevels.Add(0);
|
||||
}
|
||||
|
||||
unlockedLevels[0] = 4;
|
||||
unlockedLevels[1] = 3;
|
||||
unlockedLevels[2] = 2;
|
||||
unlockedLevels[3] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void beatCurrentLevel(int currentLevel, int difficulty) //difficulty = 1,2,3
|
||||
{
|
||||
if (unlockedLevels != null){
|
||||
if (!mainMenuLevel)
|
||||
{
|
||||
if (currentLevel != howManyLevels - 1)
|
||||
{
|
||||
if (unlockedLevels[currentLevel] == 0)
|
||||
{
|
||||
unlockedLevels[currentLevel] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (unlockedLevels[currentLevel - 1] < difficulty + 1)
|
||||
{
|
||||
unlockedLevels[currentLevel - 1] = difficulty + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getLevelStatus(int level)
|
||||
{
|
||||
if (unlockedLevels != null)
|
||||
{
|
||||
return unlockedLevels[level - 1];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public List<int> getAllStatuses()
|
||||
{
|
||||
return unlockedLevels;
|
||||
}
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9f665727602dd2411b714a7aae91bf0d
|
|
@ -1,23 +0,0 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
|
||||
public class NavMeshJunk : MonoBehaviour
|
||||
{
|
||||
private NavMeshAgent agent;
|
||||
[SerializeField] Vector3 destination;
|
||||
[SerializeField] GameObject Arriv;
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
agent = GetComponent<NavMeshAgent>();
|
||||
destination = agent.destination;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
destination=Arriv.transform.position;
|
||||
agent.destination = destination;
|
||||
|
||||
}
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: adb0192ce72ebe549a6c031fa82c92a7
|
|
@ -1,37 +0,0 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class PVMETER : MonoBehaviour
|
||||
{
|
||||
[SerializeField] Image PVMeter;
|
||||
private float PVm;
|
||||
private float PVMax;
|
||||
public Gradient colorGradient;
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
Debug.Log("JE SUIS LA");
|
||||
var gradient = new Gradient();
|
||||
|
||||
var colors = new GradientColorKey[2];
|
||||
colors[0] = new GradientColorKey(Color.red, 0.0f);
|
||||
colors[1] = new GradientColorKey(Color.green, 1.0f);
|
||||
|
||||
var alphas = new GradientAlphaKey[2];
|
||||
alphas[0] = new GradientAlphaKey(1.0f, 0.0f);
|
||||
alphas[1] = new GradientAlphaKey(1.0f, 0.0f);
|
||||
|
||||
gradient.SetKeys(colors, alphas);
|
||||
|
||||
PVm = GetComponent<BaseDuckScript>().getHealth() / GetComponent<BaseDuckScript>().getBaseHealth();
|
||||
Debug.Log(PVm);
|
||||
PVMeter.fillAmount = PVm;
|
||||
PVMeter.color = colorGradient.Evaluate(PVm);
|
||||
}
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: cb0f365017cf19b4899eac2e66eecafb
|
|
@ -1,53 +0,0 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class PlayerJunkMVT : MonoBehaviour
|
||||
{
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
var gradient = new Gradient();
|
||||
|
||||
// Blend color from red at 0% to blue at 100%
|
||||
var colors = new GradientColorKey[2];
|
||||
colors[0] = new GradientColorKey(Color.red, 0.0f);
|
||||
colors[1] = new GradientColorKey(Color.green, 1.0f);
|
||||
|
||||
// Blend alpha from opaque at 0% to transparent at 100%
|
||||
var alphas = new GradientAlphaKey[2];
|
||||
alphas[0] = new GradientAlphaKey(1.0f, 0.0f);
|
||||
alphas[1] = new GradientAlphaKey(1.0f, 0.0f);
|
||||
|
||||
gradient.SetKeys(colors, alphas);
|
||||
|
||||
// What's the color at the relative time 0.25 (25%) ?
|
||||
Debug.Log(gradient.Evaluate(0.25f));
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
float SPEED = 10.0f;
|
||||
float ROT = 100.0f;
|
||||
if (Input.GetKey(KeyCode.UpArrow))
|
||||
{
|
||||
Debug.Log("avancer");
|
||||
transform.Translate(Vector3.forward * Time.deltaTime * SPEED);
|
||||
}
|
||||
if (Input.GetKey(KeyCode.DownArrow))
|
||||
{
|
||||
Debug.Log("reculer");
|
||||
transform.Translate(-Vector3.forward * Time.deltaTime * SPEED);
|
||||
}
|
||||
if (Input.GetKey(KeyCode.LeftArrow))
|
||||
{
|
||||
Debug.Log("tourner la tête à gauche");
|
||||
transform.Rotate(0.0f, -ROT * Time.deltaTime, 0.0f, Space.Self);
|
||||
}
|
||||
if (Input.GetKey(KeyCode.RightArrow))
|
||||
{
|
||||
Debug.Log("tourner la tête à droite");
|
||||
transform.Rotate(0.0f, ROT * Time.deltaTime, 0.0f, Space.Self);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a79444adcfdbaa841878f04f33784edb
|
|
@ -1,8 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 175007022ec6d7f3b8eb14971fed7fdd
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,16 +0,0 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class CoinManager : MonoBehaviour
|
||||
{
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: eb6be98e8ad485528a6f0241b6e6df90
|
|
@ -1,38 +0,0 @@
|
|||
using UnityEngine;
|
||||
using TMPro;
|
||||
|
||||
public class EnemiesAliveManager : MonoBehaviour
|
||||
{
|
||||
[SerializeField] GameManager gameManager;
|
||||
[SerializeField] GameObject enemiesAliveCanvas;
|
||||
[SerializeField] GameObject enemiesAliveDisplay;
|
||||
private TextMeshProUGUI enemiesAliveMesh;
|
||||
|
||||
private bool switchedCanvasOn = false;
|
||||
|
||||
private bool switchedCanvasOff = false;
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
enemiesAliveMesh = enemiesAliveDisplay.GetComponent<TextMeshProUGUI>();
|
||||
enemiesAliveCanvas.SetActive(false);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (!switchedCanvasOn && gameManager.combatPhase)
|
||||
{
|
||||
enemiesAliveCanvas.SetActive(true);
|
||||
switchedCanvasOn = true;
|
||||
}
|
||||
|
||||
if (switchedCanvasOn && !switchedCanvasOff && !gameManager.combatPhase)
|
||||
{
|
||||
enemiesAliveCanvas.SetActive(false);
|
||||
switchedCanvasOff = true;
|
||||
}
|
||||
|
||||
enemiesAliveMesh.text = "Ennemies En Vie : " + gameManager.armyManager.getArmy(true).Count.ToString();
|
||||
}
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d54fff469da868b898b10d9a2dadc850
|
|
@ -1,51 +0,0 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
public class ResolutionSettings : MonoBehaviour
|
||||
{
|
||||
[SerializeField] public TMP_Dropdown resolutionDropdown;
|
||||
private Resolution[] resolutions =
|
||||
{
|
||||
new Resolution {width = 1280, height = 720},
|
||||
new Resolution {width = 1920, height = 1080},
|
||||
new Resolution {width = 2560, height = 1440},
|
||||
new Resolution {width = 3840, height = 2160}
|
||||
};
|
||||
private int selectedIndex = 0;
|
||||
[SerializeField] private Button applyButton;
|
||||
|
||||
|
||||
void Start()
|
||||
{
|
||||
resolutionDropdown.ClearOptions();
|
||||
List<string> options = new List<string>();
|
||||
|
||||
for (int i = 0; i < resolutions.Length; i++)
|
||||
{
|
||||
string option = resolutions[i].width + " x " + resolutions[i].height;
|
||||
options.Add(option);
|
||||
}
|
||||
|
||||
resolutionDropdown.AddOptions(options);
|
||||
|
||||
int savedResolutionIndex = PlayerPrefs.GetInt("ResolutionIndex", 0);
|
||||
resolutionDropdown.value = savedResolutionIndex;
|
||||
resolutionDropdown.RefreshShownValue();
|
||||
}
|
||||
|
||||
public void SetResolution()
|
||||
{
|
||||
Resolution resolution = resolutions[selectedIndex];
|
||||
Debug.Log(resolution.width + " x " + resolution.height);
|
||||
Screen.SetResolution(resolution.width, resolution.height, Screen.fullScreen);
|
||||
|
||||
PlayerPrefs.SetInt("ResolutionIndex", selectedIndex);
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
|
||||
public void preSaveResolution()
|
||||
{
|
||||
selectedIndex = resolutionDropdown.value;
|
||||
}
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0698fd8378f2603d08fa38f7074a2ff3
|
|
@ -1,56 +0,0 @@
|
|||
using UnityEngine;
|
||||
using TMPro;
|
||||
|
||||
public class TimerManager : MonoBehaviour
|
||||
{
|
||||
[SerializeField] GameManager gameManager;
|
||||
[SerializeField] GameObject timerCanvas;
|
||||
[SerializeField] GameObject timer;
|
||||
private TextMeshProUGUI timerMesh;
|
||||
|
||||
[SerializeField] GameObject winTimer;
|
||||
private TextMeshProUGUI winTimerMesh;
|
||||
|
||||
[SerializeField] GameObject lostTimer;
|
||||
private TextMeshProUGUI lostTimerMesh;
|
||||
|
||||
|
||||
|
||||
private bool switchedCanvasOn = false;
|
||||
|
||||
private bool switchedCanvasOff = false;
|
||||
private float startTime;
|
||||
|
||||
private float endTime;
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
timerMesh = timer.GetComponent<TextMeshProUGUI>();
|
||||
winTimerMesh = winTimer.GetComponent<TextMeshProUGUI>();
|
||||
lostTimerMesh = lostTimer.GetComponent<TextMeshProUGUI>();
|
||||
timerCanvas.SetActive(false);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (!switchedCanvasOn && gameManager.combatPhase)
|
||||
{
|
||||
timerCanvas.SetActive(true);
|
||||
switchedCanvasOn = true;
|
||||
startTime = Time.time;
|
||||
}
|
||||
|
||||
if (switchedCanvasOn && !switchedCanvasOff && !gameManager.combatPhase)
|
||||
{
|
||||
timerCanvas.SetActive(false);
|
||||
switchedCanvasOff = true;
|
||||
endTime = Time.time-startTime;
|
||||
winTimerMesh.text = (((int)(endTime / 60)).ToString() + ":" + ((((int)(endTime) % 60) < 10) ? "0" : "") + ((int)(endTime) % 60).ToString());
|
||||
lostTimerMesh.text = (((int)(endTime / 60)).ToString() + ":" + ((((int)(endTime) % 60) < 10) ? "0" : "") + ((int)(endTime) % 60).ToString());
|
||||
}
|
||||
|
||||
float combatTime = Time.time - startTime;
|
||||
timerMesh.text = (((int)(combatTime / 60)).ToString() + ":" + ((((int)(combatTime) % 60) < 10) ? "0" : "") + ((int)(combatTime) % 60).ToString());
|
||||
}
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 307a1f6e5ebe37b4f89085a762648529
|
|
@ -1,6 +0,0 @@
|
|||
//using UnityEngine;
|
||||
|
||||
public interface Weapon
|
||||
{
|
||||
void dealDamage();
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7cedfc101377768d7ad55c639ea2f239
|
Loading…
Add table
Add a link
Reference in a new issue