示例#1
0
    public void ChangePart(PartBase part)
    {
        if (IsEquipped(part))
        {
            return;
        }

        Unequip(part);

        switch (part)
        {
        case TriggerData trigger:
        {
            TriggerData = trigger;

            CurrentAmmo = TriggerData.AmmoCapacity;
            break;
        }

        case EventData eventData:
            EventData = eventData;
            break;

        case SeekerData seekerData:
            SeekerData = seekerData;
            break;

        default:
            throw new NotImplementedException();
        }

        part.OnEquipped();
    }
        public void BuildProviderId_RoleFrPlusDot_EqualsTypeIdAndRoleId()
        {
            string id = PartBase.BuildProviderId("net.fusisoft.token-text-layer",
                                                 "fr.net.fusisoft.comment:scholarly");

            Assert.Equal("net.fusisoft.token-text-layer:fr.net.fusisoft.comment", id);
        }
示例#3
0
    private bool IsEquipped(PartBase part)
    {
        bool isEquipped = false;

        PerformActionOnParts(x => { isEquipped = x == part; }, part);

        return(isEquipped);
    }
示例#4
0
 protected PartSeparator_Part()
 {
     _isLooseProps = false;
     _part         = null;
     _convexPoints = null;
     _size         = new Vector3D(0, 0, 0);
     _mass         = 0;
 }
示例#5
0
        public PartSeparator_Part(PartBase part)
        {
            _part = part;

            _isLooseProps = false;
            _convexPoints = null;
            _size         = new Vector3D(0, 0, 0);
            _mass         = 0;
        }
 public void RemoveContent()
 {
     workerContent      = null;
     partContent        = null;
     hasContent         = false;
     contentIcon.sprite = null;
     emptyContentIcon.SetActive(true);
     contentMain.SetActive(false);
 }
示例#7
0
 public void AddPart(PartUpgrade _part)
 {
     installedPart = _part;
     if (_part != null)
     {
         titleText.text = _part.PartName;
         icon.sprite    = _part.Icon;
         icon.color     = new Color(1, 1, 1, 1);
     }
 }
示例#8
0
 private void Unequip(PartBase part)
 {
     PerformActionOnParts(x =>
     {
         if (x != null)
         {
             x.OnUneqipped();
         }
     }, part);
 }
示例#9
0
    public void OnUnsnap(GameObject go)
    {
        PartBase pb = go.GetComponent <PartBase>();

        if (pb == null)
        {
            return;
        }
        children.Remove(pb);
        PartCore.Instance.Rebuild();
    }
示例#10
0
        /// <summary>
        /// This overload is for bots that don't derive from ship, but do contain parts.  This will show the parts, and won't show
        /// any ship specific visuals
        /// </summary>
        public ShipViewerWindow(PartBase[] parts, NeuralUtility.ContainerOutput[] neuronLinks, Window owner)
        {
            InitializeComponent();

            _bot         = null;
            _parts       = parts;
            _neuronLinks = neuronLinks;

            var aabb = PartBase.GetAABB(_parts);

            Constructor_Finish(aabb, owner);
        }
示例#11
0
    public void OnSnap(GameObject go)
    {
        PartBase pb = go.GetComponent <PartBase>();

        if (pb == null)
        {
            return;
        }
        children.Add(pb);
        SetLeft(leftSide);
        PartCore.Instance.Build();
    }
示例#12
0
 void BuildColliders(PartBase pb)
 {
     if (pb.rb != null && !parts.ContainsKey(pb))
     {
         parts.Add(pb, GameObject.Instantiate(pb.primaryCollider.transform, pb.primaryCollider.transform.position, pb.primaryCollider.transform.rotation, colliderHolder));
         parts[pb].gameObject.layer = 11;
     }
     foreach (PartBase partBase in pb.children)
     {
         BuildColliders(partBase);
     }
 }
示例#13
0
        private void Part_RequestWorldLocation(object sender, PartRequestWorldLocationArgs e)
        {
            if (!(sender is PartBase))
            {
                throw new ApplicationException("Expected sender to be PartBase");
            }

            PartBase senderCast = (PartBase)sender;

            e.Orientation = this.PhysicsBody.Rotation.RotateBy(senderCast.Orientation);
            e.Position    = this.PositionWorld + this.PhysicsBody.Rotation.GetRotatedVector(senderCast.Position.ToVector());
        }
    public void ChangePart(PartBase partdata)
    {
#if UNITY_EDITOR
        if (_weaponIndex == null)
        {
            Debug.LogWarning("Not initialized, using debug weapon index");

            _weaponInventory[_debugWeaponIndex].ChangePart(partdata);
            return;
        }
#endif

        _weaponInventory[_weaponIndex.Value].ChangePart(partdata);
    }
示例#15
0
 public void AddContent(PartBase _part)
 {
     if (_part != null)
     {
         partContent        = _part;
         workerContent      = null;
         type               = ContentType.Part;
         hasContent         = true;
         contentIcon.sprite = partContent.Icon;
         emptyContentIcon.SetActive(false);
         contentMain.SetActive(true);
         contentButton.onClick.AddListener(OnPickUp);
     }
 }
示例#16
0
 public void AddContent(WorkerBase _worker)
 {
     if (_worker != null)
     {
         workerContent      = _worker;
         partContent        = null;
         type               = ContentType.Worker;
         hasContent         = true;
         contentIcon.sprite = workerContent.Portrait;
         emptyContentIcon.SetActive(false);
         contentMain.SetActive(true);
         contentButton.onClick.AddListener(OnPickUp);
     }
 }
示例#17
0
        private void Part_RequestWorldSpeed(object sender, PartRequestWorldSpeedArgs e)
        {
            if (!(sender is PartBase))
            {
                throw new ApplicationException("Expected sender to be PartBase");
            }

            PartBase senderCast = (PartBase)sender;

            e.Velocity        = this.PhysicsBody.Velocity;
            e.AngularVelocity = this.PhysicsBody.AngularVelocity;

            if (e.GetVelocityAtPoint != null)
            {
                e.VelocityAtPoint = this.PhysicsBody.GetVelocityAtPoint(this.PhysicsBody.Position + this.PhysicsBody.PositionToWorld(e.GetVelocityAtPoint.Value).ToVector());
            }
        }
示例#18
0
    public void RemoveItem(PartBase _part)
    {
        if (currentItems <= 0)
        {
            return;
        }

        foreach (InventoryBarContent item in invContent)
        {
            if (item.partContent == _part)
            {
                item.RemoveContent();
                currentItems--;
                return;
            }
        }
    }
示例#19
0
    public void AddItem(PartBase _part)
    {
        if (currentItems >= maxItems)
        {
            return;
        }

        foreach (InventoryBarContent item in invContent)
        {
            if (!item.HasContent)
            {
                item.AddContent(_part);
                item.shipEditor = shipEditor;
                currentItems++;
                return;
            }
        }
    }
示例#20
0
    public void AddPart(PartBase _part)
    {
        if (_part == null)
        {
            return;
        }

        partsInventoryBar.AddItem(_part);
        for (int i = 0; i < partsInventory.Count; i++)
        {
            if (partsInventory[i] == null)
            {
                partsInventory[i] = _part;
                return;
            }
        }
        partsInventory.Add(_part);
    }
示例#21
0
 private void PerformActionOnParts(Action <PartBase> callback, PartBase part)
 {
     if (part is TriggerData)
     {
         callback(TriggerData);
     }
     else if (part is EventData)
     {
         callback(EventData);
     }
     else if (part is SeekerData)
     {
         callback(SeekerData);
     }
     else
     {
         throw new NotImplementedException();
     }
 }
示例#22
0
        public decimal GetPrice_Repair(PartBase part)
        {
            const decimal MULT_DESTROYED = .75m;
            const decimal MULT_PARTIAL   = .4m;

            if (!part.IsDestroyed && part.HitPoints_Current.IsNearValue(part.HitPoints_Max))
            {
                return(0m);
            }

            // Make the repair cost some fraction of the cost of a new part
            decimal purchasePrice = ItemOptionsAstMin2D.GetCredits_ShipPart(part.GetNewDNA());

            if (part.IsDestroyed)
            {
                return(purchasePrice * MULT_DESTROYED);
            }
            else
            {
                double percent = (part.HitPoints_Max - part.HitPoints_Current) / part.HitPoints_Max;

                return(Convert.ToDecimal(percent) * purchasePrice * MULT_PARTIAL);
            }
        }
示例#23
0
    public void RemovePart()
    {
        installedPart = null;
        switch (partType)
        {
        case PartType.Drill:
            titleText.text = "Drill";
            icon.sprite    = null;
            icon.color     = new Color(1, 1, 1, 0);
            break;

        case PartType.Cabin:
            titleText.text = "Cabin";
            icon.sprite    = null;
            icon.color     = new Color(1, 1, 1, 0);
            break;

        case PartType.Engine:
            titleText.text = "Engine";
            icon.sprite    = null;
            icon.color     = new Color(1, 1, 1, 0);
            break;

        case PartType.Wheels:
            titleText.text = "Wheels";
            icon.sprite    = null;
            icon.color     = new Color(1, 1, 1, 0);
            break;

        case PartType.Upgrade:
            titleText.text = "Equipment";
            icon.sprite    = null;
            icon.color     = new Color(1, 1, 1, 0);
            break;
        }
    }
        /// <summary>
        /// Writes a parts info into a packet
        /// </summary>
        /// <param name="packet"></param>
        /// <param name="part"></param>
        public static void WritePartInfo(this ServerBasePacket packet, PartBase part)
        {
            if (!(part is NullWeapon))
            {
                packet.WriteInt(part.Id);
                packet.WriteUInt(part.TemplateId);

                packet.WriteUShort(0x86a0); // Parameter - Possibly for permanent / cannot delete items?
                packet.WriteUShort(0);      // Type? - Zero in packets

                packet.WriteByte(part.Color.R);
                packet.WriteByte(part.Color.G);
                packet.WriteByte(part.Color.B);

                // 0 - Head
                // 1 - Chest
                // 2 - Arm
                // 3 - Leg
                // 4 - Backpack
                // 5 - Fist
                // 6 - Gun
                // 7 - Shield

                // Quick and dirty, get first digit
                var partsType = part.TemplateId;
                while (partsType >= 10)
                {
                    partsType /= 10;
                }

                partsType--;

                packet.WriteByte((byte)partsType); // Looks like 0 indexed version of part type
                packet.WriteByte(0);               // Unknown

                packet.WriteInt(0);                // Unknown

                // FArray - Unknown
                packet.WriteInt(0); // Array size

                // Array contents would go here

                packet.WriteInt(-1);         // Expiry time / current durability
                packet.WriteInt(0x14997000); // Max Durability - Value from server packet capture
                packet.WriteInt(2);          // If 1, durability, if 2, expired?
                packet.WriteInt(0);          // Unknown
            }
            else
            {
                packet.WriteInt(-1);
                packet.WriteUInt(0);

                packet.WriteUShort(0);
                packet.WriteUShort(0);

                packet.WriteByte(0);
                packet.WriteByte(0);
                packet.WriteByte(0);

                packet.WriteByte(0); // Unknown
                packet.WriteByte(0); // Unknown

                packet.WriteInt(0);  // Unknown

                // FArray - Unknown
                packet.WriteInt(0); // Array size

                // Array contents would go here

                packet.WriteInt(0); // Unknown
                packet.WriteInt(0); // Unknown
                packet.WriteInt(0); // If 1, durability, if 2, expired?
                packet.WriteInt(0); // Unknown
            }
        }
        /// <summary>
        /// This overload is for bots that don't derive from ship, but do contain parts.  This will show the parts, and wont' show
        /// any ship specific visuals
        /// </summary>
        public ShipViewerWindow(PartBase[] parts, NeuralUtility.ContainerOutput[] neuronLinks)
        {
            InitializeComponent();

            _bot = null;
            _parts = parts;
            _neuronLinks = neuronLinks;

            var aabb = PartBase.GetAABB(_parts);

            Constructor_Finish(aabb);
        }
示例#26
0
        public void BuildProviderId_RoleNonFr_EqualsTypeId()
        {
            string id = PartBase.BuildProviderId("net.fusisoft.date", "copy");

            Assert.Equal("net.fusisoft.date", id);
        }
示例#27
0
        public void BuildProviderId_NoRole_EqualsTypeId()
        {
            string id = PartBase.BuildProviderId("net.fusisoft.note", null);

            Assert.Equal("net.fusisoft.note", id);
        }
示例#28
0
 public void RemovePart(PartBase _part)
 {
     partsInventory.Remove(_part);
     partsInventoryBar.RemoveItem(_part);
 }