Example #1
0
 // Use this for initialization
 void Start()
 {
     _hazardSpawner = GameObject.Find("Hazard Spawner").GetComponent <HazardSpawner>();
     _nextSpawn     = Time.timeSinceLevelLoad;
     Messenger.AddListener(GameConstants.GameEvents.PLAYER_COLLISION_HAZARD, OnPlayerHazardCollision);
     Messenger.AddListener(GameConstants.GameEvents.PLAYER_Out_Of_Road, OnPlayerOutOfRoad);
 }
Example #2
0
    void Start()
    {
        var time          = GetTime();
        var randomService = new RandomFloat(new System.Random());
        var collisions    = GetCollisions();

        //Create the Hazard Spawner
        var hazardSpawner = new HazardSpawner(
            time,
            spawnInterval,
            randomService,
            minHazardHeight,
            maxHazardHeight,
            initialPosition,
            hazardSpeed
            );

        //Initialize Bird
        bird.Setup(time, collisions);

        //When a collision event occurs, the hazard spawner stop spawning hazards
        collisions.Subscribe(collisionEvent => hazardSpawner.Stop());

        //Every time the HazardSpawner spawns a hazar, create a hazard view
        hazardSpawner.Hazards.Subscribe(hazard => CreateHazard(hazard, collisions));
    }
Example #3
0
    public void Initialize(HazardSpawner hazardSpawner, int level, Vector3 pos, PlayerID owner = PlayerID.NP, float dir = 1)
    {
        spawner = hazardSpawner;

        if (DataUtility.gameData.isNetworkedGame)
        {
            PunTools.PhotonRpcMine(view, "RPC_Initialize", RpcTarget.AllBuffered, level, pos, owner, dir);
        }
        else
        {
            gameObject.SetActive(true);
            transform.localScale = level * scaleFactor * Vector3.one;
            transform.position   = pos;
            xSpeed      = speed * dir;
            ySpeed      = gravity;
            HazardLevel = level;
            alive       = true;
            hazardOwner = owner;

            thrown     = false;
            throwSpeed = Vector3.zero;

            GetComponent <Renderer>().material.color = DataUtility.GetColorFor(owner);
        }
    }
Example #4
0
    // Start is called before the first frame update

    void Awake()
    {
        childGameObject1 = transform.Find("Laser1").gameObject;
        childGameObject2 = transform.Find("Laser2").gameObject;
        childGameObject3 = transform.Find("Laser3").gameObject;
        questionZones    = GameObject.Find("QuestionZones");
        laser            = GetComponent <AudioSource>();
        sceneSaver       = GameObject.Find("GameSave").GetComponent <SaveScene>();
        hSpawner         = GameObject.Find("GameHandler").GetComponent <HazardSpawner>();
    }
Example #5
0
    public void Initialize(PlayerID playerID, bool isLocal, HazardSpawner spawner)  //TODO: Sync with alex on owner?
    {
        this.playerID = playerID;
        this.isLocal  = isLocal;
        this.spawner  = spawner;

        GetComponent <PlayerInput>().enabled = isLocal;

        SetColor(DataUtility.GetColorFor(playerID));
        _charaterController = GetComponent <CharacterController>();
        initialized         = true;
        _moveDirection      = Vector3.zero;
    }
    void GivenAHazardSpawner()
    {
        var randomService = new RandomFloat(new Random(RandomSeed));

        hazardSpawner = new HazardSpawner(
            time,
            SpawnHazardsEvery,
            randomService,
            MinHazardHeight,
            MaxHazardHeight,
            HazardInitialPosition,
            HazardsSpeed
            );
    }
Example #7
0
    void Start()
    {
        Screen.autorotateToPortrait           = false;
        Screen.autorotateToPortraitUpsideDown = false;
        Screen.autorotateToLandscapeLeft      = true;
        Screen.autorotateToLandscapeRight     = true;

        playerFellOnce = false;
        playerDead     = false;
        manager        = this;

        environment = Environment.Snow;

        groundToSpawn = Resources.Load("Prefabs/Ground");

        hazardSpawner = GetComponent <HazardSpawner>();
    }
Example #8
0
 void Awake()
 {
     instance = this;
 }