示例#1
0
        protected override void OnPreDrop(PlayerController user)
        {
            //ensures no sheila entities exist when owner does not have sheila item
            if (m_Gun != null)
            {
                if (m_Gun != null && m_Gun_position != null)
                {
                    TurretController turrrret = m_Gun.GetComponent <TurretController>();
                    if (turrrret.isOnTurret && startup)
                    {
                        // dismount controller
                        user.IsStationary       = false;
                        user.MovementModifiers -= this.NoMotionModifier;
                        user.OnPreDodgeRoll    -= this.HandleDodgeRollStarted;
                        turrrret.isOnTurret     = false;
                        dismount = false;
                        if (onturretgun != null)
                        {
                            user.inventory.GunLocked.RemoveOverride("on turret");
                            user.inventory.DestroyGun(onturretgun);
                            AkSoundEngine.PostEvent("Stop_WPN_All", base.gameObject);
                            AkSoundEngine.PostEvent("Play_tur_dismount", base.gameObject);
                            AkSoundEngine.PostEvent("Play_tur_dismount", base.gameObject);
                            AkSoundEngine.PostEvent("Play_tur_dismount", base.gameObject);
                            AkSoundEngine.PostEvent("Play_tur_dismount", base.gameObject);
                        }
                    }
                }

                UnityEngine.GameObject.DestroyObject(m_Gun);
                m_Gun = null;
            }
            base.OnPreDrop(user);
        }
示例#2
0
        //update is used as the mount state controller so the code can interact with player item code and interact code at the same time
        //the isOnTurret bool is the interact press state.
        public override void Update()
        {
            if (this.LastOwner != null)
            {
                if (m_Gun != null && m_Gun_position != null)
                {
                    TurretController turrrret = m_Gun.GetComponent <TurretController>();

                    //initializes on turret state
                    if (turrrret.isOnTurret && startup == false)
                    {
                        user.MovementModifiers += this.NoMotionModifier;
                        user.IsStationary       = true;
                        user.OnPreDodgeRoll    += this.HandleDodgeRollStarted;
                        Gun sheila = user.inventory.AddGunToInventory(PickupObjectDatabase.GetByEncounterName("Sheila LMG") as Gun, true);
                        sheila.CanBeDropped = false;
                        sheila.CanBeSold    = false;
                        onturretgun         = sheila;
                        user.inventory.GunLocked.SetOverride("on turret", true, null);
                        startup = true;
                    }

                    //three sections to control ways to get off turret.

                    //knock off mechanic for explosives and rubberkin
                    if (turrrret.isOnTurret && startup == true)
                    {
                        // calculates knock off by distance from turretbase to player
                        if (Vector2.Distance(user.CenterPosition, m_Gun_position) > 1)
                        {
                            dismount = true;
                        }
                    }

                    // special dodgeroll case for mounted state
                    BraveInput instanceForPlayer = BraveInput.GetInstanceForPlayer(user.PlayerIDX);
                    if (instanceForPlayer.ActiveActions.DodgeRollAction.IsPressed && turrrret.isOnTurret && startup)
                    {
                        user.IsStationary = false;

                        user.MovementModifiers -= this.NoMotionModifier;
                        dismount = true;
                    }

                    //secondary interact controller that allows for player to use E to exit turret
                    if (turrrret.isOnTurret == false && startup == true)
                    {
                        dismount = true;
                        startup  = false;
                    }

                    // essentally a method to control dismount procedures
                    if (dismount)
                    {
                        // dismount controller
                        user.IsStationary       = false;
                        user.MovementModifiers -= this.NoMotionModifier;
                        user.OnPreDodgeRoll    -= this.HandleDodgeRollStarted;
                        turrrret.isOnTurret     = false;
                        dismount = false;
                        if (onturretgun != null)
                        {
                            user.inventory.GunLocked.RemoveOverride("on turret");
                            user.inventory.DestroyGun(onturretgun);
                            AkSoundEngine.PostEvent("Stop_WPN_All", base.gameObject);
                            AkSoundEngine.PostEvent("Play_tur_dismount", base.gameObject);
                            AkSoundEngine.PostEvent("Play_tur_dismount", base.gameObject);
                            AkSoundEngine.PostEvent("Play_tur_dismount", base.gameObject);
                            AkSoundEngine.PostEvent("Play_tur_dismount", base.gameObject);
                        }
                    }
                }
            }
            else
            {
            }

            base.Update();
        }