Example #1
0
 void OnTriggerEnter2D(Collider2D collider)
 {
     if (collider.tag == "Fish" || collider.tag == "unusual")
     {
         if (!ProgressManager.Instance.isOvering && !ProgressManager.Instance.isReady)
         {
             if (collider.tag == "unusual")
             {
                 MultiHaptic.HapticHeavy();
                 //ScoreGenerate (collider.transform);
                 collider.GetComponent <GhostSprites> ().alphaFluctuationOverride = 0.15f;
                 //Destroy( collider.GetComponent<GhostSprites> ());
             }
             if (ProgressManager.Instance.isRunning)
             {
                 MultiHaptic.HapticLight();
                 ScoreGenerate(collider.transform, new Vector3(0, 200, 0));
                 collider.transform.position = new Vector3(transform.position.x + Random.Range(-0.8f, 0.8f), transform.position.y + 0.2f + Random.Range(-0.5f, 0.4f), 0.5f);
                 collider.transform.SetParent(transform);
             }
             else if (ProgressManager.Instance.isOver)
             {
                 MultiHaptic.HapticLight();
                 ScoreGenerate(collider.transform, new Vector3(0, 0, 0));
                 collider.transform.position = new Vector3(transform.position.x + Random.Range(-0.8f, 0.8f), transform.position.y - 0.4f + Random.Range(0.4f, 0.9f), 0.5f);
                 collider.transform.SetParent(transform);
             }
         }
     }
 }
Example #2
0
	//飞机旋转
	IEnumerator AddPlaneSpeed(){	
		if (onAir) {				
			MultiHaptic.HapticHeavy ();
			transform.DORotate (new Vector3 (12, transform.eulerAngles.y, transform.eulerAngles.z), 1f, RotateMode.Fast);
			flipDiamond = true;
			Physics.gravity = new Vector3 (0, 0, 0);
			while (true) {				
				rig.velocity = Vector3.Lerp (rig.velocity, new Vector3 (rig.velocity.x, 2, rig.velocity.z), Time.deltaTime * 8);
				if (Vector3.Distance (rig.velocity, new Vector3 (rig.velocity.x, 2, rig.velocity.z)) < 0.5f) {
					yield return new WaitForSeconds (0.5f);
					rig.velocity = new Vector3 (rig.velocity.x, 0, rig.velocity.z);
					float flipTime = 1;
					if (shootForce <= 0.43f) {
						flipTime *= shootForce / 0.43f * 0.5f + 0.5f;
					} else {
						flipTime *= (shootForce-0.43f) / (1 - 0.43f) * 0.5f + 1;
					}
					yield return new WaitForSeconds ((PlayerPrefs.GetInt ("flip_level", 0))*0.3f*3*flipTime+perfectAdd);
					flipDiamond = false;
					break;
				}
				yield return null;
			}
		}
		Physics.gravity = new Vector3 (0, -3, 0);
		addPlaneSpeedSwitch = false;

	}
Example #3
0
	void OnCollisionEnter(Collision coll){
		StartCoroutine (StopPerfectTril ());
		useFlip = false;
		onAir = false;
		if (!settle.activeSelf) {
			isOver = true;
		}
		EndPlane ();
		//rig.constraints = RigidbodyConstraints.FreezeAll;
		//Physics.gravity = new Vector3 (0, -2, 0);
		MultiHaptic.HapticHeavy ();
		CameraRotate.Instance.target = realPlane;
		StartCoroutine (CheckGameover ());
	}
Example #4
0
    //被拳头打死
    void GameOverByBoxglove(Vector3 golvePos)
    {
        //在死亡状态或待机状态不作处理
        if (GameState == 3 || GameState == 0)
        {
            return;
        }
        isRotate = false;
        HidePower(true);
        //状态变为死亡状态,解放主角,被打方向施加力,随机旋转,三秒后重置游戏
        GameState       = 3;
        rig.constraints = RigidbodyConstraints.None;
        Vector3 carDirection = (transform.position - golvePos).normalized;

        rig.AddForce((carDirection + transform.up) * carForce, ForceMode.Force);
        Instantiate(hitPs, transform.position + new Vector3(0, 3, 0), Quaternion.identity);
        //rig.AddForce(Vector3.up* carForce*1.3f, ForceMode.Force);
        //transform.DOLocalRotate(new Vector3(Random.Range(0,360), Random.Range(0,360), Random.Range(0,360)), 0.2f, RotateMode.WorldAxisAdd);
        rig.AddTorque(new Vector3(Random.Range(0, 360), Random.Range(0, 360), Random.Range(0, 360)), ForceMode.Force);
        Invoke("ReGame", 3);
        //在主角位置生成拳套,面向主角出拳
        boxGloveTrans    = Instantiate(boxGlove, transform.position, Quaternion.identity).transform;
        boxGloveTrans.up = carDirection;
        //boxGloveTrans.up = Vector3.up;
        boxGloveTrans.DOMove(transform.position + Vector3.up * 3, 0.3f, false);
        //取消警告
        alarm.gameObject.SetActive(false);

        PlayerPrefs.SetInt("GloveHit", PlayerPrefs.GetInt("GloveHit", 0) + 1);

        if (tempText)
        {
            Destroy(tempText);
        }

        dailyTimes++;
        if (dailyTimes >= 3)
        {
            Invoke("ShowDaily", 3);
        }
        if (PlayerPrefs.GetInt("vibration", 1) == 1)
        {
            MultiHaptic.HapticHeavy();
        }
    }
Example #5
0
	public void OnStartBtn(){
		skill.gameObject.SetActive (false);
		personAnimator.avatar = null;
		onAir = true;
		personAnimator.runtimeAnimatorController = throwPlane;
		//Invoke ("Shootplane", (5/6f/1.7f));
		float levelAddtion = 1 + ((PlayerPrefs.GetInt ("level", 1) - 1) * 3) / 100f;
		StartCoroutine (CheckVelociy ());
		StartCoroutine (CorrectionPlane());
		MultiHaptic.HapticHeavy ();
		pointer.StopPoint ();
		//transform.eulerAngles = new Vector3 (10, shootRotation, 0);
		if (shootForce >= 0.88f) {
			TipPop.GenerateTip (perfectWords [Random.Range (0, 4)], 0.5f);
			StartCoroutine (PerfectShoot ());
			Invoke ("Shootplane", (5/6f/1.8f));
			perfectAdd = 1.5f;
		} else {
			if (shootForce <= 0.4f) {
				//TipPop.GenerateTip (badWords [Random.Range (0, 4)], 0.5f);
				perfectAdd = -0.5f;
			} else {
				TipPop.GenerateTip (goodWords [Random.Range (0, 4)], 0.5f);
			}
			Invoke ("Shootplane", (5/6f/1.7f));
			//StartCoroutine (NormalParticle ());
			//personPlane.DOPunchScale(personPlane.localScale*2,0.5f,10,1);
		}

		float perfectTime = (PlayerPrefs.GetInt ("power_level", 0)) * 0.6f *3 * levelAddtion;
		if (shootForce <= 0.43f) {
			perfectTime *= shootForce / 0.43f * 0.5f + 0.5f;
		} else {
			perfectTime *= (shootForce-0.43f) / (1 - 0.43f) * 0.5f + 1;
		}
		StartCoroutine (GravityVary (0.4f+perfectTime+perfectAdd));
		StartCoroutine (StopTimeScale ((0.4f + perfectTime + perfectAdd) * 0.8f+1.7f));
		Invoke ("CameraStartRotate", 2);
	}
Example #6
0
    //碰撞处理
    //跳跃状态才能碰撞
    //撞到一般物体加少量分数,若超过目标点则生成新的目标点,进入待机状态,生成分数
    //身体先发生碰撞则判定死亡
    private void OnCollisionEnter(Collision coll)
    {
        //离开黑洞后状态为进入新关卡,此时若碰到一般建筑则...
        if (GameState == 7 && coll.collider.tag == "Untagged")
        {
            transform.position = targetStartPos.position;
            rig.constraints    = RigidbodyConstraints.FreezeAll;
            //状态变为待机,播放待机动画
            GameState = 0;
            animator.SetBool("Idle", true);
            SetJumpBool(false);
            //如果是进入新关卡则增加关卡数并刷新关卡UI
            if (Level.Instance.slider.value == 1)
            {
                int curMapIndex = PlayerPrefs.GetInt("CurMap", 0);
                PlayerPrefs.SetInt("Level" + curMapIndex, PlayerPrefs.GetInt("Level" + curMapIndex, 1) + 1);
                Level.Instance.UpdateLevel();

                if (PlayerPrefs.GetInt("Level" + curMapIndex, 1) >= 10 && PlayerPrefs.GetInt("TurnHomeFinish", 0) == 0)
                {
                    TurntableGuide.Instance.StartGuide();
                }
                if (PlayerPrefs.GetInt("Level" + curMapIndex, 1) >= 20 && PlayerPrefs.GetInt("MapHomeFinish", 0) == 0)
                {
                    MapGuide.Instance.StartGuide();
                }
                if (PlayerPrefs.GetInt("SkillFinish", 0) == 0)
                {
                    int gold     = PlayerPrefs.GetInt("Gold", 0);
                    int needGold = PlayerPrefs.GetInt("SkillGold0", 281);
                    if (needGold == 281)
                    {
                        if (gold >= needGold)
                        {
                            SkillGuide.Instance.StartGuide();
                        }
                    }
                    else
                    {
                        PlayerPrefs.SetInt("SkillFinish", 1);
                    }
                }
            }
            //生成新环
            RadarScan();
            //显示关卡UI
            HideGameUI(false);
            HideMoneyUI(false);

            if (tempText)
            {
                TipPop.GenerateTip("X5", 0.7f, Color.yellow);
                Destroy(tempText, 0.5f);
                PlayerPrefs.SetInt("LevelPassGold", curGold * 5);
                Gold.Instance.GetGold(curGold * 5);
                MoneyManager.Instance.UpdateGold();
                couldShowDoubl = true;
                TipPop.GenerateTipPerfect("level up", 1f, Color.yellow);
            }
        }

        //如果是跳跃状态
        if (GameState == 2)
        {
            //如果碰到了一般建筑
            if (coll.collider.tag == "Untagged")
            {
                float playerEulerX = transform.eulerAngles.x;
                //if((eulurX%360)>=295&&(eulurX%360)<=360){
                //if ((playerEulerX > 325 && playerEulerX < 360) || (playerEulerX > 0 && playerEulerX < 50)) {
                //获得当前碰撞的点
                currentColl = coll.contacts [0].point;
                //检查射线下是否有环
                CheckRingByRay();
                //等待一段时间根据环生成分数,生成新的环
                Invoke("ScoreGenerate", 0.05f);
                Invoke("GenerateNewRing", 0.1f);
                //一段时间后锁定主角
                rig.constraints = RigidbodyConstraints.FreezeAll;

                //} else {
                //	GameOverByBoxglove (currentColl);
                //	TipPop.GenerateTip ("MISS", 0.5f);
                //GameOverByBoxglove (transform.position + new Vector3 (0, -5, 0));
                //}
            }
        }

        //如果蓄力过度则被拳头打飞
        if (GameState == 10)
        {
            //GameOverByBoxglove (transform.position + new Vector3 (0, -5, 0));
        }

        //如果被车撞了,状态变为被车撞,解除主角限制,往被撞的方向施加力,给予主角随机旋转,三秒后重开游戏
        if (coll.collider.tag == "car" && GameState != 9)
        {
            isRotate = false;
            HidePower(true);
            GameState       = 9;
            rig.constraints = RigidbodyConstraints.None;
            Vector3 carDirection = (transform.position - coll.transform.position).normalized;
            rig.AddForce((carDirection + transform.up) * carForce, ForceMode.Force);
            Instantiate(hitPs, transform.position + new Vector3(0, 3, 0), Quaternion.identity);
            transform.DOLocalRotate(new Vector3(Random.Range(0, 360), Random.Range(0, 360), Random.Range(0, 360)), 1.5f, RotateMode.LocalAxisAdd);
            Invoke("ReGame", 3);
            PlayerPrefs.SetInt("CarHit", PlayerPrefs.GetInt("CarHit", 0) + 1);
            if (PlayerPrefs.GetInt("vibration", 1) == 1)
            {
                MultiHaptic.HapticHeavy();
            }
            if (tempText)
            {
                Destroy(tempText);
            }
            dailyTimes++;
            if (dailyTimes >= 3)
            {
                Invoke("ShowDaily", 3);
            }
        }
    }