private protected new void OnTouchesBegan(List <CCTouch> touches, CCEvent touchEvent)
 {
     if (WreckageLayer.State == WreckageLayer.WreckageState.SALVAGED)
     {
         // switch back to carousel mode
         WreckageLayer.EndSalvage();
     }
 }
 public WreckageGUILayer(WreckageLayer wreckageLayer) : base(CCColor4B.Transparent, true)
 {
     WreckageLayer = wreckageLayer;
     Scroller      = null;
     FirstTouchListener.OnTouchesBegan     += OnTouchesBegan;
     FirstTouchListener.OnTouchesMoved     += SwipeUpDown;
     FirstTouchListener.OnTouchesEnded     += StopSwiping;
     FirstTouchListener.OnTouchesCancelled += StopSwiping;
 }
 private protected void StopSwiping(List <CCTouch> touches, CCEvent touchEvent)
 {
     if (TouchCount == 0)
     {
         if (SwipingUpDown)
         {
             touchEvent.StopPropogation();
             // since the event is stopped here the WreckCarousel has to be informed manually
             WreckageLayer.WreckCarousel.Pressed = false;
             const float actionRate = 2f;
             const float actionTime = 0.25f;
             CCAction    action;
             var         reenableCarousel = new CCCallFunc(() => { if (WreckageLayer.State == WreckageLayer.WreckageState.CAROUSEL)
                                                                   {
                                                                       WreckageLayer.WreckCarousel.Pressable = true;
                                                                   }
                                                           });
             var bounds = WreckageLayer.VisibleBoundsWorldspace;
             // release the wreck
             var wreck = WreckageLayer.MiddleAircraft;
             if (wreck.PositionWorldspace.Y > bounds.Center.Y + bounds.Size.Height * 0.25f)
             {
                 // salvage
                 WreckageLayer.WreckCarousel.Pressable = false;
                 action = new CCSequence(new CCEaseOut(new CCMoveTo(actionTime, WreckPositionOriginal + new CCPoint(0, VisibleBoundsWorldspace.Size.Height)), actionRate),
                                         new CCCallFunc(WreckageLayer.Salvage) /*,
                                                                                * reenableCarousel*/);
             }
             else if (wreck.PositionWorldspace.Y < bounds.Center.Y - bounds.Size.Height * 0.25f &&
                      WreckageLayer.GetWreckPercentile(WreckageLayer.MiddleAircraft) < WreckageLayer.GetWreckMaxPercentile(WreckageLayer.MiddleAircraft))
             {
                 // repair
                 WreckageLayer.WreckCarousel.Pressable = false;
                 action = new CCSequence(new CCEaseOut(new CCMoveTo(actionTime, WreckPositionOriginal), actionRate),
                                         new CCCallFunc(WreckageLayer.StartRepair) /*,
                                                                                    * reenableCarousel*/);
             }
             else
             {
                 // reset
                 action = new CCSequence(new CCEaseOut(new CCMoveTo(actionTime, WreckPositionOriginal), actionRate),
                                         reenableCarousel);
             }
             action.Tag = ActionTag;
             wreck.AddAction(action);
         }
         // reset flags
         SwipeIsUndecided = true;
         SwipingUpDown    = false;
     }
 }
Esempio n. 4
0
        private protected void EnterWreckageLayer()
        {
            var wreckageLayer = new WreckageLayer();

            TransitionFadingFromTo(this.GUILayer, wreckageLayer.GUILayer, this, wreckageLayer, 0.8f);
            GUILayer.PlayLayer = null;

            /*
             * var parent = Parent;
             * RemoveAllListeners();
             * GUILayer.RemoveAllListeners();
             * Parent.RemoveChild(GUILayer);
             * Parent.RemoveChild(this);
             * parent.AddChild(wreckageLayer.GUILayer);
             * parent.AddChild(wreckageLayer, zOrder: int.MinValue);
             */
            // place the aircrafts and add them as children
            var list = DownedAircrafts.ToArray().ToList();

            wreckageLayer.AddAction(new CCCallFunc(() => { wreckageLayer.InitWreckage(list); wreckageLayer.CheckForWelcome(); }));
        }