コード例 #1
0
    private void SpawnCar(Vector3 velocity, int line, float dist, int id)
    {
        Vector3    spawnpos = spawnPoints[line].transform.position;
        Quaternion rotation;

        if (velocity.z == 0)
        {
            spawnpos.x -= dist;
            if (velocity.x > 0)
            {
                rotation = Quaternion.Euler(270, 0, 0);
            }
            else
            {
                rotation = Quaternion.Euler(270, 180, 0);
            }
        }
        else
        {
            spawnpos.z += dist;
            rotation    = carPrefab[id].transform.rotation;
        }

        spawnedCar[line] = Instantiate(carPrefab[id], spawnpos, rotation) as GameObject;
        BckgrndCar bckgrndCar = spawnedCar[line].AddComponent <BckgrndCar>();

        bckgrndCar.velocity = velocity;
        bckgrndCar.startPos = transform.position;
        spawnedCar[line].transform.parent = transform;
        spawnedCar[line].tag = "Car";
    }
コード例 #2
0
ファイル: PlayerMove.cs プロジェクト: NGdev1/AnimalRun
    IEnumerator stopSwim(float z)
    {
        StatePoint = 0; State = eState.Stay;
        Vector3 newpos = new Vector3(spawnPoints[StatePoint], player.position.y, player.position.z - 20f);

        player.position = newpos;

        areaSp.RightFromWaterToRoute(z);
        areaSp.Pause();

        gameOver = true;
        smoothFollow2D.toFloatTarget();
        smoothFollow2D.smoothTime /= 3;

        if (fromWaterToRoadAnim != null)
        {
            if (boat.animation)
            {
                boat.animation.Play("fromWaterToRoad");
            }

            anim.Play(fromWaterToRoadAnim.name, PlayMode.StopAll);
            yield return(new WaitForSeconds(fromWaterToRoadAnim.length));
        }
        else
        {
            BckgrndCar.DeleteAllBckgrndCars();
        }

        GameObject.Destroy(boat);

        gameOver = false;
        smoothFollow2D.toFixedTarget();
        smoothFollow2D.smoothTime *= 3;

        jetpack    = false;
        jump       = false;
        inTheWater = false;
        gravity    = 35;
        WalkSpeed *= 3;

        duckSpawner.StopSpawningDucks();

        anim.Play(animations[0].name);

        newpos.y        = 0.1f;
        newpos.z       += 20f;
        player.position = newpos;

        duckSpawner.changeBird(true);

        areaSp.Continue();
        sc.EnableFlyButton();
    }
コード例 #3
0
ファイル: PlayerMove.cs プロジェクト: NGdev1/AnimalRun
    private void Right(string commandName, float Zpos)
    {
        prepareToRotate(Zpos);

        if (commandName == "RightWater")
        {
            StartCoroutine(swim(Zpos));

            areaSp.RightWater(Zpos);
            carSp.RightWater();
        }
        else if (commandName == "RightFromWaterToRoute")
        {
            StartCoroutine(stopSwim(Zpos));

            //BckgrndCars.canSpawn = false;
            BckgrndCar.DeleteAllBckgrndCarSpawners();

            //areaSp.RightFromWaterToRoute(Zpos);
            carSp.RightFromWaterToRoute();
        }
        else if (commandName == "RightForest")
        {
            areaSp.RightForest(Zpos);
            carSp.Right();
        }
        else
        {
            areaSp.Right(Zpos);
            carSp.Right();
        }

        nextRotation    = pivot.rotation.eulerAngles;
        nextRotation.y -= 90;
        nextRotation    = Quaternion.Euler(nextRotation).eulerAngles;

        rotState = eState.WalkRight;
    }