コード例 #1
0
        public void CreateExposalBracketingTest()
        {
            ShootParameters parameters = new ShootParameters(IsoSpeedEnum.iso50, ApertureEnum.f5_6, ExposalEnum.t1_100);

            Expect.Once.On(_camera).Method("GetAvailableValues").With(EDSDK.PropID_Tv).Will(Return.Value(
                                                                                                new int[]
            {
                (int)ExposalEnum.t1_4000,
                (int)ExposalEnum.t1_125,
                (int)ExposalEnum.t1_100,
                (int)ExposalEnum.t1_80,
                (int)ExposalEnum.t1_60,
                (int)ExposalEnum.t1,
                (int)ExposalEnum.t30
            }));

            CameraProcessor processor = new CameraProcessor(_camera, _cameraInfo);

            IShootParameters[] exposalBracketing = processor.CreateExposalBracketing(2, 3, parameters);

            Assert.AreEqual(3, exposalBracketing.Length);
            Assert.AreEqual(new ShootParameters(IsoSpeedEnum.iso50, ApertureEnum.f5_6, ExposalEnum.t1_4000), exposalBracketing[0]);
            Assert.AreEqual(new ShootParameters(IsoSpeedEnum.iso50, ApertureEnum.f5_6, ExposalEnum.t1_100), exposalBracketing[1]);
            Assert.AreEqual(new ShootParameters(IsoSpeedEnum.iso50, ApertureEnum.f5_6, ExposalEnum.t1_60), exposalBracketing[2]);

            _mockery.VerifyAllExpectationsHaveBeenMet();
        }
コード例 #2
0
 public void Shoot(ShootParameters shootParameters, DamageTag damageTag)
 {
     foreach (ShootOriginScript origin in shootOrigins)
     {
         origin.Shoot(shootParameters, damageTag);
     }
 }
コード例 #3
0
    public static WeaponParameters CreateWeaponSetInFolder(string folderPath, string weaponName, WeaponScript linkedWeapon)
    {
        WeaponParameters     weaponParams     = ScriptableObject.CreateInstance <WeaponParameters>();
        ShootParameters      shootParams      = ScriptableObject.CreateInstance <ShootParameters>();
        ProjectileParameters projectileParams = ScriptableObject.CreateInstance <ProjectileParameters>();

        weaponParams.weaponName = weaponName;

        weaponParams.SetWeaponPrefab(linkedWeapon);

        weaponParams.SetShootParameters(shootParams);

        ProjectileScript baseProjectilePrefab = AssetDatabase.LoadAssetAtPath <ProjectileScript>("Assets/Weapons/BaseProjectile.prefab");

        shootParams.SetProjectilePrefab(baseProjectilePrefab);

        shootParams.SetProjectileParameters(projectileParams);

        string weaponPath     = AssetDatabase.GenerateUniqueAssetPath(folderPath + "/" + weaponName + " Weapon Parameters.asset");
        string shootPath      = AssetDatabase.GenerateUniqueAssetPath(folderPath + "/" + weaponName + " Shoot Parameters.asset");
        string projectilePath = AssetDatabase.GenerateUniqueAssetPath(folderPath + "/" + weaponName + " Projectiles Parameters.asset");

        AssetDatabase.CreateAsset(weaponParams, weaponPath);
        AssetDatabase.CreateAsset(shootParams, shootPath);
        AssetDatabase.CreateAsset(projectileParams, projectilePath);

        EditorUtility.SetDirty(weaponParams);
        EditorUtility.SetDirty(shootParams);
        EditorUtility.SetDirty(projectileParams);

        return(weaponParams);
    }
コード例 #4
0
    public void UpdateTouch(bool fingerOn, Vector3 worldPositon)
    {
        if (fingerOnSlot && !fingerOn)
        {
            fingerOnSlot = false;

            relatedCompetence.EndShowPreview();
        }

        if (!fingerOnSlot && fingerOn)
        {
            fingerOnSlot = true;

            relatedCompetence.StartShowPreview();
        }

        if (fingerOnSlot)
        {
            if (equipmentType == EquipmentType.Hull)
            {
                if (relatedCompetence as CompetenceRamming != null)
                {
                    (relatedCompetence as CompetenceRamming).UpdateCompetence(relatedShip.transform.position, relatedShip.GetShipVelocity.normalized);
                }
                else
                {
                    relatedCompetence.UpdateCompetence(relatedShip.GetShipVelocity);
                }
            }

            #region Canon
            else if (equipmentType == EquipmentType.Canon)
            {
                foreach (EquipmentObject equipObj in relatedCompetence.GetLinkEquipment.GetAllSpawnedEquipments)
                {
                    ShootParameters shootParameters = (relatedCompetence as CompetenceShoot).shootParameters;

                    if (equipObj as EquipmentObjectShoot != null)
                    {
                        (equipObj as EquipmentObjectShoot).UpdateShootOriginsModifiedDirection(worldPositon.x, 0);
                    }
                }
                relatedCompetence.UpdateCompetence(worldPositon);
            }
            #endregion

            #region Catapult
            else if (equipmentType == EquipmentType.Catapult)
            {
                ShootParameters shootParameters = (relatedCompetence as CompetenceShoot).shootParameters;

                Vector3 catapultVector = worldPositon;
                float   distance       = Mathf.Lerp(shootParameters.GetCatapultMinDistance, shootParameters.GetCatapultMaxDistance, worldPositon.magnitude);

                relatedCompetence.UpdateCompetence(relatedShip.transform.position + (worldPositon.normalized * distance));
            }
            #endregion
        }
    }
コード例 #5
0
 /// <summary>
 /// Commence un tir sur cet équipement
 /// </summary>
 /// <param name="shootParameters">Paramètres du tir</param>
 /// <param name="aimPos">Position visée</param>
 public void Shoot(ShootParameters shootParameters, Vector3 aimPos, bool lockPosition, ProjectileSpecialParameters projectileSpecialParameters)
 {
     foreach (ShootOrigin shootOrigin in shootOrigins)
     {
         shootOrigin.SetProjectileSpecialParameters(projectileSpecialParameters);
         shootOrigin.StartShooting(shootParameters, aimPos, lockPosition);
     }
 }
コード例 #6
0
    public void EndTouch(bool endedOnButton, Vector3 worldPositon)
    {
        if (endedOnButton)
        {
            if (startedTouch && fingerOnSlot)
            {
                if (relatedCompetence as CompetenceShoot != null)
                {
                    if (!relatedCompetence.IsAimCompetence())
                    {
                        relatedCompetence.UseCompetence(worldPositon);
                        SetCooldown();
                    }
                    else
                    {
                        ShootParameters shootParameters = (relatedCompetence as CompetenceShoot).shootParameters;

                        Vector3 catapultVector = worldPositon;
                        float   distance       = Mathf.Lerp(shootParameters.GetCatapultMinDistance, shootParameters.GetCatapultMaxDistance, worldPositon.magnitude);

                        relatedCompetence.UseCompetence(relatedShip.transform.position + (worldPositon.normalized * distance));

                        SetCooldown();
                    }
                }
                else if (relatedCompetence as CompetenceRamming != null)
                {
                    relatedCompetence.EndShowPreview();
                    relatedCompetence.UseCompetence(relatedShip.ShipMvt);
                    SetCooldown();
                }
                else if (relatedCompetence as CompetenceProtection != null)
                {
                    relatedCompetence.EndShowPreview();
                    (relatedCompetence as CompetenceProtection).UseCompetence(relatedShip);
                    SetCooldown();
                }
                else if (relatedCompetence as CompetenceSpecialShipMove != null)
                {
                    relatedCompetence.EndShowPreview();
                    (relatedCompetence as CompetenceSpecialShipMove).UseCompetence(relatedShip);
                    SetCooldown();
                }
            }
        }

        startedTouch         = false;
        fingerOnSlot         = false;
        currentFingerTouchId = -1;
    }
コード例 #7
0
    public void SetUp(DamageTag dmgTag, bool instantiateWeapon)
    {
        currentShootParameters = baseWeaponParameters.GetShootParameters;
        cadenceTimerSystem     = new TimerSystem(currentShootParameters.GetShootCadence, null);

        serialShotTimerSystem = new TimerSystem(currentShootParameters.GetTimeBetweenEachSerialShot, EndShooting, currentShootParameters.GetNumberOfSerialShots - 1, Shoot);

        if (instantiateWeapon)
        {
            InstantiateBaseWeapon();
        }

        damageTag = dmgTag;
    }
コード例 #8
0
    /// <summary>
    /// Entame un tir sur ce shoot origin
    /// </summary>
    /// <param name="shootParameters">Paramètres du tir</param>
    /// <param name="shAimPosition">Position visée par le tir</param>
    public void StartShooting(ShootParameters shootParameters, Vector3 shAimPosition, bool lockDirection)
    {
        currentShootParameters = shootParameters;
        shootAimPosition       = shAimPosition;

        Shoot(currentShootParameters.GetCurrentSalvo);

        lockDirectionAfterStartShoot = lockDirection;

        if (lockDirectionAfterStartShoot)
        {
            lockedDirection          = (shootAimPosition - transform.position).normalized;
            relativeShootAimPosition = shootAimPosition - transform.position;
            rotationWhenShot         = directionParent.rotation;
        }
    }
コード例 #9
0
    public void SelectWeapon()
    {
        currentWeapon          = GetSelectedWeaponObject;
        currentShootParameters = GetSelectedShootParameters;

        if (cadenceTimerSystem != null)
        {
            cadenceTimerSystem.ChangeTimerValue(currentShootParameters.GetShootCadence);
        }

        if (cadenceTimerSystem != null)
        {
            serialShotTimerSystem.ChangeTimerValue(currentShootParameters.GetTimeBetweenEachSerialShot);
            serialShotTimerSystem.ChangeIterationValue(currentShootParameters.GetNumberOfSerialShots - 1);
        }

        OnWeaponChanged?.Invoke(GetSelectedWeaponParameters.weaponName);
    }
コード例 #10
0
        public void ApplyToTest()
        {
            Mockery mockery = new Mockery();
            ICamera camera  = (ICamera)mockery.NewMock(typeof(ICamera));

            IsoSpeedEnum iso      = IsoSpeedEnum.iso50;
            ApertureEnum aperture = ApertureEnum.f10;
            ExposalEnum  exposal  = ExposalEnum.t1_100;

            Expect.Once.On(camera).Method("SetProperty").With(EDSDK.PropID_ISOSpeed, (int)iso);
            Expect.Once.On(camera).Method("SetProperty").With(EDSDK.PropID_Av, (int)aperture);
            Expect.Once.On(camera).Method("SetProperty").With(EDSDK.PropID_Tv, (int)exposal);

            ShootParameters parameters = new ShootParameters(iso, aperture, exposal);

            parameters.ApplyTo(camera);

            mockery.VerifyAllExpectationsHaveBeenMet();
        }
コード例 #11
0
    public static void ShowWeaponParameters(WeaponParameters weaponParameters, float indentValue, ref bool showShootParameters, ref bool showProjectileParameters)
    {
        SerializedObject serializedParameters = new SerializedObject(weaponParameters);

        serializedParameters.Update();

        #region Base Parameters
        GUI.Label(EditorStaticMethods.GetIndentedControlRect(indentValue), "Base Parameters", EditorStyles.boldLabel);

        SerializedProperty weaponNameAttribute = serializedParameters.FindProperty("weaponName");
        EditorGUI.PropertyField(EditorStaticMethods.GetIndentedControlRect(indentValue), weaponNameAttribute);

        SerializedProperty weaponPrefabAttribute = serializedParameters.FindProperty("weaponPrefab");
        EditorGUI.PropertyField(EditorStaticMethods.GetIndentedControlRect(indentValue), weaponPrefabAttribute);
        #endregion

        #region Shoot Parameters
        GUILayout.Space(20);

        GUI.Label(EditorStaticMethods.GetIndentedControlRect(indentValue), "Shoot Parameters", EditorStyles.boldLabel);

        SerializedProperty shootParamsAttribute = serializedParameters.FindProperty("shootParameters");
        EditorGUI.PropertyField(EditorStaticMethods.GetIndentedControlRect(indentValue), shootParamsAttribute);

        serializedParameters.ApplyModifiedProperties();

        ShootParameters shootParams = weaponParameters.GetShootParameters;
        if (shootParams != null)
        {
            showShootParameters = EditorGUI.BeginFoldoutHeaderGroup(EditorStaticMethods.GetIndentedControlRect(indentValue), showShootParameters, (showShootParameters ? "Close" : "Open") + " Shoot Parameters", showShootParameters ? EditorStyles.boldLabel : null);
            EditorGUI.EndFoldoutHeaderGroup();

            if (showShootParameters)
            {
                EditorGUILayout.BeginVertical("box");
                ShootParametersInspector.ShowShootParameters(shootParams, indentValue + 15, ref showProjectileParameters);
                EditorGUILayout.EndVertical();
            }
        }
        #endregion
    }
コード例 #12
0
        public void CreateApertureBracketingTest()
        {
            ShootParameters parameters = new ShootParameters(IsoSpeedEnum.iso50, ApertureEnum.f5_6, ExposalEnum.t1_80);

            Aperture[] apertures = new Aperture[] { (Aperture)Aperture.Apertures.AtKey(ApertureEnum.f2), (Aperture)Aperture.Apertures.AtKey(ApertureEnum.f91) };


            Expect.Once.On(_camera).Method("GetAvailableValues").With(EDSDK.PropID_Tv).Will(Return.Value(
                                                                                                new int[]
            {
                (int)ExposalEnum.t30,
                (int)ExposalEnum.t1,
                (int)ExposalEnum.t1_60,
                (int)ExposalEnum.t1_80,
                (int)ExposalEnum.t1_100,
                (int)ExposalEnum.t1_125,
                (int)ExposalEnum.t1_4000
            }));
            Expect.Once.On(_camera).Method("GetAvailableValues").With(EDSDK.PropID_Av).Will(Return.Value(
                                                                                                new int[]
            {
                (int)ApertureEnum.f1,
                (int)ApertureEnum.f2,
                (int)ApertureEnum.f3_5,
                (int)ApertureEnum.f5_6,
                (int)ApertureEnum.f8,
                (int)ApertureEnum.f11,
                (int)ApertureEnum.f91
            }));

            CameraProcessor processor = new CameraProcessor(_camera, _cameraInfo);

            IShootParameters[] apertureBracketing = processor.CreateApertureBracketing(parameters, apertures);

            Assert.AreEqual(2, apertureBracketing.Length);
            Assert.AreEqual(new ShootParameters(IsoSpeedEnum.iso50, ApertureEnum.f2, ExposalEnum.t1_125), apertureBracketing[0]);
            Assert.AreEqual(new ShootParameters(IsoSpeedEnum.iso50, ApertureEnum.f91, ExposalEnum.t30), apertureBracketing[1]);

            _mockery.VerifyAllExpectationsHaveBeenMet();
        }
コード例 #13
0
    public void Shoot(ShootParameters shootParameters, DamageTag damageTag)
    {
        int projectileIndex               = shootParameters.GetProjectilePrefab.GetPoolingIndex;
        ProjectileScript projPrefab       = shootParameters.GetProjectilePrefab;
        float            imprecisionAngle = shootParameters.GetImprecisionAngle;

        for (int i = 0; i < shootParameters.GetNumberOfProjectilesPerShot; i++)
        {
            ProjectileScript newProj = poolingManager.GetProjectileFromPool(projectileIndex);

            if (newProj == null)
            {
                break;
            }

            newProj.transform.position = transform.position;
            newProj.transform.rotation = Quaternion.identity;
            //ProjectileScript newProj = Instantiate(projPrefab, transform.position, Quaternion.identity);
            Vector3 shootDirection = Quaternion.Euler(0, 0, Random.Range(-imprecisionAngle / 2, imprecisionAngle / 2)) * GetTrueDirection;
            newProj.Shoot(shootParameters.GetProjectileParameters, shootDirection, damageTag);
        }
    }
コード例 #14
0
 public WeaponSet(WeaponScript weaponObj, WeaponParameters weaponParams, ShootParameters shootParams)
 {
     weaponObject     = weaponObj;
     weaponParameters = weaponParams;
     shootParameters  = shootParams;
 }
コード例 #15
0
 private void OnEnable()
 {
     targetShootParameters = target as ShootParameters;
 }
コード例 #16
0
    public static void ShowShootParameters(ShootParameters shootParameters, float indentValue, ref bool showProjectileParameters)
    {
        SerializedObject serializedParameters = new SerializedObject(shootParameters);

        serializedParameters.Update();

        #region Base Parameters
        GUI.Label(EditorStaticMethods.GetIndentedControlRect(indentValue), "Base Parameters", EditorStyles.boldLabel);

        SerializedProperty projectilePrefabAttribute = serializedParameters.FindProperty("projectilePrefab");
        EditorGUI.PropertyField(EditorStaticMethods.GetIndentedControlRect(indentValue), projectilePrefabAttribute);

        SerializedProperty cadenceProperty = serializedParameters.FindProperty("shootCadence");
        EditorGUI.PropertyField(EditorStaticMethods.GetIndentedControlRect(indentValue), cadenceProperty, new GUIContent("Shoot Cadence", "The reloading time needed after a shot to be able to shoot again"));
        if (cadenceProperty.floatValue < 0)
        {
            cadenceProperty.floatValue = 0;
        }

        SerializedProperty numberOfProjectilesPerShotProperty = serializedParameters.FindProperty("numberOfProjectilesPerShot");
        EditorGUI.PropertyField(EditorStaticMethods.GetIndentedControlRect(indentValue), numberOfProjectilesPerShotProperty, new GUIContent("Number of Projectiles per Shot", "The number of projectile that will be instantiated on shot by each shoot origins of the weapon. Generaly of one except for shotguns"));
        if (numberOfProjectilesPerShotProperty.intValue < 1)
        {
            numberOfProjectilesPerShotProperty.intValue = 1;
        }

        SerializedProperty imprecisionAngleProperty = serializedParameters.FindProperty("imprecisionAngle");
        EditorGUI.PropertyField(EditorStaticMethods.GetIndentedControlRect(indentValue), imprecisionAngleProperty, new GUIContent("Imprecision Angle", "The angle of the cone in which the projectile direction will be randomly picked on shot. Set low for precise shots, set high for spray"));
        if (imprecisionAngleProperty.floatValue < 0)
        {
            imprecisionAngleProperty.floatValue = 0;
        }
        #endregion

        #region Serial Shots
        GUILayout.Space(20);
        GUI.Label(EditorStaticMethods.GetIndentedControlRect(indentValue), "Serial Shots", EditorStyles.boldLabel);

        SerializedProperty numberOfSerialShotsProperty = serializedParameters.FindProperty("numberOfSerialShots");
        bool isSerialShot = EditorGUI.Toggle(EditorStaticMethods.GetIndentedControlRect(indentValue), new GUIContent("Is Serial Shots", "Set true if you want a burst shot"), numberOfSerialShotsProperty.intValue > 1);

        if (isSerialShot)
        {
            if (numberOfSerialShotsProperty.intValue < 2)
            {
                numberOfSerialShotsProperty.intValue = 3;
            }

            EditorGUI.PropertyField(EditorStaticMethods.GetIndentedControlRect(indentValue), numberOfSerialShotsProperty, new GUIContent("Number of Shots", "The number of shots that will be done through the burst shot"));

            SerializedProperty timeBetweenEachSerialShotProperty = serializedParameters.FindProperty("timeBetweenEachSerialShot");
            EditorGUI.PropertyField(EditorStaticMethods.GetIndentedControlRect(indentValue), timeBetweenEachSerialShotProperty, new GUIContent("Time between each Shot", "The time between two shots of the burst shot"));

            if (numberOfSerialShotsProperty.intValue < 2)
            {
                numberOfSerialShotsProperty.intValue = 2;
            }

            if (timeBetweenEachSerialShotProperty.floatValue < 0)
            {
                timeBetweenEachSerialShotProperty.floatValue = 0;
            }
        }
        else
        {
            if (numberOfSerialShotsProperty.intValue != 1)
            {
                numberOfSerialShotsProperty.intValue = 1;
            }
        }
        #endregion

        #region Projectile Parameters
        GUILayout.Space(20);

        GUI.Label(EditorStaticMethods.GetIndentedControlRect(indentValue), "Projectiles Parameters", EditorStyles.boldLabel);

        SerializedProperty projParamsAttribute = serializedParameters.FindProperty("projectileParameters");
        EditorGUI.PropertyField(EditorStaticMethods.GetIndentedControlRect(indentValue), projParamsAttribute);

        serializedParameters.ApplyModifiedProperties();

        ProjectileParameters projParams = shootParameters.GetProjectileParameters;
        if (projParams != null)
        {
            showProjectileParameters = EditorGUI.BeginFoldoutHeaderGroup(EditorStaticMethods.GetIndentedControlRect(indentValue), showProjectileParameters, (showProjectileParameters ? "Close" : "Open") + " Projectile Parameters", showProjectileParameters ? EditorStyles.boldLabel : null);
            EditorGUI.EndFoldoutHeaderGroup();

            if (showProjectileParameters)
            {
                EditorGUILayout.BeginVertical("box");
                ProjectileParametersInspector.ShowProjectileParameters(projParams, indentValue + 15);
                EditorGUILayout.EndVertical();
            }
        }
        #endregion
    }
コード例 #17
0
ファイル: World.cs プロジェクト: jerry830202/unity3Dproject
	// ----------------------------------------------
	// PUBLIC FUNCTIONS
	// ----------------------------------------------	
	// -------------------------------------------
	/* 
	 * Ask for a new shoot
	 */
	public void AskNewShoot(ShootParameters newData) 
	{
		if ((shootProtagonist!=null)&&(shootEnemy!=null))
		{
			GameObject gShoot = (GameObject)Instantiate(((newData.type==Global.TYPE_PROTAGONIST)?shootProtagonist:shootEnemy)
														, new Vector3(newData.position.x, newData.position.y+1f, newData.position.z)
			            								, newData.origin.transform.rotation);
			Shoot sShoot = gShoot.GetComponent<Shoot>();
			sShoot.Type = newData.type;
			sShoot.Speed = newData.speed;
			sShoot.Damage = newData.damage;
			
			// PLAY SHOOT
			if (m_state == STATE_RUN)
			{
				if (gameShoot!=null) audio.PlayOneShot(gameShoot);
			}
		}
	}
コード例 #18
0
 public void SetShootParameters(ShootParameters shootParams)
 {
     shootParameters = shootParams;
 }