예제 #1
0
    void Fly()
    {
        flySpeed.y     -= curFallSpeed;
        curFallSpeed   += fallSpeed;
        bodyRb.velocity = flySpeed;
        if (bodyRb.velocity.y < 0)
        {
            if (transform.position.y - curFallSpeed * Time.deltaTime <= 0.6f) //0.5 is hardcode ground height
            {
                Vector3 curPos = transform.position;
                curPos.y           = 0.5f;
                transform.position = curPos;
                Collider[] smashTargets = Physics.OverlapSphere(transform.position, transform.localScale.x * 0.6f, smashTargetLayer);
                foreach (Collider col in smashTargets)
                {
                    col.transform.GetComponent <humanCtrl>().Death();
                }
                screenShake.shakecoefficient = 0.1f + Mathf.Log10(curFallSpeed);
                screenShake.StopScreen(0.03f);
                isDeath = true;
                Instantiate(bloodParticle, bloodParticlePos.position, bloodParticlePos.rotation);
                GameObject.Find("Second Camera").GetComponent <followAst>().Dismiss();
                GameObject.Find("MouseCtrl").GetComponent <mouseCtrl>().RestartAimming();

                BackgroundSetting.SetCurHeight(0);
                BackgroundSetting.CheckStep();

                Destroy(gameObject);
                return;
            }
        }
        else
        {
            //Debug.Log(Mathf.Max(Mathf.RoundToInt(transform.position.y - height), 0));
            BackgroundSetting.SetCurHeight(Mathf.Max(Mathf.RoundToInt(transform.position.y - height), 0));
            if (!BackgroundSetting.gameEnded && BackgroundSetting.highestHeight > BackgroundSetting.stepStoneTarget[4])
            {
                BackgroundSetting.EndTheGame(gameObject);
                gameObject.name = "arrivedHuman";
                DontDestroyOnLoad(this);
                isLoaded           = false;
                bodyRb.isKinematic = true;
            }
        }
    }
예제 #2
0
 // Use this for initialization
 void Awake()
 {
     ground            = transform.Find("ground");
     wallUp            = transform.Find("wallUp");
     wallDown          = transform.Find("wallDown");
     wallRight         = transform.Find("wallRight");
     wallLeft          = transform.Find("wallLeft");
     wallUpRb          = wallUp.GetComponent <Rigidbody>();
     wallDownRb        = wallDown.GetComponent <Rigidbody>();
     wallRightRb       = wallRight.GetComponent <Rigidbody>();
     wallLeftRb        = wallLeft.GetComponent <Rigidbody>();
     wallUpPos         = wallUp.localPosition;
     wallDownPos       = wallDown.localPosition;
     wallRightPos      = wallRight.localPosition;
     wallLeftPos       = wallLeft.localPosition;
     wallUpStartPos    = wallUp.localPosition;
     wallDownStartPos  = wallDown.localPosition;
     wallRightStartPos = wallRight.localPosition;
     wallLeftStartPos  = wallLeft.localPosition;
     curGroundSize     = (int)ground.transform.localScale.x;
     curWallLength     = curGroundSize / 2 - curWallThick;
     //SetUpTarget(new Vector3(0,0,0));
     mouseScript   = GameObject.Find("MouseCtrl").GetComponent <mouseCtrl>();
     normalHuamn   = Resources.Load <Transform>("Human/NormalHuman");
     thinHuman     = Resources.Load <Transform>("Human/ThinHuman");
     fuelTankHuman = Resources.Load <Transform>("Human/FuelTankHuman");
     skinCount     = skin.Length;
     clothingCount = clothing.Length;
     shoeCount     = shoe.Length;
     spawnPos.y    = wallUp.localPosition.y + 3f;
     //humanSpawnScript = GetComponent<humanSpawning>();
     StartCoroutine("humanSpawningLoop");
     BackgroundSetting.curStep = 0;
     BackgroundSetting.CheckStep();
     audioS = GetComponent <AudioSource>();
 }