Exemplo n.º 1
0
    IEnumerator hailFire(Transform user, Missile projectile)
    {
        yield return(new WaitForSeconds(delayTime));

        float startTime = Time.time;

        while (Time.time - startTime < lifeTime)
        {
            // Make sure user isn't dead
            if (user == null)
            {
                break;
            }
            if (projectile == null)
            {
                break;
            }

            yield return(new WaitForSeconds(intervalTime));

            Vector3 location = user.position + Vector3.up * heightOffset;                                                           // Get current height offset
            Missile newProj  = Instantiate(projectile, location + Random.insideUnitSphere * maxRadius, Quaternion.Euler(90, 0, 0)); // create new missile
            newProj.originator = projectile.originator;

            Rigidbody rbody = newProj.GetComponent <Rigidbody>(); // Get projectile rigidbody
            rbody.useGravity = true;                              // allow gravity
            newProj.GetComponent <Collider>().enabled = true;
            newProj.Activate();
            // newProj.originator = null;
        }
    }
Exemplo n.º 2
0
    public void missileMaker() {
        GameObject missile = Instantiate(Resources.Load("Prefabs/Missile", typeof(GameObject)), transform.position, Quaternion.identity) as GameObject;
        Missile m = missile.GetComponent("Missile") as Missile;
        m.prepMissile(this);
		m.GetComponent<MeshRenderer>().enabled=false;
		m.GetComponent<BoxCollider>().enabled=false;
        //slash.transform.Translate(s.cast(),Space.World);
        spells [1] = missile;
        //		Debug.Log("-.-");
    }
Exemplo n.º 3
0
    public override void MessUp(Transform user, Missile projectile)
    {
        Rigidbody rbody = projectile.GetComponent <Rigidbody>(); // Get projectile rigidbody

        rbody.useGravity = false;                                // do not allow gravity
        rbody.velocity   = Vector3.zero;                         // Stop the missile from moving
        projectile.GetComponent <Collider>().enabled = false;
        projectile.Deactivate();
        projectile.StartCoroutine(hailFire(user, projectile));
    }
Exemplo n.º 4
0
	public void P1WrongAttack(){
		//Fire when option is choosen. 
		missile = missile.GetComponent<Missile> ();
		source.PlayOneShot(fly);
		missile.createShot ();

		//reset the options back to original place. 
		resetOpt = resetOpt.GetComponent<ResetOption> ();
		resetOpt.reset ();
		resetOpt2 = resetOpt.GetComponent<ResetOption2> ();
		resetOpt2.reset ();
		
		gamesqlM.activation();
	}
Exemplo n.º 5
0
    private IEnumerator ThirdAttack()
    {
        //attackThree = false;

        temp = 4;
        StartCoroutine(Teleport());

        yield return(new WaitForSeconds(attackSwitch));

        GameObject Missile;

        for (int i = 1; i < 8; i++)
        {
            //Blink.SetActive(true);

            Missile = Instantiate(ThirdBossAttack, new Vector3(transform.position.x, transform.position.y + i, 0), Quaternion.identity);
            Missile.GetComponent <ThirdBossAttack>().ChooseRadius(i);

            yield return(new WaitForSeconds(0.25f));
            //Blink.SetActive(false);
        }

        attackThree = true;

        gameObject.GetComponent <Collider2D>().enabled = true;
        //yield return new WaitForSeconds(2f);

        StartCoroutine(ChooseAttack());
    }
Exemplo n.º 6
0
    private IEnumerator SpawnMissiles(int toSpawn)
    {
        int            count    = 0;
        WaitForSeconds waitTime = new WaitForSeconds(timesBetweenMissiles);

        while (count < toSpawn)
        {
            Vehicle target = enemies[count].GetComponentInChildren <Vehicle>();
            if (target != null)
            {
                for (int i = 0; i < missilesPerTarget; i++)
                {
                    GameObject    obj     = bulletPool.SpawnFromPool(missileTag, transform.position, Quaternion.identity);
                    Missile       mis     = obj.GetComponentInChildren <Missile>();
                    IPooledObject iPooled = mis.GetComponent <IPooledObject>();
                    if (iPooled != null)
                    {
                        iPooled.OnSpawn();
                    }
                    mis.Target = target;
                }
                count++;
            }
            yield return(waitTime);
        }
    }
Exemplo n.º 7
0
    void UpdateOrbitalMovement()
    {
        // Find the missile object
        Missile missile = null;

        foreach (var m in FindObjectsOfType(typeof(Missile)) as Missile[])
        {
            if (m.owner == this)
            {
                missile = m;
            }
        }

        if (missile == null || !(missile.GetComponent(typeof(Missile)) as Missile).IsFalling())
        {
            // Player 2
            float horizontalTranslation = Input.GetAxis("X2");
            float verticalTranslation   = Input.GetAxis("Y2");

            // Player 1
            if (gameObject.name == "Player")
            {
                horizontalTranslation = Input.GetAxis("X1");
                verticalTranslation   = Input.GetAxis("Y1");
            }

            transform.RotateAround(planet.transform.position, Vector3.up, horizontalTranslation * Time.deltaTime * horizontalCameraSpeed);
            transform.RotateAround(planet.transform.position, Vector3.right, -verticalTranslation * Time.deltaTime * verticalCameraSpeed);

            transform.LookAt(planet.transform.position);
        }
    }
    IEnumerator InstantiateMissilesOverTime()
    {
        var attackers = GameObject.FindObjectsOfType <GameObject>();

        for (int i = 0; i < attackers.Length; i++)
        {
            if (attackers[i] == null)
            {
                continue;
            }
            AttackingUnitI attacker = attackers[i].GetComponent <AttackingUnitI>();
            if (attacker == null)
            {
                continue;
            }
            for (int j = 0; j < 30; j++)
            {
                if (!activeLevel == null)
                {
                    break;
                }
                Missile missile = GameObject.Instantiate(attacker.Missile).GetComponent <Missile>();
                missile.OnInit();
                missile.tr.SetParent(activeLevel.transform);
                InitMissile(attackers[i], missile.GetComponent <Missile>());
                yield return(new WaitForEndOfFrame());
            }
        }
    }
Exemplo n.º 9
0
    void Shoot()
    {
        if (gunLocked == true)
        {
            return;
        }
        else if (gunLocked == false)
        {
            //Instantiate projectile
            GameObject missileGameObject = (GameObject)Instantiate(missilePrefab, firePoint.position + new Vector3(0, 0, 36.4f), firePoint.rotation);
            Missile    missile           = missileGameObject.GetComponent <Missile>();
            v = player.GetComponent <Rigidbody>().velocity *fireForce;
            missile.GetComponent <Rigidbody>().velocity = v;

            // Configure the missile using it's own functions
            missile.Fire(spinSpeed);
            missile.SelfDestruct(missileLifeSpan);

            //lock the gun to prevent a glitch related to creating too many missiles at once, decrement ammo
            gunLocked = true;
            Invoke("Action", 0.1f);
            ammo--;

            //Biden changes faces when firing
            FaceSwitch biden = player.GetComponent <FaceSwitch>();
            biden.ChangeFace(2);

            // Biden says something
            FindObjectOfType <AudioManager>().PlayRandom();
        }
    }
Exemplo n.º 10
0
    private void ShootAt(GameObject asteroid, Vector3 velocity)
    {
        Missile missile = Instantiate(MissilePrefab, transform.position, transform.rotation) as Missile;

        missile.GetComponent <Rigidbody2D>().velocity = velocity;
        missile.SetTarget(asteroid);
    }
Exemplo n.º 11
0
    private IEnumerator SecondAttack()
    {
        temp = Random.Range(5, 7);
        StartCoroutine(Teleport());

        yield return(new WaitForSeconds(attackSwitch));

        GameObject Missile;

        for (int i = 0; i < 4; i++)
        {
            //Blink.SetActive(true);

            if (i % 2 == 0)
            {
                Missile = Instantiate(SecondBossAttack, new Vector3(transform.position.x, transform.position.y - 2.5f, 0), Quaternion.identity);
                Missile.GetComponent <SecondBossAttack>().yPosition(i);
            }
            else
            {
                Missile = Instantiate(SecondBossAttack, new Vector3(transform.position.x, transform.position.y, 0), Quaternion.identity);
                Missile.GetComponent <SecondBossAttack>().yPosition(i);
            }

            Missile.GetComponent <SecondBossAttack>().Direction(temp);
            yield return(new WaitForSeconds(1f));

            //Blink.SetActive(false);
        }

        gameObject.GetComponent <Collider2D>().enabled = true;

        StartCoroutine(ChooseAttack());
    }
    public override void MessUp(Transform user, Missile projectile)
    {
        projectile.bounceCount = additionalBounces;
        projectile.friendlyOff = true;
        Collider coll = projectile.GetComponent <Collider>();

        coll.material = physMat;
    }
Exemplo n.º 13
0
    public override void MessUp(Transform user, Missile projectile)
    {
        // change projectile bounce count
        projectile.bounceCount = bounceCount;

        Missile pRoJeCtIlE = Instantiate(projectile, projectile.transform.position, projectile.transform.rotation);

        Destroy(projectile.gameObject);

        Rigidbody rbody = pRoJeCtIlE.GetComponent <Rigidbody>();

        rbody.mass       = modMass;
        rbody.useGravity = true;
        rbody.AddForce(projectile.transform.forward * modForce, ForceMode.Impulse);

        Collider coll = pRoJeCtIlE.GetComponent <Collider>();

        coll.material = bounceMat;
    }
Exemplo n.º 14
0
    IEnumerator firePillar(Transform coll, Missile proj)
    {
        proj.Deactivate();
        Rigidbody rbody = proj.GetComponent <Rigidbody>();

        rbody.useGravity  = false;
        rbody.isKinematic = true;
        proj.GetComponent <Collider>().enabled = false;
        ParticleSystem flame = Instantiate(tinyFlamePrefab, proj.transform.position, Quaternion.identity);

        ParticleSystem.MainModule flameMain = flame.main;
        while (flame.startLifetime > 0f)
        {
            flame.startLifetime -= Time.deltaTime;
            yield return(new WaitForEndOfFrame());
        }
        // Transform newPillar = Instantiate(firePillarPrefab, flame.transform.position, Quaternion.identity);
        mainBlast(proj, flame.transform);
        Destroy(flame.gameObject);
    }
Exemplo n.º 15
0
    void subBlast(Vector3 position, Vector3 startingPos, Transform caster)
    {
        Missile newSubBlast = Instantiate(projectilePrefab, position, Quaternion.identity);

        newSubBlast.transform.forward = position - startingPos;
        Missile newproj = newSubBlast.GetComponent <Missile>();

        newproj.originator       = caster;
        newproj.primaryEffect    = this;
        newproj.power            = power;
        newproj.mainShot         = false;
        newproj.trail.startColor = baseColor;
        Rigidbody rbody = newSubBlast.GetComponent <Rigidbody>();

        rbody.useGravity = true;
        rbody.mass       = mass;
        rbody.AddForce(newSubBlast.transform.forward * Random.Range(subShotMinimumForce, subShotMaximumForce), ForceMode.Impulse);
        ParticleSystem.MainModule main = newproj.sparkles.main;
        main.startColor = baseColor;
    }
Exemplo n.º 16
0
    public void Init(GlobalController controller)
    {
        this.controller            = controller;
        target                     = controller.player;
        planet                     = GetComponent <Planet>();
        missileTypeObj             = controller.missile.GetRandomMissile();
        planet.saveData.missleType = missileTypeObj.type;
        planet.SetMissileSprite(missileTypeObj.GetComponent <SpriteRenderer>().sprite);

        isInitialized = true;
    }
Exemplo n.º 17
0
    // Update is called once per frame
    void Update()
    {
        // Find the missile object
        Missile missile = null;

        foreach (var m in FindObjectsOfType(typeof(Missile)) as Missile[])
        {
            if (m.owner == player)
            {
                missile = m;
            }
        }

        var playerPosition     = player.transform.position;
        var playerRotation     = player.transform.eulerAngles;
        var playerRotationQuat = player.transform.rotation;

        if (missile != null)
        {
            var missileComponent = missile.GetComponent(typeof(Missile)) as Missile;
            var distance         = missileComponent.hasAttached ? 0 : (float)System.Math.Sqrt(
                System.Math.Sqrt(missileComponent.CameraDistanceRatio())
                );
            var targetPosition = missile.transform.Find("CameraSeat").transform.position;

            transform.position = playerPosition * (distance)
                                 + targetPosition * (1 - distance);
            transform.rotation = Quaternion.Lerp(
                missile.transform.rotation,
                playerRotationQuat,
                distance
                );
            crashPosition = transform.position;
            crashRotation = transform.rotation;
            zoomOutTime   = 0;
        }
        else
        {
            float missileDistance = zoomOutAmount(zoomOutTime);
            transform.position = playerPosition * missileDistance
                                 + (crashPosition * (1 - missileDistance));
            transform.rotation = Quaternion.Lerp(crashRotation, playerRotationQuat, missileDistance);

            zoomOutTime       = Math.Min(zoomOutTime + Time.deltaTime, 1);
            Screen.lockCursor = true;
            if (Input.GetKeyDown("escape"))
            {
                Screen.lockCursor = false;
            }
            // transform.position -= (transform.position - playerPosition) * Time.deltaTime;
            // // transform.eulerAngles -= (transform.eulerAngles - initialRotation) * Time.deltaTime;
            // transform.LookAt(crashPosition);
        }
    }
Exemplo n.º 18
0
//	public void submit(){
//
//		y = ansslot.GetComponentInChildren<Text> ().text ;
//		//Debug.Log (ansslot.GetComponentInChildren<Text> ().text);
//
//		if (y == gamesql.checker) {
//			correctAttack ();
//		} else {
//			wrongAttack();
//		}
//
//	}


    public void wrongAttack()
    {
//		gamesql.timer = 1f;
        //Fire when option is choosen.
        missile = missile.GetComponent <Missile> ();
        source.PlayOneShot(fly);
        missile.createShot();

        resetOpt = resetOpt.GetComponent <ResetOption> ();
        resetOpt.reset();

        gamesql.activation();
    }
Exemplo n.º 19
0
    IEnumerator processMessUp(Missile projectile)
    {
        yield return(new WaitForEndOfFrame());

        // Make projectile use gravity
        Rigidbody rbody = projectile.GetComponent <Rigidbody>();

        rbody.useGravity = true;

        // Replace force
        Vector3 forceDir = rbody.velocity.normalized;

        Debug.Log("Velocity before: " + rbody.velocity);
        rbody.velocity        = Vector3.zero;
        rbody.angularVelocity = Vector3.zero;
        rbody.mass            = modMass;
        // rbody.AddForce(forceDir * modForce, ForceMode.Impulse);

        // change projectile's bounciness
        Collider coll = projectile.GetComponent <Collider>();

        coll.material = bounceMat;
    }
Exemplo n.º 20
0
    IEnumerator antiGravity(Missile projectile)
    {
        Rigidbody projRbody = projectile.GetComponent <Rigidbody>();

        projRbody.useGravity = false;
        while (true)
        {
            if (projRbody == null)
            {
                break;
            }
            projRbody.AddForce(Vector3.down * Physics.gravity.y * upwardForce);
            yield return(new WaitForEndOfFrame());
        }
    }
Exemplo n.º 21
0
    public void Shoot(GameObject target)
    {
        if (!isFiring)
        {
            isFiring = true;
            missile.SetActive(true);

            GameObject missileCopy          = Instantiate(missile, new Vector3(transform.position.x, transform.position.y, transform.position.z), Quaternion.identity);
            Missile    missileComponentCopy = missileCopy.GetComponent <Missile>();
            missileComponentCopy.GetComponent <BoxCollider>().enabled = true;

            missileComponentCopy.target     = target.transform.gameObject;
            missileComponentCopy.dirFrom    = startFrom.position;
            missileComponentCopy.isFired    = true;
            enemyMgr.proyectileNotDestroyed = missileCopy;
        }
    }
Exemplo n.º 22
0
    public override void Fire()
    {
        base.Fire();

        if (missilePrefab != null)
        {
            Missile missile = Instantiate(missilePrefab);
            missile.transform.rotation = transform.rotation;
//			missile.transform.position=transform.TransformPoint(new Vector3(0,-5,0) );
            missile.transform.position = bulletTransform.position;
            missile.target             = target;
            missile.Fire();
            missile.player = owner.player;
            missile.GetComponent <Rigidbody>().velocity = owner.GetComponent <Rigidbody>().velocity;
            gameObject.GetComponent <AudioSource>().Play();
        }
    }
Exemplo n.º 23
0
    public void Init(GlobalController controller)
    {
        this.controller = controller;
        this.controller.input.OnInputEvent += Input_OnInputEvent;
        planet = GetComponent <Planet>();
        //Sets the current planet to controlled by player value,
        planet.saveData.controlledByPlayer = true;
        //Handles players planet hit.
        planet.OnHitEvent += Planet_OnHitEvent;
        //Handles players planet death.
        planet.OnDeathEvent += Planet_OnDeathEvent;
        //Gets the random missile for the player's planet.
        missileTypeObj             = controller.missile.GetRandomMissile();
        planet.saveData.missleType = missileTypeObj.type;
        planet.SetMissileSprite(missileTypeObj.GetComponent <SpriteRenderer>().sprite);
        planet.speedMod = .05f;

        isInitialized = true;
    }
Exemplo n.º 24
0
    public ParticleSystem castEffect;                                                                    // particle effect when firing spell

    public virtual void ActivateSpell(SpellCaster user, SpellSecondary secondaryEffect, Vector3 fireDir) // When the spell is fired
    {
        Transform firingPoint = user.returnGun();

        if (firingPoint)
        {
            // Make sure we dont fire inside the user
            Vector3 firePoint = firingPoint.position;

            // Create spawn shots
            ParticleSystem            gunsmoke  = Instantiate(castEffect, firePoint, Quaternion.LookRotation(fireDir));
            ParticleSystem.MainModule smokeMain = gunsmoke.main;
            smokeMain.startColor = baseColor;
            Destroy(gunsmoke.gameObject, smokeMain.startLifetime.constant);

            // Create a new missile object
            Missile newProjectile = Instantiate(projectilePrefab, firePoint, Quaternion.LookRotation(fireDir));
            newProjectile.bounceCount     = 0;
            newProjectile.power           = power;
            newProjectile.duration        = duration;
            newProjectile.primaryEffect   = this;
            newProjectile.secondaryEffect = secondaryEffect;
            newProjectile.originator      = user.returnBody();

            // Modify rigidbody settings for takeoff
            Rigidbody projRbody = newProjectile.GetComponent <Rigidbody>();
            projRbody.useGravity = false;
            projRbody.AddForce(newProjectile.transform.forward * force, ForceMode.Impulse);

            // Apply visual effects
            ParticleSystem.MainModule main = newProjectile.sparkles.main;
            main.startColor = baseColor;
            TrailRenderer trail = newProjectile.trail;
            trail.startColor = baseColor;
            trail.endColor   = baseColor;

            // Apply secondary effects
            if (secondaryEffect != null)
            {
                secondaryEffect.MessUp(user.returnBody(), newProjectile);
            }
        }
    }
Exemplo n.º 25
0
    IEnumerator waitAndSurround(Transform user, Missile projectile)
    {
        projectile.bounceCount = 0;
        yield return(new WaitForSeconds(forwardTime));

        Rigidbody projRbody = projectile.GetComponent <Rigidbody>();

        projRbody.velocity = Vector3.zero;
        Rigidbody newAxis = Instantiate(axisPrefab);

        newAxis.rotation            = user.rotation;
        projectile.transform.parent = newAxis.transform;
        projectile.toBeDeleted.Add(newAxis.gameObject);
        newAxis.angularVelocity = new Vector3(0, speed, 0);
        while (!projectile.dead)
        {
            newAxis.MovePosition(user.position);
            yield return(new WaitForEndOfFrame());
        }
    }
Exemplo n.º 26
0
 public IEnumerator ShootCoroutine()
 {
     while (!GameManager.instance.isGameover)
     {
         if (Physics2D.OverlapCircle((Vector2)transform.position, 5f, layerMask))
         {
             if (lastShootTime + shootTime <= Time.time)
             {
                 lastShootTime = Time.time;
                 //미사일 생성
                 Missile missile = Instantiate(go_MissilePrefab, transform.position, Quaternion.identity).GetComponent <Missile>();
                 missile.transform.parent = transform;
                 missile.GetComponent <Rigidbody2D>().velocity = Vector2.up * 5;
                 animator.SetTrigger("Shoot");
                 Destroy(missile, 4.0f);
                 SoundManager.instance.PlaySFX("missile");
             }
         }
         yield return(new WaitForSeconds(0.1f));
     }
 }
Exemplo n.º 27
0
    public override void ActivateSpell(SpellCaster user, SpellSecondary secondaryEffect, Vector3 fireDir)
    {
        if (user.returnGun())
        {
            // Create a cast effect
            ParticleSystem            gunsmoke  = Instantiate(castEffect, user.returnGun().position, Quaternion.LookRotation(fireDir));
            ParticleSystem.MainModule smokeMain = gunsmoke.main;
            smokeMain.startColor = baseColor;
            Destroy(gunsmoke.gameObject, smokeMain.startLifetime.constant);

            // Create the healing missile
            Vector3 firePos       = Vector3.Lerp(user.returnGun().position, user.returnBody().position, 0.5f);
            Missile newProjectile = Instantiate(projectilePrefab, firePos, Quaternion.LookRotation(fireDir));
            newProjectile.bounceCount     = 0;
            newProjectile.power           = power;
            newProjectile.duration        = duration;
            newProjectile.primaryEffect   = this;
            newProjectile.secondaryEffect = secondaryEffect;
            newProjectile.originator      = user.returnBody();

            // Healing missiles do not have velocity!
            Rigidbody projRbody = newProjectile.GetComponent <Rigidbody>();
            projRbody.useGravity = true;
            projRbody.velocity   = Vector3.zero;

            // Apply visual effects
            ParticleSystem.MainModule main = newProjectile.sparkles.main;
            main.startColor = baseColor;
            TrailRenderer trail = newProjectile.trail;
            trail.startColor = baseColor;
            trail.endColor   = baseColor;

            // Apply secondary effects
            if (secondaryEffect != null)
            {
                secondaryEffect.MessUp(user.returnBody(), newProjectile);
            }
        }
    }
    public override void MessUp(Transform user, Missile projectile)
    {
        Damageable dam = user.GetComponent <Damageable>();
        Vector3    dir = user.position - projectile.transform.position;

        dir   = dir.normalized;
        dir.y = upwardForce;
        dir   = dir.normalized;
        projectile.transform.localScale   = new Vector3(projectile.transform.localScale.x * valueModifier, projectile.transform.localScale.y, projectile.transform.localScale.z);
        projectile.transform.position    += projectile.transform.forward * projectile.GetComponent <SphereCollider>().radius *valueModifier;
        projectile.trail.widthMultiplier *= valueModifier;
        projectile.power      *= Mathf.RoundToInt(valueModifier);
        projectile.duration   *= valueModifier;
        projectile.friendlyOff = true;
        if (dam)
        {
            dam.knockBack(dir, force);
        }
        else
        {
            Debug.Log("No damageable!");
        }
    }
Exemplo n.º 29
0
    IEnumerator processSurround(Transform user, Missile projectile)
    {
        projectile.bounceCount = 0;
        projectile.lifeSpan    = modifiedLifeSpan;
        yield return(new WaitForSeconds(forwardTime));

        Rigidbody projRbody = projectile.GetComponent <Rigidbody>();

        projRbody.velocity = Vector3.zero;
        while (true)
        {
            Vector3 userBefore = user.position;
            if (projectile == null)
            {
                break;
            }
            Debug.Log("woo!");
            // fly around the user
            Vector3 before = projectile.transform.position;
            projectile.transform.RotateAround(user.position, user.up, speed * Time.deltaTime);
            Vector3    after = projectile.transform.position;
            RaycastHit hit;
            if (projRbody.SweepTest(before - after, out hit, Vector3.Distance(before, after)))
            {
                if (hit.collider.GetComponent <Damageable>())
                {
                    projRbody.MovePosition(hit.point);
                    // projectile.primaryEffect.OnHit(projectile, hit.collider);
                }
            }
            yield return(new WaitForEndOfFrame());

            Vector3 userAfter = user.position;
            projRbody.MovePosition(projRbody.position + (userAfter - userBefore)); // update position to maintain distance
        }
    }
Exemplo n.º 30
0
 //Sets the enemy missile by specified type.
 public void SetMissleByType(MissileType type)
 {
     missileTypeObj = controller.missile.GetMissleByType(type);
     planet.SetMissileSprite(missileTypeObj.GetComponent <SpriteRenderer>().sprite);
 }