コード例 #1
0
 protected override void Initialization()
 {
     base.Initialization();
     _characterHorizontalMovement = GetComponent <CharacterHorizontalMovement> ();
     _characterHandleWeapon       = GetComponent <CharacterHandleWeapon> ();
     _character = GetComponent <Character> ();
 }
コード例 #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>();
                    }
                }
            }
        }
コード例 #3
0
        /// <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);
            }
        }
コード例 #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);
 }
コード例 #5
0
        /// <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);
                }
            }
        }
コード例 #6
0
        /// <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);
            }
        }
コード例 #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>();
 }
コード例 #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();
 }
コード例 #9
0
 // 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;
 }
コード例 #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;
                    }
                }
            }
        }
コード例 #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)
                {
                }
            }
        }
コード例 #12
0
 /// <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>();
     }
 }
コード例 #13
0
        /// <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>();
        }
コード例 #14
0
        /// <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);
            }
        }
コード例 #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> ();
                }
            }
        }
コード例 #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();
             }
         }
     }
 }
コード例 #17
0
 /// <summary>
 /// On init we grab our CharacterHandleWeapon ability
 /// </summary>
 protected override void Initialization()
 {
     _characterHandleWeapon = this.gameObject.GetComponentInParent <Character>()?.FindAbility <CharacterHandleWeapon>();
 }
コード例 #18
0
/// <summary>
/// On init we grab our CharacterHandleWeapon ability
/// </summary>
        protected override void Initialization()
        {
            _character             = GetComponent <Character>();
            _characterHandleWeapon = this.gameObject.GetComponent <CharacterHandleWeapon>();
        }
コード例 #19
0
 protected virtual void Setup()
 {
     GrabInventories();
     _characterHandleWeapon = GetComponent <CharacterHandleWeapon> ();
     FillAvailableWeaponsLists();
 }
コード例 #20
0
 /// <summary>
 /// On init we grab our CharacterHandleWeapon ability
 /// </summary>
 protected override void Initialization()
 {
     _character             = GetComponentInParent <Character>();
     _characterHandleWeapon = _character?.FindAbility <CharacterHandleWeapon>();
 }
コード例 #21
0
 /// <summary>
 /// on start we get our components
 /// </summary>
 protected virtual void Start()
 {
     _character      = GetComponent <Character>();
     _characterShoot = GetComponent <CharacterHandleWeapon>();
 }
コード例 #22
0
 /// <summary>
 /// on start we get our components
 /// </summary>
 protected virtual void Start()
 {
     _character      = GetComponentInParent <Character>();
     _characterShoot = _character?.FindAbility <CharacterHandleWeapon>();
 }