Beispiel #1
0
    public ICannonAmmo LoadAmmo(Transform newLocation)
    {
        if (_playerController.GrabbedObject != null)
        {
            ICannonAmmo objectCA = _playerController.GrabbedObject.GetComponent <ICannonAmmo>();
            //DROP
            _playerController.GrabbedObject.Release(Vector3.zero, true, false);
            _playerController.GrabbedObject = null;
            return(objectCA.LoadAmmo(newLocation));
        }

        if (_playerController.IsPlayerBig == true)
        {
            return(null);
        }

        _cannonDummy.LoadDummy(newLocation.position, newLocation.rotation);
        _playerController.DisablePlayer();
        _playerController.SetDummyCameraTarget(_cannonDummy.transform);
        return(this);
    }
Beispiel #2
0
        public void TryLoad(Mobile m)
        {
            if (Loaded)
            {
                TryPrime(m);
            }
            else
            {
                AddAction(m, 1149647); // loading started
                AmmoType = AmmunitionType.Empty;

                Timer.DelayCall(ActionTime, () =>
                {
                    ICannonAmmo ammo = null;

                    var cannon    = FindItemByType <Cannonball>();
                    var grapeshot = FindItemByType <Grapeshot>();

                    if (cannon != null)
                    {
                        ammo = cannon;
                    }
                    else if (grapeshot != null)
                    {
                        ammo = grapeshot;
                    }
                    else
                    {
                        cannon    = m.Backpack.FindItemByType <Cannonball>();
                        grapeshot = m.Backpack.FindItemByType <Grapeshot>();

                        if (cannon != null)
                        {
                            ammo = cannon;
                        }
                        else if (grapeshot != null)
                        {
                            ammo = grapeshot;
                        }
                    }

                    if (ammo != null && ammo is Item)
                    {
                        if (m.InRange(Location, 2))
                        {
                            Loaded   = true;
                            AmmoType = ammo.AmmoType;
                            ((Item)ammo).Consume();
                            InvalidateProperties();
                            AddAction(m, 1149649); // Loading Finished

                            TryPrime(m);
                            ResendGump(m);
                        }
                        else
                        {
                            DoAreaMessage(1116057, 10, m); //~1_NAME~ cancels the effort of loading the cannon and retrieves the cannonball.
                            AddAction(m, 1149648);         // Loading canceled.
                            ResendGump(m);
                        }
                    }
                    else
                    {
                        m.SendLocalizedMessage(1158933); // The magazine does not have ammo to load this cannon with.
                        AddAction(m, 1158933);           // Need ammo.
                        ResendGump(m);
                    }
                });
            }
        }