Esempio n. 1
0
 private void AnswerChosen(object sender, bool answerIsCorrect)
 {
     if (answerIsCorrect)
     {
         var   mAircraft = MiddleAircraft;
         float oldP      = GetWreckPercentile(mAircraft);
         float newP      = Math.Min(oldP + 0.1f * ((MathChallengeNode)sender).Multiplier, GetWreckMaxPercentile(mAircraft));
         float diff      = newP - oldP;
         AddAction(new CCEaseIn(new CCCallFiniteTimeFunc(1f, (progress, duration) => { SetWreckPercentile(mAircraft, newP - diff * (1 - progress)); }), 4f));
         EndRepair(false);
     }
     else
     {
         WasteCurrentWreck();
     }
     // move the challengeNode away
     GUILayer.MoveMathChallengeNodeAway();
 }
Esempio n. 2
0
        public PlayLayer() : base(CCColor4B.Black)
        {
            GUILayer         = new GUILayer(this);
            TouchCountSource = GUILayer;
            BGNode           = new CCNode();
            AddChild(BGNode);
            BGNode.VertexZ = Constants.VERTEX_Z_GROUND;
            BGNode.AddChild(DrawNode);
            BGNode.AddChild(DrawNodeBG);
            DrawNodeBG.BlendFunc = CCBlendFunc.NonPremultiplied;  // necessary for alpha to work
            BGNode.ZOrder        = (int)Constants.VERTEX_Z_GROUND;
            BGNode.Rotation      = 10f;

            AddChild(DrawNodeExplosions, -2000);
            DrawNodeExplosions.VertexZ   = Constants.VERTEX_Z_GROUND + 1;
            DrawNodeExplosions.BlendFunc = CCBlendFunc.NonPremultiplied;

            HighDrawNode           = new CCDrawNode();
            HighDrawNode.BlendFunc = CCBlendFunc.NonPremultiplied;
            AddChild(HighDrawNode, zOrder: 1000);
            LowDrawNode           = new CCDrawNode();
            LowDrawNode.BlendFunc = CCBlendFunc.NonPremultiplied;
            AddChild(LowDrawNode, zOrder: -1000);

            MaxCameraWidth  = Constants.COCOS_WORLD_WIDTH * 10;
            MaxCameraHeight = Constants.COCOS_WORLD_HEIGHT * 10;

            // add a touch listener
            var touchListener = new CCEventListenerTouchAllAtOnce();

            touchListener.OnTouchesBegan     = OnTouchesBegan;
            touchListener.OnTouchesMoved     = OnTouchesMovedMoveAndZoom;
            touchListener.OnTouchesEnded     = OnTouchesEnded;
            touchListener.OnTouchesCancelled = OnTouchesEnded;
            AddEventListener(touchListener, int.MaxValue);

            // add a mouse listener
            var mouseListener = new CCEventListenerMouse();

            mouseListener.OnMouseScroll = OnMouseScrollZoom;
            AddEventListener(mouseListener, int.MaxValue);
        }
Esempio n. 3
0
        private void WasteCurrentWreck()
        {
            GUILayer.AddScreenShake(50f, 50f);
            var         mAircraft    = MiddleAircraft;
            float       startP       = GetWreckPercentile(mAircraft);
            var         percentLabel = GetPercentLabel(mAircraft);
            const float DURATION     = 1.5f;

            AddAction(new CCSequence(new CCEaseIn(new CCCallFiniteTimeFunc(DURATION, (progress, duration) => { SetWreckPercentile(mAircraft, startP * (1 - progress)); }), 4f),
                                     new CCCallFunc(() => { EndRepair(true); })));
            // let the aircraft visually crumble to pieces
            var totalParts  = mAircraft.TotalParts;
            var currentConf = new Dictionary <Part, Tuple <CCPoint, float, float> >();

            foreach (var part in totalParts)
            {
                currentConf[part] = new Tuple <CCPoint, float, float>(part.PositionWorldspace, part.MyRotation, part.GetTotalScale());
            }
            mAircraft.Body.Disassemble();
            mAircraft.Body = null;
            var rng = new Random();

            foreach (var part in totalParts)
            {
                AddChild(part, 99999);
                // place them so that the position is (visually) the same
                var config = currentConf[part];
                part.Position = config.Item1;
                part.Rotation = config.Item2;
                part.Scale    = config.Item3;
                // add an action to let it spin around a bit randomly
                part.AddAction(new CCSpawn(new CCEaseOut(new CCMoveTo(DURATION * 2, Constants.RandomPointNear(part.Position, 600f, rng)), 2f),
                                           new CCFadeOut(DURATION * 2)));
                part.AddAction(new CCRepeatForever(new CCRotateBy(1f, (rng.NextBoolean() ? -1 : 1) * (50f + (float)rng.NextDouble() * 100f))));
                part.AddAction(new CCSequence(new CCDelayTime(DURATION * 2 + 0.1f), new CCRemoveSelf()));
            }
        }