Import
temp
This commit is contained in:
parent
a87f0ed109
commit
a17810ffeb
114 changed files with 5184 additions and 5 deletions
130
Assets/otherTeam/OtherScripts/DuckScript/AttackCAC.cs
Executable file
130
Assets/otherTeam/OtherScripts/DuckScript/AttackCAC.cs
Executable file
|
@ -0,0 +1,130 @@
|
|||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System;
|
||||
|
||||
public class AttackCAC : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private float range;
|
||||
[SerializeField] private float damage;
|
||||
[SerializeField] private float cooldown;
|
||||
private BaseDuckScript baseDuckScript;
|
||||
private LayerMask duckLayer; // Layer for ducks
|
||||
private LayerMask wallLayer;
|
||||
private GameObject targetToAttack;
|
||||
private bool CACouDistance; //True for CAC, False for Distance
|
||||
|
||||
|
||||
|
||||
private bool canAttack = true;
|
||||
|
||||
static public event Action ATTACK;
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
CACouDistance = false;
|
||||
baseDuckScript = gameObject.GetComponent<BaseDuckScript>();
|
||||
duckLayer = LayerMask.GetMask("Duck");
|
||||
wallLayer = LayerMask.GetMask("Wall");
|
||||
}
|
||||
|
||||
public bool changeCACouDistance(bool whichOne)
|
||||
{
|
||||
CACouDistance=whichOne;
|
||||
return(CACouDistance);
|
||||
}
|
||||
|
||||
IEnumerator coolDown()
|
||||
{
|
||||
canAttack = false;
|
||||
yield return new WaitForSeconds(cooldown);
|
||||
canAttack = true;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (baseDuckScript.getGameManagerScript().combatPhase)
|
||||
{
|
||||
if (canAttack)
|
||||
{
|
||||
Collider[] hits = Physics.OverlapSphere(transform.position, range, duckLayer);
|
||||
//GameObject targetToAttack = null;
|
||||
float distanceToChosenTarget = range;
|
||||
bool targetFound = false;
|
||||
foreach (Collider hit in hits)
|
||||
{
|
||||
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 (baseDuckScript.getAttackMode() == 1)
|
||||
{
|
||||
if (baseDuckScript.getArmyManagerScript().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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (targetFound && CACouDistance)
|
||||
{
|
||||
AttackC(targetToAttack);
|
||||
}
|
||||
if(targetFound && !CACouDistance)
|
||||
{
|
||||
AttackD();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void AttackC(GameObject targetToAttack)
|
||||
{
|
||||
StartCoroutine(coolDown());
|
||||
targetToAttack.GetComponent<BaseDuckScript>().TakeDamage(damage);
|
||||
Debug.Log("Corps à corps");
|
||||
ATTACK.Invoke();
|
||||
}
|
||||
|
||||
private void AttackD()
|
||||
{
|
||||
Debug.Log("DISTANCE");
|
||||
StartCoroutine(coolDown());
|
||||
|
||||
ATTACK.Invoke();
|
||||
}
|
||||
|
||||
public GameObject GetTarget()
|
||||
{
|
||||
return (targetToAttack);
|
||||
}
|
||||
|
||||
public float GetDamage()
|
||||
{
|
||||
return (damage);
|
||||
}
|
||||
|
||||
}
|
2
Assets/otherTeam/OtherScripts/DuckScript/AttackCAC.cs.meta
Executable file
2
Assets/otherTeam/OtherScripts/DuckScript/AttackCAC.cs.meta
Executable file
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8e5cb8ce6f5d03c4789dc12c8b7dac85
|
293
Assets/otherTeam/OtherScripts/DuckScript/BaseDuckScript.cs
Executable file
293
Assets/otherTeam/OtherScripts/DuckScript/BaseDuckScript.cs
Executable file
|
@ -0,0 +1,293 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class BaseDuckScript : MonoBehaviour
|
||||
{
|
||||
// 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;
|
||||
private float health;
|
||||
[SerializeField] private float baseHealth;
|
||||
[SerializeField] private float armor;
|
||||
[SerializeField] public GameObject healthBarPrefab;
|
||||
[SerializeField] private GameObject healthCanvas;
|
||||
private RectTransform healthCanvasRect;
|
||||
private GameObject healthBar = null;
|
||||
//private RectTransform healthBarRect = null;
|
||||
private float DuckHeight;
|
||||
private GameObject healthBarInside;
|
||||
private Image healthBarGradient;
|
||||
private float raycastDistance = 1.0f; //for getting ground material
|
||||
private LayerMask allGroundLayers;
|
||||
[SerializeField] private float baseSpeed;
|
||||
private GameObject crown;
|
||||
[SerializeField] public int cost = 5;
|
||||
[SerializeField] public List<string> troopStats;
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
//Pour que le Duck regarde sa cible constamment !!
|
||||
if (GetComponent<AttackCAC>().GetTarget() != null)
|
||||
{
|
||||
transform.LookAt(GetComponent<AttackCAC>().GetTarget().transform);
|
||||
}
|
||||
|
||||
|
||||
if (gameManagerScript.combatPhase)
|
||||
{
|
||||
updateMovement();
|
||||
}
|
||||
else
|
||||
{
|
||||
duckRB.isKinematic = true;
|
||||
}
|
||||
|
||||
if (health != baseHealth)
|
||||
{
|
||||
displayHealthBar();
|
||||
}
|
||||
|
||||
Vector3 rayOrigin = transform.position;
|
||||
Ray ray = new Ray(rayOrigin, Vector3.down);
|
||||
RaycastHit hit;
|
||||
|
||||
if (Physics.Raycast(ray, out hit, raycastDistance, allGroundLayers))
|
||||
{
|
||||
if (LayerMask.LayerToName(hit.collider.gameObject.layer) == "Dirt")
|
||||
{
|
||||
agent.speed = baseSpeed;
|
||||
} else if (LayerMask.LayerToName(hit.collider.gameObject.layer) == "Sand")
|
||||
{
|
||||
agent.speed = baseSpeed/2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void displayHealthBar()
|
||||
{
|
||||
if (healthBar == null)
|
||||
{
|
||||
healthBar = Instantiate(healthBarPrefab, healthCanvas.transform);
|
||||
healthBar.transform.localScale = new Vector2(0.25f, 0.25f);
|
||||
healthBarInside = healthBar.transform.GetChild(1).gameObject;
|
||||
healthBarGradient = healthBarInside.GetComponent<Image>();
|
||||
healthBarGradient.type = Image.Type.Filled;
|
||||
healthBarGradient.fillMethod = Image.FillMethod.Horizontal;
|
||||
}
|
||||
|
||||
if (healthBar != null) //safety measure
|
||||
{
|
||||
Vector2 screenPoint = Camera.main.WorldToScreenPoint(transform.position);
|
||||
healthBar.transform.position = screenPoint + new Vector2(0f, DuckHeight*80*Screen.width/3840);
|
||||
healthBarGradient.fillAmount = health / baseHealth;
|
||||
healthBarGradient.color = Color.Lerp(Color.red, Color.green, health/baseHealth);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public void updateMovement()
|
||||
{
|
||||
duckRB.isKinematic = false;
|
||||
if (attackMode == 1 && armyManagerScript.getCrownDuck(!isEnemy))
|
||||
{
|
||||
destination = armyManagerScript.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);
|
||||
}
|
||||
|
||||
void OnMouseOver()
|
||||
{
|
||||
// Check if the right mouse button is clicked
|
||||
/*
|
||||
if (Input.GetMouseButtonDown(1)) // 1 is for the right mouse button
|
||||
{
|
||||
if (!armyManagerScript.getCrownDuck(isEnemy) && !isEnemy)
|
||||
{
|
||||
becomeCrownDuck();
|
||||
}
|
||||
else if (armyManagerScript.getCrownDuck(isEnemy) == gameObject && !isEnemy)
|
||||
{
|
||||
loseMyCrown();
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public void TakeDamage(float damage)
|
||||
{
|
||||
float damageReallyTaken = Mathf.Max(0, damage - armor);
|
||||
health -= damageReallyTaken;
|
||||
if (health <= 0)
|
||||
{
|
||||
Debug.Log("dead");
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
public void Heal(float value)
|
||||
{
|
||||
health += value;
|
||||
health = (health > baseHealth) ? baseHealth : health;
|
||||
}
|
||||
|
||||
public float getHealth()
|
||||
{
|
||||
return health;
|
||||
}
|
||||
|
||||
public float getBaseHealth()
|
||||
{
|
||||
return baseHealth;
|
||||
}
|
||||
private void die()
|
||||
{
|
||||
Destroy(healthBar);
|
||||
armyManagerScript.kill(isEnemy, gameObject, hasCrown);
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
public int getAttackMode()
|
||||
{
|
||||
return (attackMode);
|
||||
}
|
||||
|
||||
public void setAttackMode(int mode)
|
||||
{
|
||||
attackMode = mode;
|
||||
}
|
||||
|
||||
public bool getTeam()
|
||||
{
|
||||
return (isEnemy);
|
||||
}
|
||||
|
||||
public float getSpeed()
|
||||
{
|
||||
return (baseSpeed);
|
||||
}
|
||||
|
||||
public void setHealthCanvas(GameObject healthCanvas)
|
||||
{
|
||||
this.healthCanvas = healthCanvas;
|
||||
}
|
||||
|
||||
public GameManager getGameManagerScript()
|
||||
{
|
||||
return(gameManagerScript);
|
||||
}
|
||||
}
|
2
Assets/otherTeam/OtherScripts/DuckScript/BaseDuckScript.cs.meta
Executable file
2
Assets/otherTeam/OtherScripts/DuckScript/BaseDuckScript.cs.meta
Executable file
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5b4f49154a488eadb80c1e6212811ead
|
89
Assets/otherTeam/OtherScripts/DuckScript/CharDuck.cs
Executable file
89
Assets/otherTeam/OtherScripts/DuckScript/CharDuck.cs
Executable file
|
@ -0,0 +1,89 @@
|
|||
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;
|
||||
}
|
||||
}
|
2
Assets/otherTeam/OtherScripts/DuckScript/CharDuck.cs.meta
Executable file
2
Assets/otherTeam/OtherScripts/DuckScript/CharDuck.cs.meta
Executable file
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7c6232b4da47c4448b112c51f245a9f7
|
88
Assets/otherTeam/OtherScripts/DuckScript/Daffy.cs
Executable file
88
Assets/otherTeam/OtherScripts/DuckScript/Daffy.cs
Executable file
|
@ -0,0 +1,88 @@
|
|||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class Daffy : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject Sword;
|
||||
private Rigidbody rib;
|
||||
private float RotSpeed = 300.0f;
|
||||
[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
|
||||
void Start()
|
||||
{
|
||||
GetComponent<AttackCAC>().changeCACouDistance(true);
|
||||
AttackCAC.ATTACK += Attack;
|
||||
}
|
||||
|
||||
void Attack()
|
||||
{
|
||||
Debug.Log("Attaque");
|
||||
StartCoroutine(Rotate360());
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
/*
|
||||
if (Input.GetKeyDown(KeyCode.R))
|
||||
{
|
||||
Debug.Log("Attaque");
|
||||
StartCoroutine(Rotate360());
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.P))
|
||||
{
|
||||
Debug.Log("DAFFY SMASH");
|
||||
StartCoroutine(Rotate360());
|
||||
Explode();
|
||||
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
IEnumerator Rotate360()
|
||||
{
|
||||
|
||||
bool IsFinish = true;
|
||||
//Clairement pas ouf, mais je sais faire autrement. Tourne jusqu'à ce que les conditions match
|
||||
//Ie que les 2 bool soit faux, l'un s'active quand il est proche de 0 degré, l'autre s'active après une demie rotation;
|
||||
while (IsFinish || Mathf.Abs(Sword.transform.localRotation.x)>0.05f)
|
||||
{
|
||||
//Debug.Log(Mathf.Abs(Sword.transform.localRotation.x));
|
||||
Sword.transform.Rotate(RotSpeed * Time.deltaTime, 0.0f, 0.0f);
|
||||
if (Mathf.Abs(Sword.transform.localRotation.x)>0.1f)
|
||||
{
|
||||
IsFinish = false;
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
Sword.transform.Rotate(RotSpeed * Time.deltaTime, 0.0f, 0.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
//On tue le signal pour eviter tout problemes (conseil de Game Jam)
|
||||
void OnDestroy()
|
||||
{
|
||||
AttackCAC.ATTACK -= Attack;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
2
Assets/otherTeam/OtherScripts/DuckScript/Daffy.cs.meta
Executable file
2
Assets/otherTeam/OtherScripts/DuckScript/Daffy.cs.meta
Executable file
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 20a6bc784cd0f59468144811378ea18d
|
153
Assets/otherTeam/OtherScripts/DuckScript/DarkWing.cs
Executable file
153
Assets/otherTeam/OtherScripts/DuckScript/DarkWing.cs
Executable file
|
@ -0,0 +1,153 @@
|
|||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class DarkWing : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject Bout;
|
||||
[SerializeField] private GameObject Balle;
|
||||
[SerializeField] private GameObject Sword;
|
||||
[SerializeField] private GameObject Gun;
|
||||
[SerializeField] private float ForceTir;
|
||||
[SerializeField] private float Range;
|
||||
private Rigidbody rib;
|
||||
private bool Shoot = true;
|
||||
float RotSpeed = 300.0f;
|
||||
private bool BladeGun; //True = Blade, False = Gun
|
||||
private GameObject Target;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
GetComponent<AttackCAC>().changeCACouDistance(false);
|
||||
AttackCAC.ATTACK += Attack;
|
||||
BladeGun = true;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
|
||||
void Attack()
|
||||
{
|
||||
Debug.Log("Attaque");
|
||||
if (!BladeGun)
|
||||
{
|
||||
if(Shoot)
|
||||
{
|
||||
StartCoroutine(Tir());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
StartCoroutine(Rotate360());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
void Update()
|
||||
{
|
||||
//Choose which weapon to use against enemy
|
||||
Target=GetComponent<AttackCAC>().GetTarget();
|
||||
if (Target != null)
|
||||
{
|
||||
Vector3 RangeWeapon = Target.transform.position - transform.position;
|
||||
if (RangeWeapon.magnitude > Range)
|
||||
{
|
||||
BladeGun = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
BladeGun = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!BladeGun) //Gun
|
||||
{
|
||||
Sword.SetActive(false);
|
||||
Gun.SetActive(true);
|
||||
GetComponent<AttackCAC>().changeCACouDistance(false);
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.R))
|
||||
{
|
||||
|
||||
if (Shoot)
|
||||
{
|
||||
Debug.Log("Attaque Shoot");
|
||||
StartCoroutine(Tir());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else //Sword
|
||||
{
|
||||
Sword.SetActive(true);
|
||||
Gun.SetActive(false);
|
||||
GetComponent<AttackCAC>().changeCACouDistance(true);
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.R))
|
||||
{
|
||||
|
||||
if (Shoot)
|
||||
{
|
||||
Debug.Log("Attaque Sword");
|
||||
StartCoroutine(Rotate360());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if (Input.GetKeyDown(KeyCode.M))
|
||||
{
|
||||
Debug.Log("DeRender");
|
||||
//SetRenderState(Sword,false);
|
||||
Sword.SetActive(false);
|
||||
}
|
||||
|
||||
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);
|
||||
Rigidbody rb = BULLET.GetComponent<Rigidbody>();
|
||||
rb.AddForce(transform.forward * ForceTir, ForceMode.Impulse);
|
||||
yield return null;
|
||||
Shoot = true;
|
||||
}
|
||||
//Heal
|
||||
IEnumerator Special()
|
||||
{
|
||||
|
||||
yield return null;
|
||||
|
||||
}
|
||||
|
||||
IEnumerator Rotate360()
|
||||
{
|
||||
|
||||
bool IsFinish = true;
|
||||
//Clairement pas ouf, mais je sais faire autrement. Tourne jusqu'a ce que les conditions match
|
||||
//Ie que les 2 bool soit faux, l'un s'active quand il est proche de 0 degre, l'autre s'active apres une demie rotation;
|
||||
while (IsFinish || Mathf.Abs(Sword.transform.localRotation.x) > 0.05f)
|
||||
{
|
||||
//Debug.Log(Mathf.Abs(Sword.transform.localRotation.x));
|
||||
Sword.transform.Rotate(RotSpeed * Time.deltaTime, 0.0f, 0.0f);
|
||||
if (Mathf.Abs(Sword.transform.localRotation.x) > 0.1f)
|
||||
{
|
||||
IsFinish = false;
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
Sword.transform.Rotate(RotSpeed * Time.deltaTime, 0.0f, 0.0f);
|
||||
}
|
||||
//On tue le signal pour eviter tout problemes (conseil de Game Jam)
|
||||
void OnDestroy()
|
||||
{
|
||||
AttackCAC.ATTACK -= Attack;
|
||||
}
|
||||
}
|
2
Assets/otherTeam/OtherScripts/DuckScript/DarkWing.cs.meta
Executable file
2
Assets/otherTeam/OtherScripts/DuckScript/DarkWing.cs.meta
Executable file
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: db4527bc43fec90429d79ff64941d4f0
|
89
Assets/otherTeam/OtherScripts/DuckScript/ExplosifDuck.cs
Executable file
89
Assets/otherTeam/OtherScripts/DuckScript/ExplosifDuck.cs
Executable file
|
@ -0,0 +1,89 @@
|
|||
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;
|
||||
}
|
||||
|
||||
}
|
2
Assets/otherTeam/OtherScripts/DuckScript/ExplosifDuck.cs.meta
Executable file
2
Assets/otherTeam/OtherScripts/DuckScript/ExplosifDuck.cs.meta
Executable file
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3c634d25b1c457f42ade841848d6f3ff
|
82
Assets/otherTeam/OtherScripts/DuckScript/SniperDuck.cs
Executable file
82
Assets/otherTeam/OtherScripts/DuckScript/SniperDuck.cs
Executable file
|
@ -0,0 +1,82 @@
|
|||
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;
|
||||
}
|
||||
}
|
2
Assets/otherTeam/OtherScripts/DuckScript/SniperDuck.cs.meta
Executable file
2
Assets/otherTeam/OtherScripts/DuckScript/SniperDuck.cs.meta
Executable file
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: eb4b255c02b8f984c82ab2f6417b637c
|
51
Assets/otherTeam/OtherScripts/DuckScript/TankDuck.cs
Executable file
51
Assets/otherTeam/OtherScripts/DuckScript/TankDuck.cs
Executable file
|
@ -0,0 +1,51 @@
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
2
Assets/otherTeam/OtherScripts/DuckScript/TankDuck.cs.meta
Executable file
2
Assets/otherTeam/OtherScripts/DuckScript/TankDuck.cs.meta
Executable file
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f0d84792271c3c847ad22f08b0cc2fcd
|
98
Assets/otherTeam/OtherScripts/DuckScript/TimeDuck.cs
Executable file
98
Assets/otherTeam/OtherScripts/DuckScript/TimeDuck.cs
Executable file
|
@ -0,0 +1,98 @@
|
|||
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;
|
||||
}
|
||||
}
|
2
Assets/otherTeam/OtherScripts/DuckScript/TimeDuck.cs.meta
Executable file
2
Assets/otherTeam/OtherScripts/DuckScript/TimeDuck.cs.meta
Executable file
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 983a511a5a7517b478b8909da220e895
|
Loading…
Add table
Add a link
Reference in a new issue