Exemplo n.º 1
0
    public static ShellBehaviour GetObject()
    {
        ShellBehaviour res = null;

        if (FreeItems.Count > 0)
        {
            res = FreeItems[0];
            FreeItems.RemoveAt(0);
        }
        return(res);
    }
Exemplo n.º 2
0
    public override void Fire(Transform firePoint)
    {
        float fraction = angle / amount;

        for (int i = 0; i < amount; i++)
        {
            float degrees = fraction * i - (angle / 2) + (fraction / 2);
            float radians = Mathf.Deg2Rad * degrees;

            Vector3 direction = firePoint.rotation * new Vector2(Mathf.Sin(radians), Mathf.Cos(radians));

            ShellBehaviour shellBehaviour = Instantiate(shellPrefab, firePoint.position, Quaternion.Euler(direction));
            shellBehaviour.AddVelocityChangeForce(direction.normalized);
        }
    }
Exemplo n.º 3
0
    public void ShotShell(Sprite sprite, float speed, int damage, float shellReloadTime)
    {
        reloadTime = shellReloadTime;
        float          angle = Mathf.Atan2(tankShellPoint.right.y, tankShellPoint.right.x) * Mathf.Rad2Deg;
        ShellBehaviour shell = ShellPoolManager.GetObject();

        if (shell != null)
        {
            shell.transform.position = tankShellPoint.position;
            shell.transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
            shell.gameObject.SetActive(true);
        }
        else
        {
            shell = Instantiate(tankShell, tankShellPoint.position, Quaternion.AngleAxis(angle, Vector3.forward)) as ShellBehaviour;
        }
        shell.SetDirection(tankShellPoint.right, sprite, speed, damage);
    }
    public override void Fire(Transform firePoint)
    {
        float fraction = angle / amount;

        for (int i = 0; i < amount; i++)
        {
            float degrees = fraction * i - (angle / 2) + (fraction / 2);
            float radians = Mathf.Deg2Rad * degrees;

            Vector3 direction = firePoint.rotation * new Vector2(Mathf.Sin(radians), Mathf.Cos(radians));

            GameObject shell = spawnGameObjectBehaviour.Spawn(prefab, firePoint.position, Quaternion.Euler(direction));

            ShellBehaviour shellBehaviour = shell.GetComponent <ShellBehaviour>();

            Assert.IsNotNull(shellBehaviour, $"{shell.gameObject.name} doesn't have ShellBehaviour component");

            shellBehaviour.AddVelocityChangeForce(direction.normalized);
        }
    }
Exemplo n.º 5
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();
    }
Exemplo n.º 6
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();
	}
Exemplo n.º 7
0
 public static void AddObject(ShellBehaviour obj)
 {
     FreeItems.Add(obj);
 }
Exemplo n.º 8
0
 // Use this for initialization
 void Start()
 {
     //Debug.Log("===========");
     b             = GetComponent <ShellBehaviour>();
     shellCollider = GetComponent <Collider2D>();
 }