Esempio n. 1
0
    private void Start()
    {
        _camera         = Camera.main;
        _particleSystem = GetComponent <ParticleSystem>();
        _animator       = new MultiAnimator(modelMasked.GetComponentInChildren <Animator>(),
                                            modelUnmasked.GetComponentInChildren <Animator>());
        _boxCollider = GetComponent <BoxCollider>();
        _rigidbody   = GetComponent <Rigidbody>();

        _shoppingCart = GetComponentInChildren <ShoppingCart>();

        _cameraOffset = _camera.transform.position - transform.position;

        _fingersScript = GetComponent <FingersScript>();

        _tapRecognizer = new TapGestureRecognizer();
        _tapRecognizer.NumberOfTapsRequired = 1;
        _tapRecognizer.StateUpdated        += Controls.OnTap;

        _longPressGestureRecognizer = new LongPressGestureRecognizer();
        _longPressGestureRecognizer.MinimumDurationSeconds = 0.1f;
        _longPressGestureRecognizer.StateUpdated          += Controls.OnLongPress;

        _fingersScript.AddGesture(_tapRecognizer);
        _fingersScript.AddGesture(_longPressGestureRecognizer);

        _fingersScript.TreatMousePointerAsFinger = !Input.touchSupported;
    }
Esempio n. 2
0
 public override void OnStart(StartState state)
 {
     base.OnStart(state);
     if (!string.IsNullOrEmpty(AnimatorID))
     {
         Animator = part.GetAnimator(AnimatorID);
     }
 }
Esempio n. 3
0
 public override void OnStart(StartState state)
 {
     base.OnStart(state);
     //get grapple transforms
     foreach (var grapple in Utils.ParseLine(GrappleTransforms, Utils.Whitespace))
     {
         grapple_transforms.AddRange(part.FindModelTransforms(grapple));
     }
     //initialize animators
     armAnimator = part.GetAnimator <MultiAnimator>(ArmAnimatorID);
     fixAnimator = part.GetAnimator <MultiAnimator>(FixAnimatorID);
     if (IsDocked)
     {
         var dockedPart = vessel[dockedPartUId];
         if (dockedPart == part.parent)
         {
             setup_grapple_node(dockedPart, part);
         }
         else
         {
             setup_grapple_node(dockedPart, dockedPart);
         }
     }
     else if (this.state > State.Armed)
     {
         this.state = State.Armed;
     }
     if (this.state != State.Idle)
     {
         if (armAnimator != null)
         {
             armAnimator.Open();
         }
     }
     if (this.state == State.Fixed)
     {
         if (fixAnimator != null)
         {
             fixAnimator.Open();
         }
     }
     update_part_menu();
     //initialize socket
     if (GrappleEnergyConsumption > 0)
     {
         socket = part.CreateSocket();
     }
 }
Esempio n. 4
0
 public override void OnStart(StartState state)
 {
     base.OnStart(state);
     vessel_spawner = new VesselSpawner(part);
     SpawnManager.Init(part);
     SpawnManager.SetupSensor();
     if (!string.IsNullOrEmpty(AnimatorID))
     {
         animator = part.GetAnimator(AnimatorID);
     }
     if (animator != null)
     {
         StartCoroutine(Utils.SlowUpdate(spawn_space_keeper));
     }
     if (Kit && !Kit.Empty)
     {
         can_construct_in_situ = CanConstruct(Kit);
     }
 }
Esempio n. 5
0
        public override void OnLoad(ConfigNode node)
        {
            base.OnLoad(node);
            //node and value names are compatible with ModuleGrappleNode
            //deprecated config conversion
            var vinfo = node.GetNode("THISVESSEL") ?? node.GetNode("DOCKEDVESSEL");

            if (vinfo != null)
            {
                this_vessel = new DockedVesselInfo();
                this_vessel.Load(vinfo);
            }
            //deprecated config conversion
            vinfo = node.GetNode("DOCKEDVESSEL_Other") ?? node.GetNode("DOCKEDVESSEL");
            if (vinfo != null)
            {
                docked_vessel = new DockedVesselInfo();
                docked_vessel.Load(vinfo);
            }
            if (node.HasValue("dockUId"))
            {
                dockedPartUId = uint.Parse(node.GetValue("dockUId"));
            }
            GrappleRangeSqr = GrappleRange * GrappleRange;
            DockRangeSqr    = DockRange * DockRange;
            //load grapple attach node
            if (HighLogic.LoadedSceneIsFlight)
            {
                grappleNode               = new AttachNode();
                grappleNode.size          = 1;
                grappleNode.id            = "grapple";
                grappleNode.rigid         = true;
                grappleNode.ResourceXFeed = true;
                grappleNode.attachMethod  = AttachNodeMethod.FIXED_JOINT;
                grappleNode.breakingForce = grappleNode.breakingTorque = float.PositiveInfinity;
            }
            if (node.HasValue("grapplePos"))
            {
                grapplePos = KSPUtil.ParseVector3(node.GetValue("grapplePos"));
            }
            if (node.HasValue("grappleOrt"))
            {
                grappleOrt = KSPUtil.ParseVector3(node.GetValue("grappleOrt"));
            }
            if (node.HasValue("grappleOrt2"))
            {
                grappleOrt2 = KSPUtil.ParseVector3(node.GetValue("grappleOrt2"));
            }
            //deprecated config conversion
            if (node.HasValue("Fixed"))
            {
                if (bool.Parse(node.GetValue("Fixed")))
                {
                    state = State.Fixed;
                }
                else if (dockedPartUId > 0)
                {
                    state = State.Docked;
                }
                else
                {
                    armAnimator = part.GetAnimator <MultiAnimator>(ArmAnimatorID);
                    if (armAnimator != null &&
                        armAnimator.State == AnimatorState.Opened)
                    {
                        state = State.Armed;
                    }
                    else
                    {
                        state = State.Idle;
                    }
                }
            }
        }