// Update is called once per frame void Update() { timer += Time.deltaTime; CanonInfos.currentCooldownTime -= Time.deltaTime; if (CanonInfos.canFire()) { if (timer >= TEMPS_AVANT_SWITCH) { RaycastHit2D hit = Physics2D.Raycast(transform.GetChild(0).GetChild(0).position, transform.GetChild(0).GetChild(0).up, 2000, 1 << LayerMask.NameToLayer("Ennemy")); if (hit.collider != null) { GameObject canonball = Instantiate(Static_Resources.defaultCanonball, CanonInfos.shootPoint.position, CanonInfos.shootPoint.rotation); Canonball c = canonball.GetComponent <Canonball>(); c.InitCanonball(CanonInfos.shootPoint.up, 20, "Enemy", 2); CanonInfos.ResetCooldown(); c.transform.position = CanonInfos.shootPoint.position; } } else { RaycastHit2D hit = Physics2D.Raycast(transform.GetChild(0).GetChild(0).position, transform.GetChild(0).GetChild(0).up, 2000, 1 << LayerMask.NameToLayer("Player")); if (hit.collider != null) { GameObject canonball = Instantiate(Static_Resources.defaultCanonball, CanonInfos.shootPoint.position, CanonInfos.shootPoint.rotation); Canonball c = canonball.GetComponent <Canonball>(); c.InitCanonball(CanonInfos.shootPoint.up, 20, "Player", 2); CanonInfos.ResetCooldown(); c.transform.position = CanonInfos.shootPoint.position; } } } }
//Fonction appellee lors d'un tir, renvoie l'objet de degat creer protected override WeaponDamageDealer Fire() { reloadTime = 0.0f; //On commence a recharger animator.SetTrigger("Fire"); //On declenche l'aniamtion GameObject projectile = Instantiate(projectilePrefab, transform); //On cree le projectile projectile.transform.position += Vector3.up; //On place le boulet au dessus du canon Canonball newCanonBall = projectile.GetComponent<Canonball>(); newCanonBall.Initialize(target.position, projectile.transform.position); //On initialise le boulet de canon PlaySoundOnEvent.Instance.PlayMortarFire(); //On joue le son de tir de mortier return newCanonBall; //On renvoie l'objet de degat cree }
public ObjectInstance(GameObject objectInstance) { gameObject = objectInstance; transform = gameObject.transform; gameObject.SetActive(false); if (gameObject.GetComponent <Splatter>()) { hasPoolObjectComponent = true; splatterScript = gameObject.GetComponent <Splatter>(); } else if (gameObject.GetComponent <Canonball>()) { hasPoolObjectComponent = true; canonballScript = gameObject.GetComponent <Canonball>(); } }
public override void Attack() { // Spawn projectile Canonball cball = Instantiate( CanonballToSpawn, transform.position + (Vector3)MuzzleRelative, Quaternion.identity ) as Canonball; // Get parent ; // Tell our cball whats up cball.Setup(GetComponentInParent <Canons>().relativeDistance, m_reticule); // Tell our reticule to stop moving m_reticule.StopMoving(); m_reticule = null; }
public override void Apply(PlayerActor owner, PlayerActor target) { done = false; DOTweenAnimation anim = GetComponent <DOTweenAnimation> (); int targetLane = Mathf.Clamp(owner.currentLane + offset, -1, GameConfig.Instance.upperlane + 1); Vector3 location = FindObjectOfType <Battleground> ().GetLanePosition(target.playerIndex, targetLane); Quaternion rotation = Quaternion.LookRotation(location - owner.transform.position); Debug.Log(rotation); owner.Weapon.DORotate(rotation.eulerAngles, anim.duration).SetEase(anim.easeType, 0.1f).OnComplete(() => { Canonball canonball = GameObject.Instantiate(GameConfig.Instance.canonball).GetComponent <Canonball>(); canonball.owner = owner; canonball.parentAction = this; canonball.transform.position = owner.GetFirePoint(); canonball.transform.DOMove(location, projectileFlyDuration).SetEase(projectileFlyEase).OnComplete(() => { Destroy(canonball.gameObject); done = true; }); }); }