Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        velocityZ = GameManager.gm.lunghezzaFlusso;

        combatAttack = transform.parent.gameObject.GetComponent <CombatAttack>();
        VelocityZOrigine();

        // Move ();

        // ManageCollisions ();
    }
Exemplo n.º 2
0
        public void ResolveNullAttack_Throws()
        {
            var          mckRand = new MockBd2Randomiser();
            MockBd2Map   mp      = new MockBd2Map();
            bd2World     wld     = new bd2World(mp);
            var          sut     = new CombatManager(wld, mckRand);
            CombatAttack ca      = new CombatAttack();

            Assert.Throws <BdBaseException>(() => {
                var res = sut.ResolveAttack(null);
            });
        }
Exemplo n.º 3
0
        public void Resolve_NullVictim_Throws()
        {
            var        mckRand = new MockBd2Randomiser();
            MockBd2Map mp      = new MockBd2Map();
            bd2World   wld     = new bd2World(mp);
            var        sut     = new CombatManager(wld, mckRand);
            MappedBot  mb      = new MappedBot(new MockBotFactory().CreateBasicMockBot().ToBot());

            CombatAttack ca = new CombatAttack();

            ca.Attacker = mb;
            ca.Victim   = null;
            var excpt = Assert.Throws <BdBaseException>(() => {
                var res = sut.ResolveAttack(ca);
            });

            Assert.Contains("victim", excpt.Message);
        }
Exemplo n.º 4
0
    void VelocityZOrigine()
    {
        if (!takeVelocityZFromParent)
        {
            return;
        }

        CombatAttack combatAttack = transform.parent.gameObject.GetComponent <CombatAttack>();

        if (combatAttack != null)
        {
            velocityZ = combatAttack.velocityZ;
        }
        else
        {
            Debug.LogError("No Parent found or the Parent hasn't a component of type 'CombatAttack' or a componenet that inherit from the type 'CombatAttack'");
        }
    }
Exemplo n.º 5
0
        public void FullResolve_DoesHit()
        {
            b.Info.Flow();

            var mckRand = new MockBd2Randomiser();

            mckRand.Mock_SetD100Result(0);
            mckRand.Mock_SetD10Result(100);
            mckRand.Mock_SetCanTargetHit(true);

            MockBd2Map mp = new MockBd2Map();

            MockBd2World wld = new MockBd2World(mp);

            wld.Test_LOSCanHitReturn(true);
            var sut = new CombatManager(wld, mckRand);


            var mbf = new MockBotFactory();
            var atk = new MockMappedBot(mbf.CreateBasicMockBot().ToBot());

            atk.Test_Initialise();
            var vic = new MockMappedBot(mbf.CreateBasicMockBot().ToBot());

            vic.Test_Initialise();

            var          mw = new MockWeapon();
            CombatAttack ca = new CombatAttack();

            ca.Attacker                  = atk;
            ca.Victim                    = vic;
            ca.Weapon                    = mw;
            ca.WeaponInstance            = new ActiveEquipment(mw);
            ca.WeaponInstance.MountPoint = MountPoint.Turret;
            var res = sut.ResolveAttack(ca);

            Assert.NotNull(res);
            Assert.True(res.DidHit);
        }
Exemplo n.º 6
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();


        CombatAttack myTarget = (CombatAttack)target;

        /*
         * EditorGUILayout.LabelField("Space:");
         *
         * myTarget.velocityZ = EditorGUILayout.Slider("Velocity Z", myTarget.velocityZ, 0.1f, 100f);
         *
         *
         * EditorGUILayout.LabelField("Time:");
         *
         * myTarget.lifeTime = EditorGUILayout.Slider("Life Time:", myTarget.lifeTime, 1f, 60f);
         */

        //Space
        SerializedProperty takeVelocityZFromParent = serializedObject.FindProperty("takeVelocityZFromParent");

        SerializedProperty velocityZ = serializedObject.FindProperty("velocityZ");

        SerializedProperty rotationVelocityY = serializedObject.FindProperty("rotationVelocityY");

        SerializedProperty rotationVelocityZ = serializedObject.FindProperty("rotationVelocityZ");

        //Time
        SerializedProperty lifeTime = serializedObject.FindProperty("lifeTime");

        //SerializedProperty hit = serializedObject.FindProperty("hit");

        //Hit
        SerializedProperty haveToCollide = serializedObject.FindProperty("haveToCollide");


        //Sound
        SerializedProperty haveSpawnSound = serializedObject.FindProperty("haveSpawnSound");

        SerializedProperty spawnSound = serializedObject.FindProperty("spawnSound");


        ////////////
        EditorGUI.BeginChangeCheck();

        //Space
        EditorGUILayout.PropertyField(takeVelocityZFromParent, false);

        if (!myTarget.takeVelocityZFromParent)
        {
            EditorGUILayout.PropertyField(velocityZ, false);
        }

        if (rotationVelocityY != null)
        {
            EditorGUILayout.PropertyField(rotationVelocityY, false);
        }

        if (rotationVelocityZ != null)
        {
            EditorGUILayout.PropertyField(rotationVelocityZ, false);
        }

        //Time
        EditorGUILayout.PropertyField(lifeTime, false);

        //Hit
        EditorGUILayout.PropertyField(haveToCollide, false);

        if (myTarget.haveToCollide)
        {
            EditorGUILayout.PropertyField(serializedObject.FindProperty("haveToInstantiateSomthingOnHit"));

            if (myTarget.haveToInstantiateSomthingOnHit)
            {
                myTarget.toInstantiateOnHit = EditorGUILayout.ObjectField("To Instantiate On Hit", myTarget.toInstantiateOnHit, typeof(GameObject), false) as GameObject;

                EditorGUILayout.HelpBox(
                    "'To Instantiate On Hit' accept only project prefabs. " +
                    "After modifying this field " +
                    "click on the 'Apply' button (if it exist at the top right of this inspector), " +
                    "otherwise the change is not reflercted in play mode.", MessageType.Info, true);
            }


            EditorGUILayout.PropertyField(serializedObject.FindProperty("haveToAssignTemporaryMaterialToHittedObject"));

            if (myTarget.haveToAssignTemporaryMaterialToHittedObject)
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("toAssignToHittedObject"));

                EditorGUILayout.PropertyField(serializedObject.FindProperty("toAssignToHittedObjectDuration"));
            }
        }


        //Sound
        EditorGUILayout.PropertyField(haveSpawnSound, false);

        if (myTarget.haveSpawnSound)
        {
            EditorGUILayout.PropertyField(spawnSound, false);
        }



        EditorGUILayout.Separator();

        if (myTarget.haveToCollide)
        {
            EditorGUILayout.PropertyField(serializedObject.FindProperty("haveHitSound"));

            if (myTarget.haveHitSound)
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("hitSound"));
            }
        }



        if (EditorGUI.EndChangeCheck())
        {
            serializedObject.ApplyModifiedProperties();
        }
    }
 public void DamageCombatant(CombatAttack atk)
 {
     objCombatant.DamageCombatant(atk);
     UpdateHealth();
 }