Exemple #1
0
        IEnumerator SimulateProjectile()
        {
            Target = FindClosestEnemy();

            if (Target != null)
            {
                // Short delay added before Projectile is thrown

                GameObject bullet = Instantiate(projec) as GameObject;

                bullet.GetComponent <ThrowProjektScript>().Target      = Target;
                bullet.GetComponent <ThrowProjektScript>().gravity     = gravity;
                bullet.GetComponent <ThrowProjektScript>().firingAngle = firingAngle;


                //Projectile = bullet.transform;

                // Move projectile to the position of throwing object + add some offset if needed.
                bullet.transform.position = myTransform.position + new Vector3(0f, 2f, 0);
            }
            int attachedscraps = GetComponent <TowerRessourceManagement>().AttachedScraps.Count;

            attachedscraps = (attachedscraps == 0) ? 1 : attachedscraps;
            Debug.Log(attachedscraps);

            yield return(new WaitForSeconds(4.0f / attachedscraps));

            towersounds.PlayAttackClip();
            StartCoroutine(SimulateProjectile());
        }
Exemple #2
0
        public void BubbleProjectile(int bubbleIndex)
        {
            // bubbleIndex
            // 0 = top, 1 = right, 2 = bottom, 3 = left
            if (_towerRessourceManagement.AttachedScraps.Count - 1 < bubbleIndex)
            {
                return;
            }

            GameObject bubbleProjectile = Instantiate(projectile) as GameObject;

            //print(transform.eulerAngles.y);

            bubbleProjectile.GetComponent <BubbleProjectileScript>().angle = transform.eulerAngles.y;
            //Physics.IgnoreCollision(bubbleProjectile.GetComponent<Collider>(), GetComponent<Collider>());

            if (spawnpoints.Count > bubbleIndex)
            {
                bubbleProjectile.GetComponent <BubbleProjectileScript>().spawnpoint = spawnpoints[bubbleIndex].transform;
            }

            _towersounds.PlayAttackClip();
        }