Exemple #1
0
        public void Apply_NotACharacter_Test()
        {
            var entity  = Mock.Of <IEntity>();
            var stunned = new Stunned(1);

            stunned.Apply(entity);
            Assert.IsTrue(true); // If we made it here without exception then the test passed
        }
Exemple #2
0
        public void Remove_NoConditions_Test()
        {
            var character = CreateMockCharacter();
            var stunned   = new Stunned(1);

            stunned.Apply(character);
            stunned.Remove(character);
            Assert.AreEqual(0, character.Conditions.Count);
        }
Exemple #3
0
        public void Apply_Character_WithExistingStunnedCondition_Test()
        {
            var character = CreateMockCharacter();

            character.Conditions.Add(new Stunned(2));
            var stunned = new Stunned(1);

            stunned.Apply(character);
        }
Exemple #4
0
        public void Apply_Character_NoConditions_Test()
        {
            var character = CreateMockCharacter();
            var stunned   = new Stunned(2);

            stunned.Apply(character);
            Assert.AreEqual(EntityIds.STUNNED_CONDITION_ID, character.Conditions[0].Id);
            Assert.AreSame(stunned, character.Conditions[0]);
        }
    public void stun(GameObject enemy)
    {
        Stunned         stunned    = enemy.GetComponent <Stunned>();
        StateController controller = enemy.GetComponent <StateController>();

        if (stunned && controller)
        {
            stunned.stun(duration);
        }
    }
    protected override bool performSkill(List <AbstractCreature> target, CombatData data)
    {
        if (target.Count != 1)
        {
            skillOnUseText = "Can only attack 1 target";
            return(false);
        }

        stun           = new Stunned(stunDuration, "Stunning Striked");
        skillOnUseText = "Stunned " + target[0] + "for " + stunDuration + " turn";
        target[0].statusController.addStatus(target[0], stun);
        return(true);
    }
Exemple #7
0
    private void Start()
    {
        #region Configuring State Machine

        _animator       = GetComponent <Animator>();
        _spriteRenderer = GetComponent <SpriteRenderer>();
        _rb             = GetComponent <Rigidbody2D>();

        _stateMachine = new StateMachine();

        // Instantiating states
        var running = new Running(this, _animator);
        var idle    = new Idle(this, _animator);
        var dashing = new Dashing(this, _animator, _rb);
        var stunned = new Stunned(this, _rb);

        // Assigning transitions
        _stateMachine.AddAnyTransition(stunned, IsStunned());
        At(running, idle, IsIdle());
        At(idle, running, IsMoving());
        At(idle, dashing, IsDashing());
        At(running, dashing, IsDashing());
        At(stunned, idle, IsNotStunned());

        // Starting state
        _stateMachine.SetState(running);

        // Method to assign transitions easily
        void At(IState to, IState from, Func <bool> condition) => _stateMachine.AddTransition(to, from, condition);

        // Transition conditions
        Func <bool> IsMoving() => () => (xInput != 0 || yInput != 0);
        Func <bool> IsIdle() => () => (xInput == 0 && yInput == 0);
        Func <bool> IsDashing() => () => (isDashing);
        Func <bool> IsNotDashing() => () => (!isDashing);
        Func <bool> IsStunned() => () => (isStunned);
        Func <bool> IsNotStunned() => () => (!isStunned);

        #endregion

        #region Instantiating instance variables
        // Get boundaries object to set player movement boundaries
        GameObject boundaryObj = GameObject.Find("Boundaries");
        Boundaries boundary    = boundaryObj.GetComponent <Boundaries>();
        xBoundary = boundary.playerBoundary_x;
        yBoundary = boundary.playerBoundary_y;

        // Base sorting layer
        baseLayer = GetComponent <SpriteRenderer>().sortingOrder;
        #endregion
    }
Exemple #8
0
 protected override void Start()
 {
     base.Start();
     Debug.Log("교수님 등장");
     level         = 1;
     attack        = 2; //shld be decided by level and setting file
     defense       = 2;
     maxhp         = 300;
     hp            = maxhp;
     debuffPercent = 0.0f;
     enemyAction   = new GunnerAction(this);
     debuff        = new Stunned(1);
     player        = GameObject.Find("Player").GetComponent <Player>();
     atkBuffTurn   = 0;
     atkBuffOn     = false;
     delA          = 1;
     delD          = 1;
 }
Exemple #9
0
        private void Actor_Hurt(object sender, AttackEventArgs attackArgs)
        {
            Actor victim = (Actor)sender;

            if (behaviorLists.ContainsKey(victim))
            {
                ActionList victimBehaviorList = behaviorLists[victim];
                Aggravated aggravated         = new Aggravated(victimBehaviorList, victim, attackArgs.damageInfo.attacker);
                if (!victimBehaviorList.has(aggravated))
                {
                    victimBehaviorList.pushFront(aggravated);
                }
                Stunned stunned = new Stunned(victimBehaviorList, victim);
                if (!victimBehaviorList.has(stunned))
                {
                    victimBehaviorList.pushFront(stunned);
                }
            }
        }
Exemple #10
0
        public string[] ToArray()
        {
            string[] array = new string[16];

            array[0]  = Blinded.Equals("Cured") ? "" : "Blinded";
            array[1]  = Charmed.Equals("Cured") ? "" : "Charmed";
            array[2]  = Deafened.Equals("Cured") ? "" : "Deafened";
            array[3]  = Encumbrance.Equals("Normal") ? "" : Encumbrance;
            array[4]  = Fatigued.Equals("Cured") ? "" : Fatigued;
            array[5]  = Frightened.Equals("Cured") ? "" : "Frightened";
            array[6]  = Grappled.Equals("Cured") ? "" : "Grappled";
            array[7]  = Incapacitated.Equals("Cured") ? "" : "Incapacitated";
            array[8]  = Invisible.Equals("Cured") ? "" : "Invisible";
            array[9]  = Paralyzed.Equals("Cured") ? "" : "Paralyzed";
            array[10] = Petrified.Equals("Cured") ? "" : "Petrified";
            array[11] = Poisoned.Equals("Cured") ? "" : "Poisoned";
            array[12] = Prone.Equals("Cured") ? "" : "Prone";
            array[13] = Restrained.Equals("Cured") ? "" : "Restrained";
            array[14] = Stunned.Equals("Cured") ? "" : "Stunned";
            array[15] = Unconscious.Equals("Cured") ? "" : "Unconscious";

            return(array);
        }
Exemple #11
0
        /// <summary>
        /// Draws the inspector for the pack
        /// </summary>
        /// <returns></returns>
        public static bool OnPackInspector(MotionController rMotionController)
        {
            EditorHelper.DrawSmallTitle(GroupName());
            EditorHelper.DrawLink("Mixamo Pro Magic Pack Animations", "http://www.ootii.com/Unity/MotionPacks/SpellCasting/SpellCastingUsersGuide.pdf");

            GUILayout.Space(5f);

            EditorGUILayout.LabelField("See included documentation:", EditorHelper.SmallBoldLabel);
            EditorGUILayout.LabelField("1. Download and import animations.", EditorHelper.SmallLabel);
            EditorGUILayout.LabelField("2. Unzip and replace animation meta files.", EditorHelper.SmallLabel);
            EditorGUILayout.LabelField("3. Select options and create motions.", EditorHelper.SmallLabel);

            EditorHelper.DrawLine();

            EditorHelper.BoolField("Create Mecanim States", "Determines if we create/override the existing sub-state machine", sCreateSubStateMachines);
            sCreateSubStateMachines = EditorHelper.FieldBoolValue;

            EditorHelper.BoolField("Create Input Aliases", "Determines if we create input aliases", sCreateInputAliases);
            sCreateInputAliases = EditorHelper.FieldBoolValue;

            EditorHelper.BoolField("Create Inventory", "Determines if we create/override the existing inventory", sCreateInventory);
            sCreateInventory = EditorHelper.FieldBoolValue;

            EditorHelper.BoolField("Create Attributes", "Determines if we create/override the existing attributes", sCreateAttributes);
            sCreateAttributes = EditorHelper.FieldBoolValue;

            EditorHelper.BoolField("Create Spell Inventory", "Create the spell inventory for the caster", sCreateSpellInventory);
            sCreateSpellInventory = EditorHelper.FieldBoolValue;

            EditorHelper.BoolField("Create Combatant", "Determines if we create/override the existing core", sCreateCore);
            sCreateCore = EditorHelper.FieldBoolValue;

            EditorHelper.BoolField("Create Motions", "Determines if we create the archery motions", sCreateMotions);
            sCreateMotions = EditorHelper.FieldBoolValue;

            GUILayout.Space(5f);

            if (GUILayout.Button(new GUIContent("Setup Pack", "Create and setup the motion pack."), EditorStyles.miniButton))
            {
                if (sCreateInventory)
                {
                    BasicInventory lInventory = rMotionController.gameObject.GetComponent <BasicInventory>();
                    if (lInventory == null)
                    {
                        lInventory = rMotionController.gameObject.AddComponent <BasicInventory>();
                    }

                    BasicInventoryItem lItem = lInventory.GetInventoryItem("Spell_01");
                    if (lItem != null)
                    {
                        lInventory.Items.Remove(lItem);
                    }

                    lInventory.Items.Add(new BasicInventoryItem());
                    lInventory.Items[lInventory.Items.Count - 1].ID          = "Spell_01";
                    lInventory.Items[lInventory.Items.Count - 1].EquipMotion = "PMP_EquipSpell";
                    lInventory.Items[lInventory.Items.Count - 1].StoreMotion = "PMP_StoreSpell";

                    BasicInventorySlot lSlot = lInventory.GetInventorySlot("RIGHT_HAND");
                    if (lSlot == null)
                    {
                        lInventory.Slots.Add(new BasicInventorySlot());
                        lInventory.Slots[lInventory.Slots.Count - 1].ID     = "RIGHT_HAND";
                        lInventory.Slots[lInventory.Slots.Count - 1].ItemID = "";
                    }

                    if (lInventory.GetInventorySlot("LEFT_HAND") == null)
                    {
                        lInventory.Slots.Add(new BasicInventorySlot());
                        lInventory.Slots[lInventory.Slots.Count - 1].ID     = "LEFT_HAND";
                        lInventory.Slots[lInventory.Slots.Count - 1].ItemID = "";
                    }

                    lSlot = lInventory.GetInventorySlot("LEFT_LOWER_ARM");
                    if (lSlot == null)
                    {
                        lInventory.Slots.Add(new BasicInventorySlot());
                        lInventory.Slots[lInventory.Slots.Count - 1].ID     = "LEFT_LOWER_ARM";
                        lInventory.Slots[lInventory.Slots.Count - 1].ItemID = "";
                    }

                    if (lInventory.GetInventorySlot("READY_PROJECTILE") == null)
                    {
                        lInventory.Slots.Add(new BasicInventorySlot());
                        lInventory.Slots[lInventory.Slots.Count - 1].ID     = "READY_PROJECTILE";
                        lInventory.Slots[lInventory.Slots.Count - 1].ItemID = "";
                    }

                    BasicInventorySet lWeaponSet = lInventory.GetWeaponSet("Spell Casting");
                    if (lWeaponSet != null)
                    {
                        lInventory.WeaponSets.Remove(lWeaponSet);
                    }

                    lWeaponSet    = new BasicInventorySet();
                    lWeaponSet.ID = "Spell Casting";

                    BasicInventorySetItem lWeaponSetItem = new BasicInventorySetItem();
                    lWeaponSetItem.ItemID      = "";
                    lWeaponSetItem.SlotID      = "LEFT_HAND";
                    lWeaponSetItem.Instantiate = true;
                    lWeaponSet.Items.Add(lWeaponSetItem);

                    lWeaponSetItem             = new BasicInventorySetItem();
                    lWeaponSetItem.ItemID      = "";
                    lWeaponSetItem.SlotID      = "READY_PROJECTILE";
                    lWeaponSetItem.Instantiate = false;
                    lWeaponSet.Items.Add(lWeaponSetItem);

                    lWeaponSetItem             = new BasicInventorySetItem();
                    lWeaponSetItem.ItemID      = "Spell_01";
                    lWeaponSetItem.SlotID      = "RIGHT_HAND";
                    lWeaponSetItem.Instantiate = false;
                    lWeaponSet.Items.Add(lWeaponSetItem);

                    lWeaponSetItem             = new BasicInventorySetItem();
                    lWeaponSetItem.ItemID      = "";
                    lWeaponSetItem.SlotID      = "LEFT_LOWER_ARM";
                    lWeaponSetItem.Instantiate = false;
                    lWeaponSet.Items.Add(lWeaponSetItem);

                    if (lInventory.WeaponSets.Count == 0)
                    {
                        BasicInventorySet lFirstWeaponSet = new BasicInventorySet();
                        lFirstWeaponSet.ID = "Sword and Shield";

                        lInventory.WeaponSets.Add(lFirstWeaponSet);
                    }

                    if (lInventory.WeaponSets.Count == 1)
                    {
                        BasicInventorySet lSecondWeaponSet = new BasicInventorySet();
                        lSecondWeaponSet.ID = "Longbow";

                        lInventory.WeaponSets.Add(lSecondWeaponSet);
                    }

                    lInventory.WeaponSets.Insert(2, lWeaponSet);
                }

                if (sCreateAttributes)
                {
                    BasicAttributes lAttributes = rMotionController.gameObject.GetComponent <BasicAttributes>();
                    if (lAttributes == null)
                    {
                        lAttributes = rMotionController.gameObject.AddComponent <BasicAttributes>();
                    }

                    BasicAttribute lAttribute = lAttributes.GetAttribute("Health");
                    if (lAttribute != null)
                    {
                        lAttributes.Items.Remove(lAttribute);
                    }

                    lAttributes.Items.Add(new BasicAttribute());
                    lAttributes.Items[lAttributes.Items.Count - 1].ID = "Health";
                    lAttributes.Items[lAttributes.Items.Count - 1].SetValue <float>(100f);
                }

                if (sCreateSpellInventory)
                {
                    SpellInventory lAttributes = rMotionController.gameObject.GetComponent <SpellInventory>();
                    if (lAttributes == null)
                    {
                        lAttributes = rMotionController.gameObject.AddComponent <SpellInventory>();
                    }
                }

                if (sCreateCore)
                {
                    Combatant lCombatant = rMotionController.gameObject.GetComponent <Combatant>();
                    if (lCombatant == null)
                    {
                        lCombatant = rMotionController.gameObject.AddComponent <Combatant>();
                    }

                    if (rMotionController._ActorController == null || !rMotionController._ActorController.UseTransformPosition)
                    {
                        lCombatant.IsLockingEnabled = true;
                        lCombatant.TargetLockedIcon = AssetDatabase.LoadAssetAtPath <Texture>("Assets/ootii/Framework_v1/Content/Textures/UI/TargetIcon_2.png");
                    }

                    ActorCore lCore = rMotionController.gameObject.GetComponent <ActorCore>();
                    if (lCore == null)
                    {
                        lCore = rMotionController.gameObject.AddComponent <ActorCore>();
                    }

                    lCore.IsAlive = true;
                }

                if (sCreateInputAliases)
                {
                    // Sheathe
                    if (!InputManagerHelper.IsDefined("Spell Casting Equip"))
                    {
                        InputManagerEntry lEntry = new InputManagerEntry();
                        lEntry.Name           = "Spell Casting Equip";
                        lEntry.PositiveButton = "3"; // "3" key
                        lEntry.Gravity        = 1000;
                        lEntry.Dead           = 0.001f;
                        lEntry.Sensitivity    = 1000;
                        lEntry.Type           = InputManagerEntryType.KEY_MOUSE_BUTTON;
                        lEntry.Axis           = 0;
                        lEntry.JoyNum         = 0;
                        InputManagerHelper.AddEntry(lEntry, true);

                        lEntry             = new InputManagerEntry();
                        lEntry.Name        = "Spell Casting Equip";
                        lEntry.Gravity     = 1000;
                        lEntry.Dead        = 0.001f;
                        lEntry.Sensitivity = 1000;
                        lEntry.JoyNum      = 0;

#if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
                        lEntry.PositiveButton = "joystick button 8";
                        lEntry.Type           = InputManagerEntryType.KEY_MOUSE_BUTTON; // D-pad Y
                        lEntry.Axis           = 0;
#else
                        lEntry.PositiveButton = "";
                        lEntry.Type           = InputManagerEntryType.JOYSTICK_AXIS; // D-pad Y
                        lEntry.Axis           = 7;
#endif

                        InputManagerHelper.AddEntry(lEntry, true);
                    }

                    // Fire
                    if (!InputManagerHelper.IsDefined("Spell Casting Cast"))
                    {
                        InputManagerEntry lEntry = new InputManagerEntry();
                        lEntry.Name              = "Spell Casting Cast";
                        lEntry.PositiveButton    = "left ctrl";
                        lEntry.AltPositiveButton = "mouse 0"; // Left mouse button
                        lEntry.Gravity           = 1000;
                        lEntry.Dead              = 0.001f;
                        lEntry.Sensitivity       = 1000;
                        lEntry.Type              = InputManagerEntryType.KEY_MOUSE_BUTTON;
                        lEntry.Axis              = 0;
                        lEntry.JoyNum            = 0;
                        InputManagerHelper.AddEntry(lEntry, true);

                        lEntry      = new InputManagerEntry();
                        lEntry.Name = "Spell Casting Cast";

#if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
                        lEntry.PositiveButton = "joystick button 16"; // Green A
#else
                        lEntry.PositiveButton = "joystick button 0";  // Green A
#endif

                        lEntry.Gravity     = 1000;
                        lEntry.Dead        = 0.001f;
                        lEntry.Sensitivity = 1000;
                        lEntry.Type        = InputManagerEntryType.KEY_MOUSE_BUTTON;
                        lEntry.Axis        = 0;
                        lEntry.JoyNum      = 0;
                        InputManagerHelper.AddEntry(lEntry, true);
                    }

                    // Continue
                    if (!InputManagerHelper.IsDefined("Spell Casting Continue"))
                    {
                        InputManagerEntry lEntry = new InputManagerEntry();
                        lEntry.Name              = "Spell Casting Continue";
                        lEntry.PositiveButton    = "left ctrl";
                        lEntry.AltPositiveButton = "mouse 0"; // Left mouse button
                        lEntry.Gravity           = 1000;
                        lEntry.Dead              = 0.001f;
                        lEntry.Sensitivity       = 1000;
                        lEntry.Type              = InputManagerEntryType.KEY_MOUSE_BUTTON;
                        lEntry.Axis              = 0;
                        lEntry.JoyNum            = 0;
                        InputManagerHelper.AddEntry(lEntry, true);

                        lEntry      = new InputManagerEntry();
                        lEntry.Name = "Spell Casting Continue";

#if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
                        lEntry.PositiveButton = "joystick button 16"; // Green A
#else
                        lEntry.PositiveButton = "joystick button 0";  // Green A
#endif

                        lEntry.Gravity     = 1000;
                        lEntry.Dead        = 0.001f;
                        lEntry.Sensitivity = 1000;
                        lEntry.Type        = InputManagerEntryType.KEY_MOUSE_BUTTON;
                        lEntry.Axis        = 0;
                        lEntry.JoyNum      = 0;
                        InputManagerHelper.AddEntry(lEntry, true);
                    }

                    // Cancel
                    if (!InputManagerHelper.IsDefined("Spell Casting Cancel"))
                    {
                        InputManagerEntry lEntry = new InputManagerEntry();
                        lEntry.Name           = "Spell Casting Cancel";
                        lEntry.PositiveButton = "escape";
                        lEntry.Gravity        = 1000;
                        lEntry.Dead           = 0.001f;
                        lEntry.Sensitivity    = 1000;
                        lEntry.Type           = InputManagerEntryType.KEY_MOUSE_BUTTON;
                        lEntry.Axis           = 0;
                        lEntry.JoyNum         = 0;
                        InputManagerHelper.AddEntry(lEntry, true);

                        lEntry      = new InputManagerEntry();
                        lEntry.Name = "Spell Casting Cancel";

#if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
                        lEntry.PositiveButton = "joystick button 19"; // Yellow Y
#else
                        lEntry.PositiveButton = "joystick button 3";  // Yellow Y
#endif

                        lEntry.Gravity     = 1000;
                        lEntry.Dead        = 0.001f;
                        lEntry.Sensitivity = 1000;
                        lEntry.Type        = InputManagerEntryType.KEY_MOUSE_BUTTON;
                        lEntry.Axis        = 0;
                        lEntry.JoyNum      = 0;
                        InputManagerHelper.AddEntry(lEntry, true);
                    }

                    // Move Up
                    if (!InputManagerHelper.IsDefined("Move Up"))
                    {
                        InputManagerEntry lEntry = new InputManagerEntry();
                        lEntry.Name           = "Move Up";
                        lEntry.PositiveButton = "e";
                        lEntry.Gravity        = 1000;
                        lEntry.Dead           = 0.001f;
                        lEntry.Sensitivity    = 1000;
                        lEntry.Type           = InputManagerEntryType.KEY_MOUSE_BUTTON;
                        lEntry.Axis           = 0;
                        lEntry.JoyNum         = 0;

                        InputManagerHelper.AddEntry(lEntry, true);
                    }

                    // Move down
                    if (!InputManagerHelper.IsDefined("Move Down"))
                    {
                        InputManagerEntry lEntry = new InputManagerEntry();
                        lEntry.Name           = "Move Down";
                        lEntry.PositiveButton = "q";
                        lEntry.Gravity        = 1000;
                        lEntry.Dead           = 0.001f;
                        lEntry.Sensitivity    = 1000;
                        lEntry.Type           = InputManagerEntryType.KEY_MOUSE_BUTTON;
                        lEntry.Axis           = 0;
                        lEntry.JoyNum         = 0;

                        InputManagerHelper.AddEntry(lEntry, true);
                    }
                }

                if (sCreateMotions || sCreateSubStateMachines)
                {
                    IBaseCameraRig lCameraRig = rMotionController.CameraRig;
                    if (lCameraRig == null)
                    {
                        lCameraRig = rMotionController.ExtractCameraRig(rMotionController.CameraTransform);
                    }

                    if (rMotionController.MotionLayers.Count == 0)
                    {
                        MotionControllerLayer lMotionLayer = new MotionControllerLayer();
                        rMotionController.MotionLayers.Add(lMotionLayer);
                    }

                    PMP_Idle lIdle = rMotionController.GetMotion <PMP_Idle>();
                    if (lIdle == null)
                    {
                        lIdle = rMotionController.CreateMotion <PMP_Idle>(0);
                    }

                    PMP_EquipSpell lEquip = rMotionController.GetMotion <PMP_EquipSpell>(0);
                    if (lEquip == null)
                    {
                        lEquip = rMotionController.CreateMotion <PMP_EquipSpell>(0);
                    }

                    PMP_StoreSpell lStore = rMotionController.GetMotion <PMP_StoreSpell>(0);
                    if (lStore == null)
                    {
                        lStore = rMotionController.CreateMotion <PMP_StoreSpell>(0);
                    }

                    PMP_WalkRunPivot lPivot = rMotionController.GetMotion <PMP_WalkRunPivot>(0);
                    if (lPivot == null)
                    {
                        lPivot = rMotionController.CreateMotion <PMP_WalkRunPivot>(0);
                    }

                    PMP_WalkRunStrafe lStrafe = rMotionController.GetMotion <PMP_WalkRunStrafe>(0);
                    if (lStrafe == null)
                    {
                        lStrafe = rMotionController.CreateMotion <PMP_WalkRunStrafe>(0);
                    }

                    PMP_BasicSpellCastings lCast = rMotionController.GetMotion <PMP_BasicSpellCastings>(0);
                    if (lCast == null)
                    {
                        lCast = rMotionController.CreateMotion <PMP_BasicSpellCastings>(0);
                    }

                    Cower lCower = rMotionController.GetMotion <Cower>(0);
                    if (lCower == null)
                    {
                        lCower = rMotionController.CreateMotion <Cower>(0);
                    }

                    Death lDeath = rMotionController.GetMotion <Death>(0);
                    if (lDeath == null)
                    {
                        lDeath = rMotionController.CreateMotion <Death>(0);
                    }

                    Damaged lDamaged = rMotionController.GetMotion <Damaged>(0);
                    if (lDamaged == null)
                    {
                        lDamaged = rMotionController.CreateMotion <Damaged>(0);
                    }

                    Frozen lFrozen = rMotionController.GetMotion <Frozen>(0);
                    if (lFrozen == null)
                    {
                        lFrozen = rMotionController.CreateMotion <Frozen>(0);
                    }

                    KnockedDown lKnockedDown = rMotionController.GetMotion <KnockedDown>(0);
                    if (lKnockedDown == null)
                    {
                        lKnockedDown = rMotionController.CreateMotion <KnockedDown>(0);
                    }

                    Levitate lLevitate = rMotionController.GetMotion <Levitate>(0);
                    if (lLevitate == null)
                    {
                        lLevitate = rMotionController.CreateMotion <Levitate>(0);
                    }

                    PushedBack lPushedBack = rMotionController.GetMotion <PushedBack>(0);
                    if (lPushedBack == null)
                    {
                        lPushedBack = rMotionController.CreateMotion <PushedBack>(0);
                    }

                    Sleep lSleep = rMotionController.GetMotion <Sleep>(0);
                    if (lSleep == null)
                    {
                        lSleep = rMotionController.CreateMotion <Sleep>(0);
                    }

                    Stunned lStunned = rMotionController.GetMotion <Stunned>(0);
                    if (lStunned == null)
                    {
                        lStunned = rMotionController.CreateMotion <Stunned>(0);
                    }

                    if (sCreateSubStateMachines)
                    {
                        Animator lAnimator = rMotionController.Animator;
                        if (lAnimator == null)
                        {
                            lAnimator = rMotionController.gameObject.GetComponent <Animator>();
                        }

                        if (lAnimator != null)
                        {
                            UnityEditor.Animations.AnimatorController lAnimatorController = lAnimator.runtimeAnimatorController as UnityEditor.Animations.AnimatorController;

                            lIdle.CreateStateMachine(lAnimatorController);
                            lEquip.CreateStateMachine(lAnimatorController);
                            lPivot.CreateStateMachine(lAnimatorController);
                            lStrafe.CreateStateMachine(lAnimatorController);
                            lCast.CreateStateMachine(lAnimatorController);
                            lDeath.CreateStateMachine(lAnimatorController);
                            lLevitate.CreateStateMachine(lAnimatorController);
                        }
                    }
                }

                EditorUtility.DisplayDialog("Motion Pack: " + GroupName(), "Motion pack imported.", "ok");

                return(true);
            }

            return(false);
        }
Exemple #12
0
 public void Start()
 {
     aggroBox.enabled = false;
     setFloorHeight();
     OnStunned += StunHandler;
 }
Exemple #13
0
    void initialise()
    {
        initialised = true;
        // make sure there is a parent
        if (transform.parent == null)
        {
            return;
        }
        if (parent == null)
        {
            parent = transform.parent.gameObject;
        }
        if (parent == null)
        {
            Debug.LogError("BuffParent component has no parent"); return;
        }
        // find the parent's protection class
        parentProtection = parent.gameObject.GetComponent <ProtectionClass>();

        if (parentProtection)
        {
            if (ward != 0)
            {
                parentProtection.GainWard(ward);
            }
            if (wardPercentage != 0 && parent.GetComponent <BaseHealth>())
            {
                parentProtection.GainWard((wardPercentage * parent.GetComponent <BaseHealth>().maxHealth));
            }
        }

        if (increasedSize != 0)
        {
            SizeManager sizeManager = parent.GetComponent <SizeManager>();
            if (sizeManager)
            {
                sizeManager.increaseSize(increasedSize);
            }
        }

        // find the parent's base health
        if (lifeRegen != 0)
        {
            parentHealth = parent.GetComponent <BaseHealth>();
            parentHealth.addedHealthRegenPerSecond += lifeRegen;
        }
        // find the parent's base mana
        if (manaCostDivider != 0)
        {
            parentMana = parent.GetComponent <BaseMana>();
            parentMana.addedManaCostDivider += manaCostDivider;
        }
        // find the parent's demo ward regen
        if (wardRegen != 0)
        {
            parentProtection.wardRegen += wardRegen;
        }
        // find the parent's base stats
        if (speed != 0)
        {
            parentBaseStats = parent.GetComponent <BaseStats>();
            if (parentBaseStats != null)
            {
                parentBaseStats.ChangeStatModifier(Tags.Properties.Movespeed, speed, BaseStats.ModType.ADDED);
            }
        }
        // find the parent's speed manager
        if (percentageSpeed != 0)
        {
            if (!parentBaseStats)
            {
                parentBaseStats = parent.GetComponent <BaseStats>();
            }
            parentSpeedManager = parent.GetComponent <SpeedManager>();
            if (parentSpeedManager != null && parentBaseStats != null)
            {
                parentBaseStats.ChangeStatModifier(Tags.Properties.Movespeed, percentageSpeed, BaseStats.ModType.INCREASED);
            }
        }
        if (reducedStunDuration != 0)
        {
            parentStunnedState = parent.gameObject.GetComponent <Stunned>();
            if (parentStunnedState != null)
            {
                parentStunnedState.baseStunDuration -= reducedStunDuration;
            }
        }
        // apply taggedStats
        parentBaseStats = parent.GetComponent <BaseStats>();
        if (parentBaseStats)
        {
            foreach (TaggedStatsHolder.TaggableStat stat in taggedStats)
            {
                parentBaseStats.ChangeStatModifier(stat.property, stat.addedValue, BaseStats.ModType.ADDED, stat.tagList);
                parentBaseStats.ChangeStatModifier(stat.property, stat.increasedValue, BaseStats.ModType.INCREASED, stat.tagList);
                foreach (float value in stat.moreValues)
                {
                    parentBaseStats.ChangeStatModifier(stat.property, value, BaseStats.ModType.MORE, stat.tagList);
                }
                foreach (float value in stat.quotientValues)
                {
                    parentBaseStats.ChangeStatModifier(stat.property, value, BaseStats.ModType.QUOTIENT, stat.tagList);
                }
            }
            parentBaseStats.UpdateStats();
        }

        // update protection totals
        if (parentProtection)
        {
            parentProtection.UpdateProtectionTotals();
        }
        // subscribe to a death event to remove the buffs
        if (GetComponent <SelfDestroyer>())
        {
            GetComponent <SelfDestroyer>().deathEvent += removeBuffs;
        }
    }
    public void Restart()
    {
        // Creating and setting some basic values for the blackboard
        m_Blackboard = new Blackboard();
        m_Blackboard.Trans = transform;
        m_Blackboard.StartPoint = transform.position;
        GameObject player = GameObject.FindGameObjectWithTag("Player");
        if (player) {
            m_Blackboard.Player = player.transform;
        }
        m_Blackboard.Destination = transform.position + new Vector3(10, 0, 5);
        m_Blackboard.LookAtObject = GetComponent<Looker>();

        //-------------------------------------------------------------------------
        // Higher level sequence/selectors which we'll add leaf behaviors to later
        //-------------------------------------------------------------------------
        Sequence randomMove = new Sequence();
        Sequence moveToBeacon = new Sequence();

        //----------------------------------------------------------------------------------
        // Create leaf behaviors. Should only need one of each.
        // Some of these get used often (MoveToPoint), others are specific (CheckForBeacon)
        //----------------------------------------------------------------------------------
        MoveToPoint moveToPoint = new MoveToPoint();
        PickRandomTarget pickRandomTarget = new PickRandomTarget();
        CheckForBeacon checkForBeacon = new CheckForBeacon();
        ChasePlayer chasePlayer = new ChasePlayer();
        Stunned stunned = new Stunned();

        //---------------------------------------------------------------------------------------
        // Building the subtrees.
        // Add children to subtrees in left to right order, since each AddChild is doing a push_back
        //----------------------------------------------------------------------------------------
        moveToBeacon.AddChild(checkForBeacon);
        moveToBeacon.AddChild(moveToPoint);

        randomMove.AddChild(pickRandomTarget);
        randomMove.AddChild(moveToPoint);

        //--------------------------------------------------
        // Add subtrees to the root.
        // Like before, add behaviors in left to right order
        //--------------------------------------------------
        m_Root.AddChild(stunned);
        m_Root.AddChild(moveToBeacon);
        m_Root.AddChild(chasePlayer);
        m_Root.AddChild(randomMove);

        //m_Blackboard.MovementPath = NavGraphConstructor.Instance.FindPathToLocation(m_Blackboard.Trans.position, m_Blackboard.Destination);
        //m_Blackboard.PathCurrentIdx = 0;

        //		repeat.m_Child = randomMove;
        //
        //		// Try out Chase behavior
        //		m_Chase = new Chase(moveBehavior, m_Bt);
        //		m_Flee = new Flee(moveBehavior, m_Bt);
        //
        //		List<Behavior> tree = new List<Behavior>();
        //		tree.Add(repeat);
        //		tree.Add(m_Chase);
        //
        //		root.m_Children = tree;
        //
        //		m_Bt.Start(root, this.SequenceComplete);
    }