コード例 #1
0
    void CastRay()
    {
        RaycastHit hit;

        if (Physics.Raycast(camera.transform.position, camera.transform.forward, out hit, 2.4f, 1, QueryTriggerInteraction.Collide))
        {
            Item          item          = hit.collider.GetComponent <Item> ();
            ShipWheel     shipWheel     = hit.collider.GetComponent <ShipWheel> ();
            Harbourmaster harbourmaster = hit.collider.GetComponent <Harbourmaster> ();
            if (item)
            {
                uiManager.SetInteractTextToItem(item);
                if (Input.GetKeyDown(KeyCode.E))
                {
                    AttemptPickUpItem(item);
                }
            }
            else if (shipWheel)
            {
                uiManager.SetInteractText("E - Take control");
                if (Input.GetKeyDown(KeyCode.E))
                {
                    shipManager.ActivateShipWheel(shipWheel.GetComponentInParent <Ship>());
                }
            }
            else if (harbourmaster)
            {
                uiManager.SetInteractText("E - Access port");
                if (Input.GetKeyDown(KeyCode.E))
                {
                    uiManager.EnablePortMenu(harbourmaster.GetPort());
                }
            }
            else
            {
                uiManager.ClearInteractText();
            }
        }
        else
        {
            uiManager.ClearInteractText();
        }
    }
コード例 #2
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();

            if (version == 0)
            {
                Timer.DelayCall(() =>
                {
                    var deckItem = Fixtures.FirstOrDefault(f => m_WheelItemIDs.Any(listID => listID == f.ItemID));

                    if (deckItem != null)
                    {
                        ShipWheel wheel = new ShipWheel(this, deckItem.ItemID);
                        AddFixture(wheel);

                        wheel.MoveToWorld(new Point3D(deckItem.X, deckItem.Y, deckItem.Z), deckItem.Map);

                        deckItem.Delete();
                        RemoveFixture(deckItem);
                    }
                });
            }
        }