コード例 #1
0
    IEnumerator CameraShake(float magnitude, float speed, float duration, bool damp)
    {
        cameraShakePosition = Vector3.zero;

        Vector3 targetPosition = cameraShakePosition;

        float shakeStartTime = Time.time;

        while (!SuperMath.Timer(shakeStartTime, duration))
        {
            cameraShakePosition = Vector3.MoveTowards(cameraShakePosition, targetPosition, speed * Time.deltaTime);

            float magModifier = 1.0f - Mathf.InverseLerp(shakeStartTime, shakeStartTime + duration, Time.time);

            if (cameraShakePosition == targetPosition)
            {
                targetPosition = Vector3.zero + Random.insideUnitSphere * magnitude * magModifier;
            }

            yield return(0);
        }

        while (cameraShakePosition != Vector3.zero)
        {
            cameraShakePosition = Vector3.MoveTowards(cameraShakePosition, Vector3.zero, speed * Time.deltaTime);

            yield return(0);
        }
    }
コード例 #2
0
 void OnTriggerEnter(Collider col)
 {
     if (SuperMath.Timer(spawnTime, InvinciblePeriod) && col.gameObject.tag == "Player")
     {
         Death();
     }
 }
コード例 #3
0
    protected override void LateGlobalSuperUpdate()
    {
        base.LateGlobalSuperUpdate();

        if (fuseLit)
        {
            windRotation = SuperMath.ClampAngle(windRotation + 1000.0f * Time.deltaTime);
        }
        else
        {
            windRotation = SuperMath.ClampAngle(windRotation + 360.0f * Time.deltaTime);
        }

        WindTransform.Rotation = Quaternion.Euler(new Vector3(0, 0, windRotation));

        if (fuseLit)
        {
            if (SuperMath.Timer(fuseLitTime, FuseTimer))
            {
                AnimatedMesh.localScale = Vector3.MoveTowards(AnimatedMesh.localScale, initialScale * 2.0f, 10.0f * Time.deltaTime);
            }

            if (SuperMath.Timer(fuseLitTime, FuseTimer + 0.1f))
            {
                currentState = BobOmbStates.Explode;
                return;
            }
        }
    }
コード例 #4
0
ファイル: GameMaster.cs プロジェクト: fuhongxuezr/zmario
    void Update()
    {
        if (inputManager.PauseDown())
        {
            if (paused)
            {
                Unpause();
            }
            else
            {
                Pause();
            }
        }

        if ((float)MusicSource.timeSamples / (float)MusicSource.clip.frequency > 140.7f)
        {
            MusicSource.timeSamples = (int)(72.775f * MusicSource.clip.frequency);
        }

        if (DebugGUI && SuperMath.Timer(lastFrameRateUpdate, 0.25f))
        {
            lastFrameRateUpdate = Time.time;
            FramerateText.text  = (1.0f / Time.deltaTime).ToString("F0");
        }
    }
コード例 #5
0
ファイル: BobOmbExplosion.cs プロジェクト: fuhongxuezr/zmario
    void Update()
    {
        if (SuperMath.Timer(startTime, Delay))
        {
            // Haha I still can't get over "PlayerMask"
            Collider[] cols = Physics.OverlapSphere(transform.position, Radius);

            foreach (var col in cols)
            {
                if (col.gameObject.tag == "Player")
                {
                    col.gameObject.GetComponent <MarioMachine>().HeavyDamage(2, transform.position);
                }

                var trigger = col.gameObject.GetComponent <TriggerableObject>();

                if (trigger)
                {
                    trigger.Explosion();
                }

                var machine = col.gameObject.GetComponent <EnemyMachine>();

                if (machine)
                {
                    machine.Explosion();
                }
            }
        }
    }
コード例 #6
0
    void Exploding_Update()
    {
        Shadow.Scale = Art.localScale.x;

        if (SuperMath.Timer(timeEnteredState, Art.GetComponent <Animation>()["explode"].length))
        {
            Death();
        }
    }
コード例 #7
0
    void Knockback_SuperUpdate()
    {
        moveDirection -= controller.up * KnockbackGravity * Time.deltaTime;

        if (SuperMath.Timer(struckTime, 0.2f) && controller.collisionData.Count > 0)
        {
            currentState = BobOmbStates.Explode;
            return;
        }
    }
コード例 #8
0
    void OnTriggerStay(Collider col)
    {
        if (col.gameObject.tag == "Player" && SuperMath.Timer(lastSpawnTime, ReloadTime))
        {
            Vector3 targetPosition = col.transform.position + Math3d.ProjectVectorOnPlane(Vector3.up, col.GetComponent <MarioMachine>().Velocity());

            Instantiate(WaterBomb, targetPosition + Height * Vector3.up, Quaternion.identity);

            lastSpawnTime = Time.time;
        }
    }
コード例 #9
0
    public override bool GroundPound()
    {
        if (SuperMath.Timer(lastPounded, 0.4f) && currentPounds < MaxPounds)
        {
            Drop();

            lastPounded = Time.time;

            return(true);
        }

        return(false);
    }
コード例 #10
0
ファイル: MarioSound.cs プロジェクト: fuhongxuezr/zmario
    IEnumerator Footsteps(float speed, float delay)
    {
        float lastStepTime = Time.time - speed + delay;

        while (true)
        {
            if (SuperMath.Timer(lastStepTime, speed))
            {
                SoundSource.PlayOneShot(Footstep, 0.07f);
                lastStepTime = Time.time;
            }

            yield return(0);
        }
    }
コード例 #11
0
    public override bool StandingOn(Vector3 position)
    {
        if (SuperMath.Timer(lastSpringTime, 1.0f))
        {
            AnimatedMesh.GetComponent <Animation>().Play();

            GameObject.FindGameObjectWithTag("Player").GetComponent <MarioMachine>().MegaSpring(transform.forward, velocity, lift);

            GetComponent <AudioSource>().Play();

            lastSpringTime = Time.time;
        }

        return(false);
    }
コード例 #12
0
    void Spring_Update()
    {
        Shadow.Scale = Art.localScale.x;

        if (SuperMath.Timer(timeEnteredState, Art.GetComponent <Animation>()["spring"].length))
        {
            moveDirection = (Target.position - transform.position).normalized * BounceSpeed;

            moveDirection += SuperMath.CalculateJumpSpeed(BounceHeight, Gravity) * Vector3.up;

            currentState = WaterBombStates.Bounce;

            return;
        }
    }
コード例 #13
0
ファイル: KingBobOmbMachine.cs プロジェクト: play3577/SM64HDR
    protected override void LateGlobalSuperUpdate()
    {
        //print (this.transform.position.x);
        //	print (this.transform.position.y);
        //	print (this.transform.position.z);
        hurtPlayer();
        if (GameObject.FindObjectOfType <GameMaster> ().raceStarted == true)
        {
            Destroy(gameObject);
        }
        if (animT)
        {
            //print ("cunzais");
        }
        else
        {
            //print ("bu");
        }
        animT.wrapMode = WrapMode.Loop;
        //animT.CrossFade ("walking_inPlace");
        //Debug.Log ("animated");
        base.LateGlobalSuperUpdate();

        if (fuseLit)
        {
            windRotation = SuperMath.ClampAngle(windRotation + 1000.0f * Time.deltaTime);
        }
        else
        {
            windRotation = SuperMath.ClampAngle(windRotation + 360.0f * Time.deltaTime);
        }


        if (fuseLit)
        {
            if (SuperMath.Timer(fuseLitTime, FuseTimer))
            {
                AnimatedMesh.localScale = Vector3.MoveTowards(AnimatedMesh.localScale, initialScale * 2.0f, 10.0f * Time.deltaTime);
            }

            if (SuperMath.Timer(fuseLitTime, FuseTimer + 0.1f))
            {
                currentState = BobOmbStates.Explode;
                return;
            }
        }
    }
コード例 #14
0
    IEnumerator Footsteps()
    {
        float speed = 0.15f;

        float lastStepTime = Time.time - speed;

        while (true)
        {
            if (SuperMath.Timer(lastStepTime, speed))
            {
                GetComponent <AudioSource>().PlayOneShot(Footstep, 0.5f);
                lastStepTime = Time.time;
            }

            yield return(0);
        }
    }
コード例 #15
0
ファイル: BlueSwitch.cs プロジェクト: play3577/SM64HDR
    public override bool GroundPound()
    {
        if (SuperMath.Timer(lastPounded, 0.4f) && currentPounds < 1)
        {
            lastPounded = Time.time;

            Drop();

            for (int i = 0; i < Coin.Length; i++)
            {
                Coin [i].SetActive(true);
            }

            return(true);
        }

        return(false);
    }
コード例 #16
0
    void Attack_SuperUpdate()
    {
        if (!IsGrounded(0.5f, true))
        {
            currentState = GoombaStates.Fall;
            return;
        }

        if (Attack(8.0f))
        {
            currentState = GoombaStates.Alert;
            return;
        }

        Vector3 direction = target.position - transform.position;

        direction = Math3d.ProjectVectorOnPlane(controller.up, direction);

        float distance = Vector3.Distance(target.position, transform.position);

        if (distance > MaintainSightDistance)
        {
            currentState = GoombaStates.Wander;
            return;
        }

        if (Vector3.Angle(direction, lookDirection) < FieldOfView)
        {
            lastSeenTime = Time.time;
        }

        if (SuperMath.Timer(lastSeenTime, ResumeWanderTime))
        {
            currentState = GoombaStates.Wander;
            return;
        }

        lookDirection = Vector3.RotateTowards(lookDirection, direction, 70 * Mathf.Deg2Rad * Time.deltaTime, 0);

        moveSpeed = Mathf.MoveTowards(moveSpeed, AttackSpeed, 5.0f * Time.deltaTime);

        moveDirection = lookDirection * moveSpeed;
    }
コード例 #17
0
    void Update()
    {
        print(currentRed);
        //Instantiate(Appear,new Vector3(59,3,67), Quaternion.identity);
        if (currentCoins >= GoldMarioCoinAmount && redCoinStarCount == 0)
        {
            Instantiate(Appear, new Vector3(59, 3, 67), Quaternion.Euler(new Vector3(270, 90, 90)));
            SoundSource.PlayOneShot(StarAppear);
            redCoinStarCount += 1;
        }
        if (currentRed == 8)
        {
            Instantiate(Appear, new Vector3(57, 10.26f, 21.15f), Quaternion.Euler(new Vector3(270, 90, 90)));
            SoundSource.PlayOneShot(StarAppear);
            currentRed++;
        }
        if (inputManager.PauseDown())
        {
            if (paused)
            {
                Unpause();
            }
            else
            {
                Pause();
            }
        }

        if ((float)MusicSource.timeSamples / (float)MusicSource.clip.frequency > 140.7f)
        {
            MusicSource.timeSamples = (int)(72.775f * MusicSource.clip.frequency);
        }

        if (DebugGUI && SuperMath.Timer(lastFrameRateUpdate, 0.25f))
        {
            lastFrameRateUpdate = Time.time;
            FramerateText.text  = (1.0f / Time.deltaTime).ToString("F0");
        }
    }
コード例 #18
0
    void FixedUpdate()
    {
        if (Mathf.Abs(currentRotation) > MaxTilt - TiltSlowBarrier && Mathf.Sign(currentSpeed) == Mathf.Sign(currentRotation))
        {
            currentSpeed = Mathf.MoveTowards(currentSpeed, 0, TiltDecceleration * Time.fixedDeltaTime);
        }

        if (Mathf.Abs(currentRotation) > MaxTilt && Mathf.Sign(currentSpeed) == Mathf.Sign(currentRotation))
        {
            currentSpeed    = 0;
            currentRotation = MaxTilt * Mathf.Sign(currentRotation);
            GetComponent <AudioSource>().Stop();
        }

        if (currentRotation != 0 && SuperMath.Timer(lastTiltTime, tiltSlowTime))
        {
            var lerpValue = Mathf.InverseLerp(0, TiltSlowBarrier * Mathf.Sign(currentRotation), currentRotation);
            var tiltSpeed = Mathf.Lerp(0, TiltSpeed, lerpValue);

            currentSpeed = Mathf.MoveTowards(currentSpeed, tiltSpeed * -Mathf.Sign(currentRotation), TiltDecceleration * Time.fixedDeltaTime);

            if (Mathf.Abs(currentRotation) < 0.1f)
            {
                currentRotation = 0;
            }
        }

        if (currentRotation == 0)
        {
            GetComponent <AudioSource>().Stop();
        }

        currentRotation += currentSpeed * Time.fixedDeltaTime;

        Bridge.rotation = Quaternion.AngleAxis(currentRotation, Bridge.right) * initialRotation;
    }
コード例 #19
0
ファイル: GameMaster.cs プロジェクト: play3577/SM64HDR
//	public void starCollect(int ID){
//		if (currentStarID == 0){
//			AddStar ();
//			starCollected [currentStarID] = ID;
//			currentStarID ++;
//		} else {
//			for (int i = 0; i < scanLength; i++) {
//				if (ID == starCollected [i]) {
//					AddCollectedStar ();
//					starAction = true;
//					print ("detected");
//				}
//			}
//			if (!starAction) {
//				AddStar ();
//				starAction = true;s
//			}
//		}
//	}

    void Update()
    {
        starTextHandler.UpdateValue(currentStars);
        livesTextHandler.UpdateValue(currentLives);
        if (!wf && !ps)
        {
            if (GameObject.FindObjectOfType <MarioMachine> ().transform.position.y <= -10 && overed == 0)
            {
                GameOver();
                overed++;
            }
        }
        else if (wf && !ps)
        {
            if (GameObject.FindObjectOfType <MarioMachine> ().transform.position.y <= -10 && overed == 0)
            {
                GameOver();
                overed++;
            }
        }
        else if (ps)
        {
            if (GameObject.FindObjectOfType <MarioMachine> ().transform.position.y <= 0 && overed == 0)
            {
                GameOver();
                overed++;
            }
        }
        if (currentCoins >= GoldMarioCoinAmount && redCoinStarCount == 0)
        {
            //AppearCoin.SetActive(true);
            AppearCoinRender.enabled = true;
            Instantiate(AppearCoin, new Vector3(MarioTransform.position.x, MarioTransform.position.y + 2.2f, MarioTransform.position.z), Quaternion.Euler(new Vector3(270, 90, 90)));
            if (redCoinStarCount == 0)
            {
                SoundSource.PlayOneShot(StarAppear);
            }
            redCoinStarCount += 1;
        }
        if (currentRed == 8)
        {
            // Instantiate(Appear, new Vector3(57, 10.26f, 21.15f), Quaternion.Euler(new Vector3(270, 90, 90)));
            AppearRed.SetActive(true);
            SoundSource.PlayOneShot(StarAppear);
            currentRed++;
        }
        //print (wf);

        if (currentRing == 5)
        {
            //AppearRing.SetActive (true);
            Instantiate(Appear, new Vector3(50.7f, 15, -12.65f), Quaternion.Euler(new Vector3(270, 90, 90)));
            SoundSource.PlayOneShot(StarAppear);
            currentRing++;
        }

        if (enterCastle == true)
        {
            if (enterPlay == 0)
            {
                SoundSource.PlayOneShot(enterSound);
                enterPlay++;
            }
            MarioIn.enabled = false;
            TeleportToInsideCastle();
            //ExitToMainMenu ();
        }

        if (exitCastle == true)
        {
            if (enterPlay == 0)
            {
                SoundSource.PlayOneShot(enterSound);
                enterPlay++;
            }
            MarioIn.enabled = false;
            TeleportToOutsideCastle();
            //ExitToMainMenu ();
        }

        if (bobOmbEnter == true)
        {
            if (enterPlay == 0)
            {
                SoundSource.PlayOneShot(enterSound);
                enterPlay++;
            }
            MarioIn.enabled = false;
            TeleportToBobombBattlefield();
            GameObject.FindObjectOfType <MarioVerySmartCamera>().canMove = false;
        }

        if (whompsEnter == true)
        {
            if (enterPlay == 0)
            {
                SoundSource.PlayOneShot(enterSound);
                enterPlay++;
            }
            MarioIn.enabled = false;
            TeleportToWhompsFortress();
            GameObject.FindObjectOfType <MarioVerySmartCamera>().canMove = false;
        }

        if (inputManager.PauseDown() && pausable == true)
        {
            if (paused)
            {
                Unpause();
            }
            else
            {
                Pause();
            }
        }
        if ((float)MusicSource.timeSamples / (float)MusicSource.clip.frequency > 140.7f)
        {
            MusicSource.timeSamples = (int)(72.775f * MusicSource.clip.frequency);
        }

        if (DebugGUI && SuperMath.Timer(lastFrameRateUpdate, 0.25f))
        {
            lastFrameRateUpdate = Time.time;
            FramerateText.text  = (1.0f / Time.deltaTime).ToString("F0");
        }
        for (int i = 0; i < scanLength; i++)
        {
            starCollected[i] = stats.deadStars[i];
        }
    }