Пример #1
0
    public void PickUp(Item item)
    {
        if (item == currItem)
        {
            return;
        }

        DropItem();

        if (item == shovel)
        {
            (shovel as Shovel).TakeOut();
        }

        Jukebox.Play("Pickup");

        currItem = item;

        // REPARENT FX TO THIS
        currItem.fx.parent        = fx.pose.rightHand;
        currItem.fx.localPosition = Vector3.zero;
        currItem.fx.localScale    = Vector3.one;

        currItem.StopPhysics();

        fx.Flash(Color.white);

        currItem.OnPickUp();
    }
Пример #2
0
        /// <summary>
        /// Called during initial app startup, this function performs all the
        /// permanent initialization.
        /// </summary>
        protected override void OneTimeSceneInitialization()
        {
            // Initialize the font's internal textures
            m_pFont.InitializeDeviceObjects(device);

            m_Engine.Initialize(this, device);

            CGameEngine.Inputs.MapKeyboardAction(Key.Escape, new ButtonAction(Terminate), true);
            CGameEngine.Inputs.MapKeyboardAction(Key.A, new ButtonAction(MoveCameraXM), false);
            CGameEngine.Inputs.MapKeyboardAction(Key.W, new ButtonAction(MoveCameraZP), false);
            CGameEngine.Inputs.MapKeyboardAction(Key.S, new ButtonAction(MoveCameraXP), false);
            CGameEngine.Inputs.MapKeyboardAction(Key.Z, new ButtonAction(MoveCameraZM), false);
            CGameEngine.Inputs.MapKeyboardAction(Key.P, new ButtonAction(ScreenCapture), true);
            CGameEngine.Inputs.MapMouseAxisAction(0, new AxisAction(PointCamera));
            CGameEngine.Inputs.MapMouseAxisAction(1, new AxisAction(PitchCamera));

            m_Console = new GameEngine.Console(m_pFont, @"..\..\Resources\console.jpg");

            GameEngine.Console.AddCommand("QUIT", "Terminate the game", new CommandFunction(TerminateCommand));
            GameEngine.Console.AddCommand("STATISTICS", "Toggle statistics display", new CommandFunction(ToggleStatistics));

            m_OptionScreen = new OptionScreen(@"..\..\Resources\Options2.jpg");
            m_OptionScreen.AddButton(328, 150, @"..\..\Resources\PlayOff.bmp", @"..\..\Resources\PlayOn.bmp", @"..\..\Resources\PlayHover.bmp", new ButtonFunction(Play));
            m_OptionScreen.AddButton(328, 300, @"..\..\Resources\QuitOff.bmp", @"..\..\Resources\QuitOn.bmp", @"..\..\Resources\QuitHover.bmp", new ButtonFunction(Terminate));
            m_Engine.SetOptionScreen(m_OptionScreen);

            music = new Jukebox();
            music.AddSong("nadine.mp3");
            music.AddSong("ComeOn.mp3");
            music.AddSong("Rock.mp3");
            music.Volume = 0.75f;
            music.Play();
        }
Пример #3
0
        public override void LoadContent()
        {
            input = new Input();

            dfp20 = ScreenManager.Content.Load <SpriteFont>("Font/dfp20");

            donIdleSheet   = ScreenManager.Content.Load <Texture2D>("Texture/Don/Anim/SongSelect/idle");
            bgMask         = ScreenManager.Content.Load <Texture2D>("Texture/SongSelect/bgMask");
            timerBg        = ScreenManager.Content.Load <Texture2D>("Texture/SongSelect/timer");
            selectSongText = ScreenManager.Content.Load <Texture2D>("Texture/SongSelect/selectText");

            menu = new Menu(ScreenManager.Content, ScreenManager.SpriteBatch);
            menu.LoadContent();

            animator = new SpriteAnimator(ScreenManager.SpriteBatch);
            donIdle  = new SpriteAnimation(donIdleSheet, new Vector2(291, 291), new Vector2(10, 3), 30, 1000f / ((30 * 116) / 60), true);

            animator.Add("idle", donIdle);
            animator.Switch("idle");

            idleLoop       = new WaveFileReader("Content/Music/SongSelect/idle.wav");
            idleLoopStream = new LoopStream(idleLoop, 254437);

            music = new Jukebox();
            music.Play(idleLoopStream);

            sfx = new Jukebox();

            kat = ScreenManager.Content.Load <SoundEffect>("kat");

            base.LoadContent();
        }
Пример #4
0
    IEnumerator Start()
    {
        yield return(null);

        yield return(null);

        while (!Input.anyKeyDown)
        {
            yield return(null);
        }

        Jukebox.Play("title");

        foreach (var t in GetComponentsInChildren <TextMesh>())
        {
            Destroy(t.gameObject);
        }

        var p0 = transform.localPosition;

        foreach (var t in Transition(0.25f * 8f / 3f))
        {
            transform.localPosition = p0.Above(EaseOut4(t));
            yield return(null);
        }

        Destroy(gameObject);
    }
Пример #5
0
 public static bool Prefix(JukeboxInstance __instance)
 {
     if (string.IsNullOrEmpty(__instance.file) || !Jukebox.HasFile(__instance._file))
     {
         __instance.SwitchTrack(true);
     }
     if (__instance.isControlling && Jukebox.isStartingOrPlaying)
     {
         MainPatch.isPaused = !Jukebox.paused;
         Jukebox.paused     = !Jukebox.paused;
     }
     else if (__instance.ConsumePower())
     {
         Jukebox.Play(__instance);
         Jukebox.TrackInfo info = Jukebox.GetInfo(__instance.file);
         __instance.SetLabel(info.label);
         __instance.SetLength(info.length);
         MainPatch.isPlaying = true;
         MainPatch.isPaused  = false;
     }
     else
     {
         __instance.SetLabel(Language.main.Get("JukeboxNoPower"));
     }
     if (StoryGoalManager.main.IsAlanOnboard())
     {
         StoryGoal.Execute("Log_Alan_Aside_JukeboxMusic", Story.GoalType.PDA, true, false);
     }
     return(false);
 }
Пример #6
0
        public override void DoPickupAction(RagdollMuscle ragdoll)
        {
            ApplyPowerup(ragdoll);

            if (Song != null)
            {
                Jukebox.Play(Song);
            }
        }
Пример #7
0
 public override void Init()
 {
     spriteRenderer.sprite = frames[0];
     frame = 0;
     time  = 0f;
     if (sfx.Length > 0)
     {
         Jukebox.Play(sfx);
     }
 }
Пример #8
0
 void DoKillscreen()
 {
     Jukebox.Play("MetalRiff" + Random.Range(0, 3));
     DropItem();
     StartCoroutine(DoSlowDownTime());
     input.Halt();
     Jukebox.Play("Kill");
     Music.KillMusic();
     Dup(killScreenPrefab);
 }
Пример #9
0
    void UpdateWaiting()
    {
        if (initialWait)
        {
            if (!FindObject <Title>())
            {
                initialWait = false;
            }
            else
            {
                return;
            }
        }

        if (Cam.inst.tracking < 0.999f || Cam.inst.trackingPatch == null)
        {
            return;
        }

        // respawn

        respawnTime = Time.time;

        Jukebox.Play("truck_respawn");
        Jukebox.Play("cheer");

        status = Status.Active;
        fx.gameObject.SetActive(true);
        shadow.gameObject.SetActive(true);
        cone.gameObject.SetActive(true);

        var spawnPos = Cam.inst.p - Cam.inst.offset;

        spawnPos.y += 8f;
        spawnPos.x  = 0.5f * (Cam.inst.trackingPatch.x0 + Cam.inst.trackingPatch.x1) - 0.001f;

        body.position   = spawnPos;
        body.rotation   = Quaternion.identity;
        speed           = maxSpeed;
        velocity        = Vec(0, 0, speed);
        rotationSpeed   = 0f;
        rotation        = 0f;
        pitch           = 0f;
        grounded        = false;
        patch           = null;
        leaveGroundTime = -999f;
        hitGroundTime   = -999f;
        scaleY          = 1f;

        coneSpeed     = 0f;
        coneY         = coneAnchor.position.y;
        cone.position = coneAnchor.position;

        explosionTime = -999f;
    }
Пример #10
0
 void OnCollisionEnter(Collision collision)
 {
     if (collision.collider.IsTile())
     {
         if (playOnce)
         {
             Jukebox.Play("GrenadeBounce");
             playOnce = false;
         }
     }
 }
Пример #11
0
    internal void Kill()
    {
        if (!dead)
        {
            Jukebox.Play("dinodie");
        }

        dead = true;
        this.GetComponent <SpriteRenderer> ().sprite = die;
        this.GetComponent <SpriteRenderer> ().color  = new Color(1, 1, 1, 1);
        this.gameObject.layer = Layers.Debris;
    }
Пример #12
0
 public void OnHitVictim()
 {
     current += 1f / hitCount;
     if (current >= 1f)
     {
         current = 0f;
         multi++;
         multiText.text = "x" + multi;
         Jukebox.Play("multi");
         Jukebox.Play("cheer");
     }
 }
Пример #13
0
    public override void Operate(Vector2 dir)
    {
        // SPAWN grenade W/ KINDA RANDOMIZED HEADING
        Grenade inst = grenade.Alloc(
            fx.GetChild(0).transform.position) as Grenade;

        //Cmul( UnitVec(Random.Range(-0.1f * Mathf.PI, 0.1f * Mathf.PI) ), dir)
        //);
        inst.SetInitDir(Cmul(UnitVec(Random.Range(-0.05f * Mathf.PI, 0.05f * Mathf.PI)), dir));

        // SIDE-EFFECTS
        Jukebox.Play("ShootGrenade");
        Hero.inst.Kickback(-dir * 5);
    }
Пример #14
0
    public override void Operate(Vector2 dir)
    {
        // SPAWN ROCKET W/ KINDA RANDOMIZED HEADING
        rocket.Alloc(
            muzzle.position,
            Cmul(UnitVec(Random.Range(-0.025f * Mathf.PI, 0.125f * Mathf.PI)), dir)
            );

        // SIDE-EFFECTS
        Jukebox.Play("ShootBazooka");
        dir *= -1;
        if (dir.y == 0)         //hack to combat friction
        {
            dir.y = 0.01f;
        }
        Hero.inst.Kickback(dir * 20);
    }
Пример #15
0
 void TryExplode()
 {
     if (status == Status.Active)
     {
         status        = Status.Exploding;
         explosionTime = Time.time;
         explosion.transform.rotation = Cam.inst.baseRotation * Quaternion.AngleAxis(-5f, Vector3.up);
         fx.gameObject.SetActive(false);
         shadow.gameObject.SetActive(false);
         explosion.gameObject.SetActive(true);
         Jukebox.Play("truck_explode");
         Jukebox.Play("boo");
         explosionConePos = cone.position;
         Cam.inst.Shake(10f);
         Cam.inst.Flash();
         HUD.inst.OnExplode();
     }
 }
Пример #16
0
    public void Shoot(Vector2 dir)
    {
        // RESET FROM LAST TIME
        rayStartRoot.localScale = Vec(1, 1, 1);
        rayRoot.localScale      = Vec(0, 1, 1);
        SetAlpha(1);
        for (int i = 0; i < zaps.Length; ++i)
        {
            zaps[i].localPosition = zapStarts[i];
        }

        // ROTATE BEAM
        xform.rotation = QDir(dir);

        // START ANIMATIONS
        Jukebox.Play("LazerBlast");
        StartCoroutine(ShowEffects());
        CameraFX.inst.Flash(Color.white, 0.1f);

        // ACTUALLY SHOOT
        var diag      = Vec(CameraFX.inst.Width, CameraFX.inst.Height).magnitude;
        var shootMask = Layers.TileMask | Layers.EnemyMask | Layers.Hazard | Layers.PassiveHazard;
        var hits      = Physics.SphereCastAll(xform.position.xy() - 2f * dir, 1.0f, Vec(dir, 0), diag, shootMask);

        foreach (var hit in hits)
        {
            switch (hit.transform.gameObject.layer)
            {
            case Layers.Enemy:
                // TODO: GENERALIZE TO ANY ENEMY?
                var dino = hit.transform.GetComponent <Dino>();
                if (dino)
                {
                    dino.Kill();
                }
                break;

            case Layers.Tile:
                var tile = hit.transform.GetComponent <Tile>();
                WorldGen.inst.Dig(tile.tileX, tile.tileY - WorldGen.inst.height, 10);
                break;
            }
        }
    }
Пример #17
0
        private void BtnPlayPause_Click(object sender, EventArgs e)
        {
            bool isNotKitkat = Build.VERSION.SdkInt > BuildVersionCodes.KitkatWatch;

            switch (playbackState)
            {
            //If the media is paused, then Play.
            case PlaybackStateCode.Paused:
                if (isNotKitkat)
                {
                    Jukebox.Play();
                }
                else
                {
                    JukeboxKitkat.Play();
                }
                break;

            //If the media is playing, then pause.
            case PlaybackStateCode.Playing:
                if (isNotKitkat)
                {
                    Jukebox.Pause();
                }
                else
                {
                    JukeboxKitkat.Pause();
                }

                break;

            default:
                if (isNotKitkat)
                {
                    Jukebox.Stop();
                }
                else
                {
                    JukeboxKitkat.Stop();
                }
                break;
            }
        }
Пример #18
0
        private void BtnPlayPause_Click(object sender, EventArgs e)
        {
            switch (playbackState)
            {
            //If the media is paused, then Play.
            case PlaybackStateCode.Paused:
                Jukebox.Play();
                break;

            //If the media is playing, then pause.
            case PlaybackStateCode.Playing:
                Jukebox.Pause();

                break;

            default:
                Jukebox.Stop();
                break;
            }
        }
Пример #19
0
    public void DropItem()
    {
        if (currItem != null)
        {
            if (currItem == shovel)
            {
                (shovel as Shovel).PutAway();
            }
            else
            {
                currItem.StartPhysics(fx.direction == HeroFX.Direction.Right ?Vec(-8, 16) : Vec(8, 16), true);
                currItem.rigidbody.angularVelocity = Vec(0, 0, 360f);
                currItem.OnDrop();
            }
            currItem = null;



            Jukebox.Play("DropWeapon");
        }
    }
Пример #20
0
    public override void Operate(Vector2 dir)
    {
        var basePos = Hero.inst.xform.position;
        var didDig  = WorldGen.inst.DigShovel((int)(basePos.x + dir.x + 0.5f), (int)(basePos.y + dir.y + 0.5f));


        fx.localPosition = 0.8f * dir;

        float d = Vector3.Distance(WorldGen.inst.earthCore.xform.position, Hero.inst.xform.position);

        if (d < 15)
        {
            WorldGen.inst.earthCore.StartDestroy();
            didDig = true;
        }

        Jukebox.Play(didDig ? "Dig" : "Derp");
        if (didDig)
        {
            CameraFX.inst.Shake(0.5f);
            Hero.inst.Kickback(-dir * 3);
        }
    }
Пример #21
0
    // Update is called once per frame
    void Update()
    {
        Vector3 p0 = xform.position;

        if (!Halted)
        {
            p0.y -= Time.deltaTime * killSpeed;
        }


        xform.position = p0;

        Vector3 p = CameraFX.inst.xform.position;

        SpriteRenderer warning = GetComponentInChildren <SpriteRenderer> ();


        if (p.y + CameraFX.inst.HalfHeight + 1.5f > xform.position.y)
        {
            warning.transform.localScale = warning.transform.localScale.EaseTowards(new Vector3(1, 1, 1), 0.2f);
            flashTimer += Time.deltaTime;
            if (flashTimer > 1)
            {
                Jukebox.Play("warning");

                warning.color = new Color(1, 1, 1, 1);
                flashTimer    = 0;
            }
        }
        else
        {
            warning.transform.localScale = new Vector3(1, 0, 1);
        }
        warning.color = warning.color.EaseTowards(new Color(1, 1, 1, 0), 0.2f);

        warning.transform.position = new Vector3(p.x, p.y + CameraFX.inst.HalfHeight * 0.9f, 0);
    }
Пример #22
0
 void TickJump()
 {
     if (input.PressedJump)
     {
         if (grounded)
         {
             Jukebox.Play("Jump");
             grounded = false;
             body.AddForce(
                 Vec(0, jumpImpulse - body.velocity.y, 0),
                 ForceMode.VelocityChange
                 );
         }
         else if (canDoubleJump)
         {
             Jukebox.Play("Jump");
             canDoubleJump = false;
             body.AddForce(
                 Vec(0, doubleJumpImpulse - body.velocity.y, 0),
                 ForceMode.VelocityChange
                 );
         }
     }
 }
Пример #23
0
    void FixedUpdateActive()
    {
        // preamble
        var dt           = Time.fixedDeltaTime;
        var p0           = body.position;
        var t0           = fx.forward;
        var prevGrounded = grounded;

        // edge rotation
        var hw           = World.inst.extent;
        var nx           = (p0.x / hw);
        var edgeResponse = Mathf.Pow(nx, 7f) * Mathf.Max(0f, t0.x * nx);

        // udpate rotation
        rotationSpeed -= turningDrag * rotationSpeed * dt;
        rotationSpeed -= turningDragQ * Mathf.Abs(rotationSpeed) * rotationSpeed * dt;
        if (grounded)
        {
            rotationSpeed += Steering * (1.0f - Mathf.Abs(edgeResponse)) * turningImpulse * dt;
        }
        rotationSpeed -= restoreP * rotation * dt;
        rotation      += rotationSpeed * dt;

        if (grounded)
        {
            rotationSpeed *= 1f - edgeResponse;
            rotation      -= cancelP * edgeResponse;
        }

        // update pitch
        if (!grounded && pitch > 0f)
        {
            pitch *= 0.97f;
        }

        // update orientation
        var radians = Mathf.Deg2Rad * rotation;
        var fwd     = Vec(Mathf.Sin(radians), pitch, Mathf.Cos(radians));
        var rot     = Quaternion.LookRotation(fwd);

        body.MoveRotation(rot);

        // linear location
        if (grounded)
        {
            // driving
            var effectiveMaxSpeed = maxSpeed + HUD.inst.multi * 4f;
            speed   += 0.2f * (effectiveMaxSpeed - speed);
            velocity = fwd * speed;
        }
        else
        {
            // freefall
            velocity -= freefallDrag * velocity * dt;
        }
        velocity += Physics.gravity * dt;

        var p1 = p0 + velocity * dt;

        // cast move ray to clip position
        RaycastHit hit;
        var        ep      = 0.01f;
        var        move    = (p1 - p0).magnitude;
        var        moveRay = new Ray(p0.Above(ep), p1 - p0);

        if (Physics.Raycast(moveRay, out hit, move, 1))
        {
            if (hit.normal.y * hit.normal.y < 0.01f)
            {
                p1 = hit.point + ep * hit.normal;
            }
        }

        // cast left/right to avoid walls
        var pad      = 0.8f;
        var leftRay  = new Ray(p1 + Vec(ep, 0, 0), Vec(-1, 0, 0));
        var rightRay = new Ray(p1 - Vec(ep, 0, 0), Vec(1, 0, 0));

        if (Physics.Raycast(leftRay, out hit, pad, 1) || Physics.Raycast(rightRay, out hit, pad, 1))
        {
            p1 = hit.point + pad * hit.normal;
            if (Vector3.Dot(transform.forward, hit.normal) < 0f)
            {
                rotation *= 0.8f;
            }
        }

        patch = World.inst.FindPatch(p1.x, p1.z);


        // resolve grounded

        if (patch == null)
        {
            grounded = false;
        }
        else
        {
            // slopes are hard :(
            patchHeight = patch.HeightAtZ(p1.z);
            patchDeriv  = patch.DerivAtZ(p1.z);
            var heightSlop = grounded ? 0.025f : 0.01f;
            heightSlop -= 0.03f * Mathf.Clamp(patchDeriv, -1f, 0f);

            if (p1.y < patchHeight + heightSlop)
            {
                p1.y = Mathf.Max(p1.y, patchHeight);

                // bounce?
                if (!grounded && velocity.y < -4.0f && Mathf.Approximately(patchDeriv, 0f))
                {
                    velocity.y      = 4f;
                    leaveGroundTime = hitGroundTime = Time.time;
                    Jukebox.Play("truck_bounce");
                }
                else
                {
                    velocity.y = 0f;
                    speed      = velocity.magnitude;
                    pitch      = patchDeriv;
                    if (!grounded)
                    {
                        Jukebox.Play("truck_hit_ground");
                    }
                    grounded = true;
                }
            }
            else
            {
                grounded = false;
            }
        }
        body.MovePosition(p1);

        // bookmark ground collision times
        if (grounded ^ prevGrounded)
        {
            if (grounded)
            {
                hitGroundTime = Time.time;
            }
            else
            {
                leaveGroundTime = Time.time;
                Jukebox.Play("truck_jump");
            }
        }
    }
Пример #24
0
    // Update is called once per frame
    void Update()
    {
        if (tripped)
        {
            timeout += Time.deltaTime;

            if (timeout + Time.deltaTime > explodeTime - 0.1f && timeout < explodeTime - 0.1f)
            {
                Jukebox.Play("beep1");
            }

            flickerTime -= Time.deltaTime;
            if (flickerTime < 0)
            {
                Color c = GetComponent <SpriteRenderer> ().color;
                if (c.a == 1.0f)
                {
                    c.a = 0.0f;
                }
                else
                {
                    c.a = 1.0f;
                    if (timeout < explodeTime - 0.1f)
                    {
                        Jukebox.Play("beep0");
                    }
                }

                GetComponent <SpriteRenderer> ().color = c;

                if (timeout < explodeTime - 1.0f)
                {
                    if (c.a == 1.0f)
                    {
                        flickerTime = 0.1f;
                    }
                    else
                    {
                        flickerTime = 0.5f;
                    }
                }
                else
                {
                    flickerTime = 0.05f;
                }
            }


            if (timeout > explodeTime)
            {
                CameraFX.inst.Shake();
                CameraFX.inst.Flash(RGBA(Color.white, 0.5f));

                float      dist    = 1.0f;
                Vector3 [] offsets = new Vector3[7];

                offsets[0] = new Vector3(dist * 1, 0, 0);
                offsets[1] = new Vector3(-dist * 1, 0, 0);
                offsets[2] = new Vector3(0, dist * 1, 0);
                offsets[3] = new Vector3(dist * 2, 0, 0);
                offsets[4] = new Vector3(-dist * 2, 0, 0);
                offsets[5] = new Vector3(0, dist * 2, 0);
                offsets[6] = new Vector3(0, 0, 0);

                for (int i = 0; i < offsets.Length; i++)
                {
                    Vector3 blastPos = xform.position + offsets[i];

                    PooledObject inst = explosionPrefab.Alloc(xform.position + offsets[i]) as PooledObject;
                    float        size = 0.45f;
                    inst.transform.localScale = new Vector3(size, size, size);


                    WorldGen.inst.Dig((int)(blastPos.x + 0.5f), (int)(blastPos.y), 3);
                }


                Release();
            }
        }
    }
Пример #25
0
    void Update()
    {
        if (!TerminalState)
        {
            // DO NORMAL ANIMATIONS
            var ammo = 0;
            if (Hero.inst.currItem != null)
            {
                ammo = Hero.inst.currItem.ammo;
            }
            if (ammo == 0 || ammo >= kAmmoLabels.Length)
            {
                ammoLabel.text = "";
            }
            else
            {
                ammoLabel.text = kAmmoLabels[ammo];
            }


            var oldStatus = status;
            if (Hero.inst.grounded)
            {
                var speed    = Mathf.Abs(Hero.inst.body.velocity.x);
                var prevTime = animationTime;
                if (speed > 0.05f)
                {
                    SetStatus(Status.Running);
                    animationTime += runAnimScale * (speed + 0.25f) * Time.deltaTime;
                    pose.ApplyRunCycle(animationTime);
                }
                else
                {
                    SetStatus(Status.Idle);
                    animationTime = 0f;
                }
                var a = Mathf.FloorToInt(8f * prevTime) % 2;
                var b = Mathf.FloorToInt(8f * animationTime) % 2;
                if (a != b && b == 0)
                {
                    Jukebox.Play("Footfall");
                }
            }
            else
            {
                animationTime = 0f;
                SetStatus(Status.Jumping);
                pose.ApplyJumpCycle(Time.time);
            }
            if (status != oldStatus && oldStatus == Status.Jumping)
            {
                Jukebox.Play("Footfall");
            }
        }
        else
        {
            ammoLabel.text = "";
            if (status == Status.Ragdoll)
            {
                // DO RAGDOLL ANIMATIONS
                pose.TickRagdoll();
            }
        }
    }
Пример #26
0
    IEnumerator Start()
    {
        // CACHE REFERENCES
        var xform    = transform;
        var appearFx = xform.Find("AppearFX");
        var logo     = xform.Find("Logo");
        var logoFx   = logo.GetComponent <SpriteRenderer>();

        var credits = xform.Find("Credits");

        // HIDE THE PLAYER AND APPEAR FX
        Hero.inst.input.Halt();
        KillBar.inst.Halt();
        Hero.inst.gameObject.SetActive(false);
        var baseScale = appearFx.localScale;

        appearFx.localScale = Vec(baseScale.x, 0, baseScale.z);
        dialogSpr.enabled   = false;
        foreach (var spr in textSprites)
        {
            spr.enabled = false;
        }
        genderOp.enabled = false;

        if (firstTime)
        {
            // SHOW LOGO
            var p0 = logo.position;
            var p1 = p0.Above(CameraFX.inst.Height);
            logo.position = p1;
            yield return(null);

            foreach (var u in Interpolate(0.5f))
            {
                logo.position = Vector3.Lerp(p1, p0, EaseOut2(u));
                yield return(null);
            }
            foreach (var u in Interpolate(0.1f))
            {
                logoFx.color = RGBA(Color.white, u);
                yield return(null);
            }
            Jukebox.Play("Bumper");
            foreach (var u in Interpolate(0.1f))
            {
                logoFx.color = RGBA(Color.white, 1f - u);
                yield return(null);
            }


            // WAIT FOR ANY KEY TO START
            do
            {
                yield return(null);
            } while(!GameInput.AnyPress);

            if (genderOp)
            {
                pressAny.text    = "GIRL OR BOY?";
                genderOp.enabled = true;
                genderOp.color   = RGBA(1, 1, 1, 0);
                foreach (var u in Interpolate(0.25f))
                {
                    genderOp.color = RGBA(1, 1, 1, EaseOut2(u));
                    yield return(null);
                }
                bool?girlChoice = null;
                do
                {
                    var pressedLeft  = Input.GetKeyDown(KeyCode.LeftArrow) || InputManager.ActiveDevice.DPadLeft.WasPressed;
                    var pressedRight = Input.GetKeyDown(KeyCode.RightArrow) || InputManager.ActiveDevice.DPadRight.WasPressed;
                    if (pressedLeft || pressedRight)
                    {
                        girlChoice = pressedLeft;
                    }
                    yield return(null);
                } while(girlChoice == null);
                Jukebox.Play("Pickup");
                isGirl = girlChoice.Value;
                if (girlChoice.Value)
                {
                    Hero.inst.SetGirl(true);
                }
                genderOp.enabled = false;
            }


            // TRANSITION IN "FRONT" / OUT LOGO
            var cp0 = credits.position;
            var cp1 = credits.position.Below(0.5f * CameraFX.inst.HalfHeight);

            foreach (var u in Interpolate(0.1f))
            {
                appearFx.localScale = Vec(baseScale.x, u * baseScale.y, baseScale.z);
                logo.position       = Vector3.Lerp(p0, p1, EaseOut2(u));
                credits.position    = Vector3.Lerp(cp0, cp1, EaseOut2(u));
                yield return(null);
            }
            logo.gameObject.SetActive(false);
            credits.gameObject.SetActive(false);
        }
        else
        {
            if (isGirl)
            {
                Hero.inst.SetGirl(true);
            }

            logo.gameObject.SetActive(false);
            credits.gameObject.SetActive(false);

            // TRANSITION IN "FRONT"
            foreach (var u in Interpolate(0.1f))
            {
                appearFx.localScale = Vec(baseScale.x, u * baseScale.y, baseScale.z);
                yield return(null);
            }
        }

        // SHOW THE PLAYER
        Hero.inst.gameObject.SetActive(true);
        Hero.inst.fx.SetColor(Color.white);

        CameraFX.inst.Flash(Color.white, 0.1f);
        CameraFX.inst.Shake();
        Jukebox.Play("AppearThump");
        yield return(new WaitForSeconds(0.1f));

        // TRANSITION IN "TAIL"
        appearFx.localPosition = appearFx.TransformPoint(Vec(0, 1, 0));
        appearFx.rotation      = appearFx.rotation * QRadians(Mathf.PI);


        foreach (var u in Interpolate(0.1f))
        {
            var v = u - 1f;
            appearFx.localScale = Vec(baseScale.x, v * baseScale.y, baseScale.z);
            yield return(null);
        }
        Hero.inst.fx.Flash(Color.white, 0.25f);

        if (firstTime)
        {
            // DIALOG SCENE
            Jukebox.Play("Warning");
            var dRoot = dialogSpr.transform;
            dRoot.parent = CameraFX.inst.xform;
            var p = dRoot.localPosition;
            p.x = 0;
            dialogSpr.enabled = true;
            foreach (var u in Interpolate(0.5f))
            {
                dialogSpr.color     = RGBA(Color.white, 1f - EaseOut2(u));
                dRoot.localPosition = Vector3.Lerp(p.Below(1f), p, EaseOutBack(u));
                yield return(null);
            }
            foreach (var spr in textSprites)
            {
                spr.enabled = true;
                Jukebox.Play("Beep1");
                foreach (var u in Interpolate(0.25f))
                {
                    spr.color = RGBA(1, 1, 1, u);
                    yield return(null);
                }
                for (var t = 0f; t < 4f; t += Time.deltaTime)
                {
                    if (GameInput.AnyPress)
                    {
                        break;
                    }
                    yield return(null);
                }
                foreach (var u in Interpolate(0.25f))
                {
                    spr.color = RGBA(1, 1, 1, 1f - u);
                    yield return(null);
                }
            }
            Jukebox.Play("Derp");
            foreach (var u in Interpolate(0.1f))
            {
                dRoot.localScale = Vec(1, 1 - EaseOut2(u), 1);
                //dRoot.localPosition = Vector3.Lerp(p.Below(1f), p, 1f-EaseOutBack(u));
                yield return(null);
            }

            Destroy(dialogSpr.gameObject);
        }

        // BEGIN INTERACTION
        Hero.inst.input.Unhalt();
        KillBar.inst.Unhalt();

        firstTime = false;


        Destroy(gameObject);
    }
Пример #27
0
    // Game logic

    public static void Run()
    {
        level = new Level();

        SetConsole(30, 120);

        //Load level
        level.Print();

        Mario NinjaMario = new Mario(5, 5);

        NinjaMario.Print();

        var enemies = GenerateEnemies();

        int counter = 0;

        Jukebox jk = new Jukebox(@"..\..\Music\Super_Mario_Bros_Official_Theme_Song.wav");

        jk.Play();

        // Game Flow
        while (true)
        {
            ConsoleKeyInfo keyPressed = GetKeyInfo();

            // clear the enemies
            if (counter % 2 == 0)
            {
                for (int i = 0; i < enemies.Count; i++)
                {
                    if (enemies[i].levelPosition == Level.levelCounter)
                    {
                        enemies[i].Clear();
                    }
                }
            }

            // clear mario
            NinjaMario.Clear();

            // handle jumping
            if (NinjaMario.isJumping)
            {
                // if left or right arrow has been pressed after jumping, modify the arc of the jump accordingly

                if ((NinjaMario.lastJumpKey == ConsoleKey.LeftArrow && keyPressed.Key == ConsoleKey.RightArrow) ||
                    (NinjaMario.lastJumpKey == ConsoleKey.RightArrow && keyPressed.Key == ConsoleKey.LeftArrow) ||
                    NinjaMario.lastJumpKey == ki.Key)
                {
                    NinjaMario.Jump(level, keyPressed.Key);
                }
                else
                {
                    NinjaMario.Jump(level, NinjaMario.lastJumpKey);
                }
            }
            else if (!NinjaMario.Collision("down", level) && !NinjaMario.isJumping)
            {
                // fall down
                NinjaMario.MoveDown(level);
            }

            // take action according to pressed key
            switch (keyPressed.Key)
            {
            case ConsoleKey.LeftArrow:     // move left
                NinjaMario.MoveLeft(level);
                break;

            case ConsoleKey.RightArrow:     // move right
                NinjaMario.MoveRight(level);
                break;

            case ConsoleKey.UpArrow:     // start jumping
                NinjaMario.isJumping = true;
                break;

            case ConsoleKey.Escape:

                Engine.GameIsOn = true;
                Menu.Display();
                SetConsole(30, 120);
                Console.Clear();
                level.Print();

                break;     // exit

            default: break;
            }

            // DUPKI MAINA
            if (NinjaMario.MarioInTheHole())
            {
                GameOver();
                break;
            }

            // move enemies
            if (counter++ % 2 == 0)
            {
                for (int i = 0; i < enemies.Count; i++)                 // for each enemy in the list
                {
                    if (enemies[i].levelPosition == Level.levelCounter) // if the enemy is to be displayed in that level
                    {
                        enemies[i].BounceHorizontal(level);



                        if (NinjaMario.isDead(enemies[i], level))
                        {
                            // Game over code here
                            GameOver();
                            Engine.GameIsOn = false;
                            return;
                        }

                        if (enemies[i].isEnemyDead(NinjaMario)) // mario has jumped on top of it
                        {
                            scoreCount++;
                            enemies[i].Clear();  // clear from console
                            enemies.RemoveAt(i); // remove from the list
                        }
                    }
                }
            }

            NinjaMario.Print();
            Thread.Sleep(50);
        }
    }
Пример #28
0
    public bool TryHit(Vector3 pos, Vector3 vel)
    {
        if (status == Status.Hit)
        {
            return(false);
        }

        var sfx = RNG.Range(1, 4);

        Jukebox.Play("victim_hit_" + sfx);


        dropShadow.enabled = false;

        status = Status.Hit;

        pos = transform.position;         // hack


        var sprites = gameObject.GetComponentsInChildren <SpriteRenderer>();

        shrapnel = new List <GameObject>(sprites.Length);

        foreach (var spr in sprites)
        {
            if (spr == dropShadow)
            {
                continue;
            }
            var xf     = spr.transform;
            var bounds = spr.bounds;

            var dup = Dup(spr.gameObject).transform;

            var sr         = dup.GetComponent <SpriteRenderer>();
            var deadSprite = ShrapnelRemapper.Get(sr.sprite);
            if (deadSprite != null)
            {
                sr.sprite = deadSprite;
            }

            var body = new GameObject("Shrapnel", typeof(Rigidbody), typeof(SphereCollider)).GetComponent <Rigidbody>();
            body.gameObject.layer = ShrapnelLayer;
            body.position         = 0.3f * xf.position + 0.7f * pos;
            body.rotation         = xf.rotation;

            body.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY;
            body.velocity    = vel;
            body.AddForce(Vec(RNG.Range(-3f, 3f), RNG.Range(8f, 12f), RNG.Range(0.5f, 2.5f)), ForceMode.Impulse);
            body.interpolation = RigidbodyInterpolation.Extrapolate;

            body.angularDrag     = 0.01f;
            body.drag            = 0.01f;
            body.angularVelocity = Vec(0, 0, RNG.Range(-0.4f, 0.4f));

            var sphere = body.GetComponent <SphereCollider>();
            sphere.radius         = 0.55f * Mathf.Min(bounds.size.x, bounds.size.y);
            sphere.sharedMaterial = shrapnelMat;

            dup.parent        = body.transform;
            dup.localScale    = xf.lossyScale;
            dup.localPosition = Vector3.zero;
            spr.enabled       = false;

            shrapnel.Add(body.gameObject);
        }
        return(true);
    }