Exemple #1
0
 protected override void Initialization()
 {
     base.Initialization();
     _characterHorizontalMovement = GetComponent <CharacterHorizontalMovement> ();
     _characterHandleWeapon       = GetComponent <CharacterHandleWeapon> ();
     _character = GetComponent <Character> ();
 }
Exemple #2
0
        /// <summary>
        /// Sets the weapon's owner
        /// </summary>
        /// <param name="newOwner">New owner.</param>
        public virtual void SetOwner(Character newOwner, CharacterHandleWeapon handleWeapon)
        {
            Owner = newOwner;
            if (Owner != null)
            {
                CharacterHandleWeapon        = handleWeapon;
                _characterGravity            = Owner.GetComponent <CharacterGravity>();
                _characterHorizontalMovement = Owner.GetComponent <CharacterHorizontalMovement>();
                _controller = Owner.GetComponent <CorgiController>();

                if (CharacterHandleWeapon.AutomaticallyBindAnimator)
                {
                    if (CharacterHandleWeapon.CharacterAnimator != null)
                    {
                        _ownerAnimator = CharacterHandleWeapon.CharacterAnimator;
                    }
                    if (_ownerAnimator == null)
                    {
                        _ownerAnimator = CharacterHandleWeapon.gameObject.MMGetComponentNoAlloc <Character>().CharacterAnimator;
                    }
                    if (_ownerAnimator == null)
                    {
                        _ownerAnimator = CharacterHandleWeapon.gameObject.MMGetComponentNoAlloc <Animator>();
                    }
                }
            }
        }
        /// <summary>
        /// Grabs the CharacterHandleWeapon component and sets the weapon
        /// </summary>
        /// <param name="newWeapon">New weapon.</param>
        protected virtual void EquipWeapon(Weapon newWeapon)
        {
            if (EquippableWeapon == null)
            {
                return;
            }
            if (TargetInventory.Owner == null)
            {
                return;
            }

            Character character = TargetInventory.Owner.GetComponent <Character>();

            if (character == null)
            {
                return;
            }

            // we equip the weapon to the chosen CharacterHandleWeapon
            CharacterHandleWeapon targetHandleWeapon = null;

            CharacterHandleWeapon[] handleWeapons = character.GetComponentsInChildren <CharacterHandleWeapon>();
            foreach (CharacterHandleWeapon handleWeapon in handleWeapons)
            {
                if (handleWeapon.HandleWeaponID == HandleWeaponID)
                {
                    targetHandleWeapon = handleWeapon;
                }
            }

            if (targetHandleWeapon != null)
            {
                targetHandleWeapon.ChangeWeapon(newWeapon, this.ItemID);
            }
        }
Exemple #4
0
 // Start is called before the first frame update
 void Start()
 {
     _characterShoot = GetComponentInParent <CharacterHandleWeapon>();
     _detectorActive = true;
     pos1            = new Vector3(_Flopper.position.x + HoverDistance, _Flopper.position.y, _Flopper.position.z);
     pos2            = new Vector3(_Flopper.position.x - HoverDistance, _Flopper.position.y, _Flopper.position.z);
 }
        /// <summary>
        /// When one of the weapons has ended its attack, we start our countdown and switch to the next weapon
        /// </summary>
        /// <param name="weaponThatStopped"></param>
        public virtual void WeaponStopped(Weapon weaponThatStopped)
        {
            OwnerCharacterHandleWeapon = Weapons[_currentWeaponIndex].CharacterHandleWeapon;

            int newIndex = 0;

            if (OwnerCharacterHandleWeapon != null)
            {
                if (Weapons.Length > 1)
                {
                    if (_currentWeaponIndex < Weapons.Length - 1)
                    {
                        newIndex = _currentWeaponIndex + 1;
                    }
                    else
                    {
                        newIndex = 0;
                    }

                    _countdownActive           = true;
                    TimeSinceLastWeaponStopped = 0f;

                    _currentWeaponIndex = newIndex;
                    OwnerCharacterHandleWeapon.CurrentWeapon = Weapons[newIndex];
                    OwnerCharacterHandleWeapon.ChangeWeapon(Weapons[newIndex], Weapons[newIndex].WeaponID, true);
                }
            }
        }
        /// <summary>
        /// What happens when the weapon gets picked
        /// </summary>
        protected override void Pick()
        {
            Character character = _collidingObject.gameObject.MMGetComponentNoAlloc <Character>();

            if (character == null)
            {
                return;
            }

            // we equip the weapon to the chosen CharacterHandleWeapon
            CharacterHandleWeapon targetHandleWeapon = null;

            CharacterHandleWeapon[] handleWeapons = character.GetComponentsInChildren <CharacterHandleWeapon>();
            foreach (CharacterHandleWeapon handleWeapon in handleWeapons)
            {
                if (handleWeapon.HandleWeaponID == HandleWeaponID)
                {
                    targetHandleWeapon = handleWeapon;
                }
            }

            if (targetHandleWeapon != null)
            {
                targetHandleWeapon.ChangeWeapon(WeaponToGive, null);
            }
        }
Exemple #7
0
 /// <summary>
 /// On Start(), we initialize our various flags
 /// </summary>
 protected override void Initialization()
 {
     base.Initialization();
     CurrentLadderClimbingSpeed = Vector2.zero;
     _boxCollider           = this.gameObject.GetComponentInParent <BoxCollider2D>();
     _colliders             = new List <Collider2D>();
     _characterHandleWeapon = this.gameObject.GetComponentInParent <Character>()?.FindAbility <CharacterHandleWeapon>();
 }
Exemple #8
0
 /// <summary>
 /// Setup grabs inventories, component, and fills the weapon lists
 /// </summary>
 protected virtual void Setup()
 {
     GrabInventories();
     if (CharacterHandleWeapon == null)
     {
         CharacterHandleWeapon = _character?.FindAbility <CharacterHandleWeapon>();
     }
     FillAvailableWeaponsLists();
 }
 // Start is called before the first frame update
 void Start()
 {
     _collider               = GetComponentInParent <BoxCollider2D>();
     _anim                   = GetComponentInParent <Animator>();
     _characterShoot         = GetComponentInParent <CharacterHandleWeapon>();
     _robeCharacter          = GetComponentInParent <Character>();
     _baddieHealth           = GetComponentInParent <BaddieHealth>();
     _characterShoot.enabled = false;
     currentPoint            = pos2.position;
 }
Exemple #10
0
        /// <summary>
        /// Watches for InventoryLoaded events
        /// When an inventory gets loaded, if it's our WeaponInventory, we check if there's already a weapon equipped, and if yes, we equip it
        /// </summary>
        /// <param name="inventoryEvent">Inventory event.</param>
        public virtual void OnMMEvent(MMInventoryEvent inventoryEvent)
        {
            if (inventoryEvent.InventoryEventType == MMInventoryEventType.InventoryLoaded)
            {
                if (!AbilityInitialized)
                {
                    Initialization();
                }

                if (inventoryEvent.TargetInventoryName == WeaponInventoryName)
                {
                    this.Setup();
                    if (WeaponInventory != null)
                    {
                        if (!InventoryItem.IsNull(WeaponInventory.Content [0]))
                        {
                            if (CharacterHandleWeapon == null)
                            {
                                CharacterHandleWeapon = _character.FindAbility <CharacterHandleWeapon>();
                            }
                            CharacterHandleWeapon.Setup();
                            WeaponInventory.Content [0].Equip();
                        }
                    }
                }
            }
            if (inventoryEvent.InventoryEventType == MMInventoryEventType.Pick)
            {
                bool isSubclass = (inventoryEvent.EventItem.GetType().IsSubclassOf(typeof(InventoryEngineWeapon)));
                bool isClass    = (inventoryEvent.EventItem.GetType() == typeof(InventoryEngineWeapon));
                if (isClass || isSubclass)
                {
                    InventoryEngineWeapon inventoryWeapon = (InventoryEngineWeapon)inventoryEvent.EventItem;
                    switch (inventoryWeapon.AutoEquipMode)
                    {
                    case InventoryEngineWeapon.AutoEquipModes.NoAutoEquip:
                        // we do nothing
                        break;

                    case InventoryEngineWeapon.AutoEquipModes.AutoEquip:
                        _nextFrameWeapon     = true;
                        _nextFrameWeaponName = inventoryEvent.EventItem.ItemID;
                        break;

                    case InventoryEngineWeapon.AutoEquipModes.AutoEquipIfEmptyHanded:
                        if (CharacterHandleWeapon.CurrentWeapon == null)
                        {
                            _nextFrameWeapon     = true;
                            _nextFrameWeaponName = inventoryEvent.EventItem.ItemID;
                        }
                        break;
                    }
                }
            }
        }
Exemple #11
0
        /// <summary>
        /// What happens when the weapon gets picked
        /// </summary>
        protected override void Pick()
        {
            CharacterHandleWeapon characterShoot = _collider.GetComponent <CharacterHandleWeapon>();

            characterShoot.ChangeWeapon(WeaponToGive, null);
            if (characterShoot != null)
            {
                if (characterShoot.CanPickupWeapons)
                {
                }
            }
        }
 /// <summary>
 /// Sets the weapon's owner
 /// </summary>
 /// <param name="newOwner">New owner.</param>
 public override void SetOwner(Character newOwner, CharacterHandleWeapon handleWeapon)
 {
     Owner = newOwner;
     if (Owner != null)
     {
         CharacterHandleWeapon        = handleWeapon;
         _characterGravity            = Owner.GetComponent <CharacterGravity>();
         _characterHorizontalMovement = Owner.GetComponent <CharacterHorizontalMovement>();
         _controller      = Owner.GetComponent <CorgiController>();
         LucyHandleWeapon = Owner.GetComponent <LucyHandleWeapon>();
     }
 }
        /// <summary>
        /// On init we disable our models and activate the current one
        /// </summary>
        protected override void Initialization()
        {
            base.Initialization();
            if (CharacterModels.Length == 0)
            {
                return;
            }

            foreach (GameObject model in CharacterModels)
            {
                model.SetActive(false);
            }

            CharacterModels[CurrentIndex].SetActive(true);
            _characterModelsFlipped = new bool[CharacterModels.Length];
            _characterHandleWeapon  = _character?.FindAbility <CharacterHandleWeapon>();
        }
        /// <summary>
        /// Grabs the CharacterHandleWeapon component and sets the weapon
        /// </summary>
        /// <param name="newWeapon">New weapon.</param>
        protected virtual void EquipWeapon(Weapon newWeapon)
        {
            if (EquippableWeapon == null)
            {
                return;
            }
            if (TargetInventory.Owner == null)
            {
                return;
            }
            CharacterHandleWeapon characterHandleWeapon = TargetInventory.Owner.GetComponent <CharacterHandleWeapon>();

            if (characterHandleWeapon != null)
            {
                characterHandleWeapon.ChangeWeapon(newWeapon, this.ItemID);
            }
        }
Exemple #15
0
        /// <summary>
        /// On Start(), we set our tunnel flag to false
        /// </summary>
        protected override void Initialization()
        {
            base.Initialization();

            if (ObjectToRotate != null)
            {
                _model = ObjectToRotate;
            }
            else
            {
                _model = _character.CharacterModel;
            }

            _handleWeapon = GetComponent <CharacterHandleWeapon> ();
            if (_handleWeapon != null)
            {
                if (_handleWeapon.CurrentWeapon != null)
                {
                    _weaponAim = _handleWeapon.CurrentWeapon.GetComponent <WeaponAim> ();
                }
            }
        }
Exemple #16
0
 /// <summary>
 /// When we detect a character switch, we equip the current weapon if AutoEquipWeaponOnCharacterSwitch is true
 /// </summary>
 /// <param name="corgiEngineEvent"></param>
 public virtual void OnMMEvent(CorgiEngineEvent corgiEngineEvent)
 {
     if (corgiEngineEvent.EventType == CorgiEngineEventTypes.CharacterSwitch)
     {
         if (!AutoEquipWeaponOnCharacterSwitch)
         {
             return;
         }
         this.Setup();
         if (WeaponInventory != null)
         {
             if (!InventoryItem.IsNull(WeaponInventory.Content[0]))
             {
                 if (CharacterHandleWeapon == null)
                 {
                     CharacterHandleWeapon = GetComponent <CharacterHandleWeapon>();
                 }
                 CharacterHandleWeapon.Setup();
                 WeaponInventory.Content[0].Equip();
             }
         }
     }
 }
 /// <summary>
 /// On init we grab our CharacterHandleWeapon ability
 /// </summary>
 protected override void Initialization()
 {
     _characterHandleWeapon = this.gameObject.GetComponentInParent <Character>()?.FindAbility <CharacterHandleWeapon>();
 }
Exemple #18
0
/// <summary>
/// On init we grab our CharacterHandleWeapon ability
/// </summary>
        protected override void Initialization()
        {
            _character             = GetComponent <Character>();
            _characterHandleWeapon = this.gameObject.GetComponent <CharacterHandleWeapon>();
        }
 protected virtual void Setup()
 {
     GrabInventories();
     _characterHandleWeapon = GetComponent <CharacterHandleWeapon> ();
     FillAvailableWeaponsLists();
 }
Exemple #20
0
 /// <summary>
 /// On init we grab our CharacterHandleWeapon ability
 /// </summary>
 protected override void Initialization()
 {
     _character             = GetComponentInParent <Character>();
     _characterHandleWeapon = _character?.FindAbility <CharacterHandleWeapon>();
 }
 /// <summary>
 /// on start we get our components
 /// </summary>
 protected virtual void Start()
 {
     _character      = GetComponent <Character>();
     _characterShoot = GetComponent <CharacterHandleWeapon>();
 }
Exemple #22
0
 /// <summary>
 /// on start we get our components
 /// </summary>
 protected virtual void Start()
 {
     _character      = GetComponentInParent <Character>();
     _characterShoot = _character?.FindAbility <CharacterHandleWeapon>();
 }