Example #1
0
    void PlanetHit(PlanetBehaviour planet, RocketBehaviour rocket, PlanetBehaviour.HitInfo hitInfo)
    {
        if (planet != playerController.playerPlanet)
        {
            AddPoints((int)(configuration.damageScoreMultiplier * hitInfo.damageDealt));

            if (hitInfo.coreExposed)
            {
                uiController.FlashMessage("CORE EXPOSED");
                AddPoints(500);
            }

            if (hitInfo.coreHit)
            {
                uiController.FlashMessage("CORE HIT");
                AddPoints(1000);
            }

            if (planet.state.hitPoints <= 0.0f)
            {
                planet.Explode();
            }
        }
        else
        {
            if (playerController.playerPlanet.state.hitPoints <= 0.0f)
            {
                GameOver();
            }
        }
    }
    void OnTriggerEnter(Collider c)
    {
        RocketBehaviour r = c.GetComponent <RocketBehaviour>();

        if (r != null)
        {
            r.ChangeMovement(false);
            Destroy(c.gameObject);
        }
    }
Example #3
0
    public void AbandonRocket()
    {
        if (ridingRocket) {
            StopAllCoroutines();

            ridingRocket = false;
            transform.parent = null;
            rigidbody.isKinematic = false;
            rigidbody.velocity = rocket.rigidbody.velocity;

            if (!isDead && stunTimer <= 0f) {
                StartCoroutine(RecoverCoroutine(transform.localRotation));
            }

            rocket.SetControlRocket(false);
            rocket = null;
        }
    }
    void Shoot()
    {
        GameObject blt = Instantiate(bullet, head.transform.position, Quaternion.identity); //Tanımlanan mermi objesini oluşturduk

        BulletBehaviour bltBehaviour = blt.GetComponent <BulletBehaviour>();                //Eğer oluşturulan merminin içinde BulletBehaviour (kurşun özelliği) varsa içerisine erişip targetini verdik

        if (bltBehaviour != null)
        {
            bltBehaviour.damage = damage;
            bltBehaviour.target = target;
        }
        RocketBehaviour rctBehaviour = blt.GetComponent <RocketBehaviour>();//Eğer oluşturulan merminin içinde Rocket (roket özelliği) varsa içerisine erişip targetini verdik

        if (rctBehaviour != null)
        {
            rctBehaviour.damage = damage;
            rctBehaviour.target = target;
        }
    }
Example #5
0
    public void AbandonRocket()
    {
        if (ridingRocket)
        {
            StopAllCoroutines();

            ridingRocket          = false;
            transform.parent      = null;
            rigidbody.isKinematic = false;
            rigidbody.velocity    = rocket.rigidbody.velocity;

            if (!isDead && stunTimer <= 0f)
            {
                StartCoroutine(RecoverCoroutine(transform.localRotation));
            }

            rocket.SetControlRocket(false);
            rocket = null;
        }
    }
Example #6
0
    private void FireRocket(Vector3 aimDir, bool ride)
    {
        float angle = Mathf.Rad2Deg * Mathf.Atan2(-aimDir.y, aimDir.x);

        rocket = (RocketBehaviour)Instantiate(rocketPrefab, transform.position + shoulderPos + aimDir * 3, Quaternion.Euler(new Vector3(angle, 90f, 0f)));
        rocket.rigidbody.velocity = rigidbody.velocity;

        // ride rocket
        if (ride)
        {
            rocket.SetControlRocket(true);
            ridingRocket          = true;
            transform.parent      = rocket.transform;
            rigidbody.isKinematic = true;

            animation.Play("StandAnimation", PlayMode.StopAll);

            MountRocket(transform.localPosition, transform.localRotation, facingRight);
        }
    }
Example #7
0
    // Use this for initialization
    void Start()
    {
        Screen.showCursor = false;

        screenCenter = new Vector3(Screen.width / 2, Screen.height / 2, 0f);
        ridingRocket = false;
        isDead       = false;
        stunTimer    = 0f;
        rocketCount  = rocketMax;

        initialConstraints = rigidbody.constraints;

        animation = GetComponentInChildren <Animation>();

        rocket = null;

        boredomClock = (BoredomClock)FindObjectOfType(typeof(BoredomClock));
        timerBar     = (TimerBarBehaviour)FindObjectOfType(typeof(TimerBarBehaviour));

        facingRight = true;
    }
    /// <summary>
    /// Method for spawning the rockets.
    /// </summary>
    /// <param name="spawn">The actual spawn Transform(either left or right bikini side).</param>
    /// <param name="range">Actual range parameter.</param>
    /// <returns></returns>
    public void spawnRocket(Transform spawn, float range)
    {
        // 0.75f*gameObject.transform.forward because to avoid colliding with the character
        //GameObject spawnedRocket = ObjectsPool.Spawn(rocket, spawn.position + 0.75f * gameObject.transform.forward, Quaternion.LookRotation(spawn.forward));
        GameObject spawnedRocket = (GameObject)Instantiate(rocket, spawn.position + 0.75f * gameObject.transform.forward, Quaternion.LookRotation(spawn.forward));

        // Gets the particle system from the parent game object
        ParticleSystem particleSystem = spawnedRocket.GetComponentInChildren <ParticleSystem>() as ParticleSystem;

        // The emission of the particle system is disabled because of the default rotation
        particleSystem.enableEmission = false;

        // Set the looking direction of the rocket to the target
        Vector3 direction = gameObject.transform.forward * range;

        /*
         *      direction = Quaternion.Euler(0, -angularOffset + addRotation, 0) * direction;
         *      direction  *= (mulRange + addRange);
         */

        // Set the target position of the rocket
        Vector3 targetPosition = gameObject.transform.position + direction;

        // Quick and dirty! Set the destination to a negative value, so it muast not be destroyed and the rocket trail is able to smoothly disappear
        targetPosition.y = -50f;

        // Get the rocketbehaviour component...
        RocketBehaviour rocketBehaviour = spawnedRocket.GetComponent <RocketBehaviour>();

        // And set the ownerscript (for datamining)
        rocketBehaviour.OwnerScript = this.OwnerScript;
        // Scale the size of the rocket to one fith of the original size
        spawnedRocket.gameObject.transform.localScale = new Vector3(0.2f, 0.2f, 0.2f);
        // Call Launch from the attached rocketbehaviour script
        rocketBehaviour.Launch(targetPosition);
        // The rocket looks into the right direction so we can enable the emission of the particle system
        particleSystem.enableEmission = true;
    }
    void HandleRocketCollision(RocketBehaviour rocket, Vector3 hitPosition)
    {
        if (!rocket.state.launched)
        {
            return;
        }

        if (rocket.configuration.sourcePlanet == this && !rocket.state.leftPlanet)
        {
            return;
        }

        GetComponent <AudioSource> ().Play();

        HitInfo hitInfo = ReceiveDamage(rocket.damage, hitPosition, rocket.configuration.sourcePlanet.configuration.mainColor);

        var rocketBody = rocket.GetComponent <Rigidbody> ();
        var rigidBody  = GetComponent <Rigidbody> ();

        rigidBody.velocity += rocketBody.velocity * rocketBody.mass / rigidBody.mass;

        var eventManager = GameObject.Find("EventManager").GetComponent <EventManager>();

        eventManager.planetHitEvent.Invoke(this, rocket, hitInfo);

        Destroy(rocket.gameObject);

        // go boom
        explosion.gameObject.transform.localPosition = hitPosition;
        explosion.gameObject.transform.localRotation = Quaternion.LookRotation(hitPosition);

        var emitParams = new ParticleSystem.EmitParams();

        emitParams.startColor = rocket.configuration.sourcePlanet.configuration.mainColor;
        explosion.Emit(emitParams, 1000 * (int)hitInfo.damageDealt + 100);
    }
Example #10
0
 // Start is called before the first frame update
 void Start()
 {
     player = GameObject.FindGameObjectWithTag("Player").GetComponent <RocketBehaviour>();
 }
Example #11
0
    private void SetCommonData()
    {
        hatchControlData.ReloadTime = tankData.ReloadTimeRocket;

        positionCursorData.angleRotationSpeed = gunData.RotationSpeed;
        positionCursorData.turret             = turretControl;

        TankDepression(tankPreset.ToString());

        positionCursorData.inverted = false;
        positionCursorData.isAlive  = true;

        movement.maxSpeed          = tracksLeftData.MaxSpeed + tracksRightData.MaxSpeed;
        movement.gravity           = gameGravity;
        movement.rotationSpeed     = tracksLeftData.TraverseSpeed + tracksRightData.TraverseSpeed;
        movement.horsePower        = tankData.horsePower;
        movement.trackWheelsLeft   = trackWheelsLeft;
        movement.trackWheelsRight  = trackWheelsRight;
        movement.trackLeft         = trackLeft;
        movement.trackRight        = trackRight;
        movement.isAlive           = true;
        movement.smokeExhaustLeft  = smokeExhaustLeft;
        movement.smokeExhaustRight = smokeExhaustRight;
        movement.dirtForwardLeft   = dirtForwardLeft;
        movement.dirtForwardRight  = dirtForwardRight;
        movement.dirtBackwardLeft  = dirtBackwardLeft;
        movement.dirtBackwardRight = dirtBackwardRight;
        //.weight is calculated later

        shellBehaviourData = shell.AddComponent("ShellBehaviour") as ShellBehaviour;
        shellBehaviourData.currentShell = shellData;

        rocketBehaviourData = rocket.AddComponent("RocketBehaviour") as RocketBehaviour;
        rocketBehaviourData.currentRocket = rocketData;

        fireRocketData.Rocket           = rocket.rigidbody;
        fireRocketData.SpawnPointRocket = GameObject.Find(user + "RocketSpawnPoint");
        fireRocketData.isAlive          = true;

        GetAmmo();

        movement.weight = tankData.Weight;
        if (shellCaliber == DataShells.ShellSize.mm40 || shellCaliber == DataShells.ShellSize.mm50)
        {
            gunFire = GameObject.Find(tankPreset.ToString() + "ShellSmallSound").
                      GetComponent("AudioSource") as AudioSource;
        }
        else
        {
            gunFire = GameObject.Find(tankPreset.ToString() + "ShellSound").
                      GetComponent("AudioSource") as AudioSource;
        }
        rocketFire = GameObject.Find(tankPreset.ToString() + "RocketSound").
                     GetComponent("AudioSource") as AudioSource;
        engine = GameObject.Find(tankPreset.ToString() + "ChassisSound").
                 GetComponent("AudioSource") as AudioSource;
        engineMoving = GameObject.Find(tankPreset.ToString() + "ChassisMovingSound").
                       GetComponent("AudioSource") as AudioSource;


        gameObject.audio.clip   = engineMoving.clip;
        gameObject.audio.volume = 0.3f;
        gameObject.audio.loop   = true;
        gameObject.audio.Stop();

        gun.audio.clip   = gunFire.clip;
        gun.audio.volume = 0.4f;

        hatchControl.audio.clip   = rocketFire.clip;
        hatchControl.audio.volume = 0.3f;

        chassis.audio.clip   = engine.clip;
        chassis.audio.volume = 0.3f;
        chassis.audio.loop   = true;
        chassis.audio.Play();
    }
Example #12
0
    protected virtual void Start()
    {
        PlayerBehaviour = GameObject.FindGameObjectWithTag("Player").GetComponent <RocketBehaviour>();

        rig = GetComponent <Rigidbody2D>();
    }
Example #13
0
    // Use this for initialization
    void Start()
    {
        Screen.showCursor = false;

        screenCenter = new Vector3(Screen.width / 2, Screen.height / 2, 0f);
        ridingRocket = false;
        isDead = false;
        stunTimer = 0f;
        rocketCount = rocketMax;

        initialConstraints = rigidbody.constraints;

        animation = GetComponentInChildren<Animation>();

        rocket = null;

        boredomClock = (BoredomClock) FindObjectOfType(typeof(BoredomClock));
        timerBar = (TimerBarBehaviour) FindObjectOfType(typeof(TimerBarBehaviour));

        facingRight = true;
    }
Example #14
0
    private void FireRocket(Vector3 aimDir, bool ride)
    {
        float angle = Mathf.Rad2Deg * Mathf.Atan2(-aimDir.y, aimDir.x);
        rocket = (RocketBehaviour) Instantiate(rocketPrefab, transform.position + shoulderPos + aimDir * 3, Quaternion.Euler(new Vector3(angle, 90f, 0f)));
        rocket.rigidbody.velocity = rigidbody.velocity;

        // ride rocket
        if (ride) {
            rocket.SetControlRocket(true);
            ridingRocket = true;
            transform.parent = rocket.transform;
            rigidbody.isKinematic = true;

            animation.Play("StandAnimation", PlayMode.StopAll);

            MountRocket(transform.localPosition, transform.localRotation, facingRight);
        }
    }
Example #15
0
	private void SetCommonData()
	{
		hatchControlData.ReloadTime = tankData.ReloadTimeRocket;
		
		positionCursorData.angleRotationSpeed = gunData.RotationSpeed;
		positionCursorData.turret = turretControl;
		
		TankDepression(tankPreset.ToString());
		
		positionCursorData.inverted = false;
		positionCursorData.isAlive = true;
		
		movement.maxSpeed = tracksLeftData.MaxSpeed + tracksRightData.MaxSpeed;
		movement.gravity = gameGravity;
		movement.rotationSpeed = tracksLeftData.TraverseSpeed + tracksRightData.TraverseSpeed;
		movement.horsePower = tankData.horsePower;
		movement.trackWheelsLeft = trackWheelsLeft;
		movement.trackWheelsRight = trackWheelsRight;
		movement.trackLeft = trackLeft;
		movement.trackRight = trackRight;
		movement.isAlive = true;
		movement.smokeExhaustLeft = smokeExhaustLeft;
		movement.smokeExhaustRight = smokeExhaustRight;
		movement.dirtForwardLeft = dirtForwardLeft;
		movement.dirtForwardRight = dirtForwardRight;
		movement.dirtBackwardLeft = dirtBackwardLeft;
		movement.dirtBackwardRight = dirtBackwardRight;
		//.weight is calculated later

		shellBehaviourData = shell.AddComponent("ShellBehaviour") as ShellBehaviour;
		shellBehaviourData.currentShell = shellData;
		
		rocketBehaviourData = rocket.AddComponent("RocketBehaviour") as RocketBehaviour;
		rocketBehaviourData.currentRocket = rocketData;
		                                           
		fireRocketData.Rocket = rocket.rigidbody;
		fireRocketData.SpawnPointRocket = GameObject.Find(user+"RocketSpawnPoint");
		fireRocketData.isAlive = true;
		
		GetAmmo();
		
		movement.weight = tankData.Weight;
		if(shellCaliber == DataShells.ShellSize.mm40 || shellCaliber == DataShells.ShellSize.mm50)
		{
			gunFire = GameObject.Find(tankPreset.ToString()+"ShellSmallSound").
				GetComponent("AudioSource") as AudioSource;
		}
		else
		{
			gunFire = GameObject.Find(tankPreset.ToString()+"ShellSound").
				GetComponent("AudioSource") as AudioSource;
		}
		rocketFire = GameObject.Find(tankPreset.ToString()+"RocketSound").
			GetComponent("AudioSource") as AudioSource;
		engine = GameObject.Find(tankPreset.ToString()+"ChassisSound").
			GetComponent("AudioSource") as AudioSource;
		engineMoving = GameObject.Find(tankPreset.ToString()+"ChassisMovingSound").
			GetComponent("AudioSource") as AudioSource;
		
		
		gameObject.audio.clip = engineMoving.clip;
		gameObject.audio.volume = 0.3f;
		gameObject.audio.loop = true;
		gameObject.audio.Stop();
		
		gun.audio.clip = gunFire.clip;
		gun.audio.volume = 0.4f;
		
		hatchControl.audio.clip = rocketFire.clip;
		hatchControl.audio.volume = 0.3f;
		
		chassis.audio.clip = engine.clip;
		chassis.audio.volume = 0.3f;
		chassis.audio.loop = true;
		chassis.audio.Play();
	}
 // Use this for initialization
 void Start()
 {
     rend           = GetComponent <Renderer>();
     screenMidPoint = Screen.width / 2;
     rocketScript   = player.GetComponent <RocketBehaviour>();
 }