Exemplo n.º 1
0
    private void Awake()
    {
        //Singleton pattern
        if (Instance == null)
        {
            Instance = this;
        }
        else
        {
            Destroy(gameObject);
            return;
        }

        //Pipes list
        pipes = new List <Pipe>();

        //Initialize pool
        GameObject poolObject = new GameObject("CloudPool");

        poolObject.transform.parent = transform;
        pipePool = poolObject.AddComponent <PipePool>();

        //Set pool properties
        pipePool.SetPrefab(pipePrefab);
        pipePool.AddObjects(20);

        timer = 0f;
    }
Exemplo n.º 2
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Exemplo n.º 3
0
 // Use this for initialization
 void Start()
 {
     pipes = new List <GameObject>();
     if (Instance == null)
     {
         Instance = this;
     }
     cor = StartCoroutine(Spawn());
 }
Exemplo n.º 4
0
    //public Text scoreText2;

    // Start is called before the first frame update
    void Start()
    {
        pipe = GameObject.Find("PipeSpawner").GetComponent <PipeSpawner>();
        //pipes = GameObject.Find("PipePair").GetComponent<Pipe>();
        gameOver.enabled = false;
        startOver.onClick.AddListener(() => {
            SceneManager.LoadScene(0);
        });
    }
Exemplo n.º 5
0
	void Start()
	{
		if(pipeSpawner == null)
		{
			PipeSpawner[] spawners = (PipeSpawner[])FindObjectsOfType(typeof(PipeSpawner));
			if(spawners.Length > 0)
				pipeSpawner = spawners[0];
			else
				Debug.LogError("Please create a GameObject with a PipeSpawner component.");
		}
		target = pipeSpawner.transform.position;
	}
Exemplo n.º 6
0
    void Awake()
    {
        gm          = GameObject.Find("NNGameManager").GetComponent <NNGameManager>();
        pipeSpawner = GameObject.Find("PipeSpawner").GetComponent <PipeSpawner>();

        score   = 0;
        fitness = 0;

        nn = new NeuralNetwork();

        scoreText   = GameObject.Find("DummyScore").GetComponent <Text>();
        fitnessText = GameObject.Find("DummyFitness").GetComponent <Text>();
    }
Exemplo n.º 7
0
    void Awake()
    {
        if (instance != null)
        {
            Debug.LogWarning(
                "There should be only ONE instance of " +
                "PipeSpawner. Destroying this instance..."
                );
            DestroyImmediate(this);
            return;
        }

        instance = this;
    }
Exemplo n.º 8
0
    private void Awake()
    {
        if (m_instance == null)
        {
            m_instance = this;
        }
        else if (m_instance != this)
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);
        m_pipeSpawner = GetComponent <PipeSpawner>();
        InitGame();
    }
Exemplo n.º 9
0
    private void FixedUpdate()
    {
        if (!alive)
        {
            return;
        }

        if (!PlayerSpawner.instance.play)
        {
            PipeSpawner firstPipe = PipeSpawnerSpawner.instance.pipes.First.Value;
            float[]     inputs    = new float[3];
            inputs[0] = (transform.position.y + 4) / 8;
            inputs[1] = (firstPipe.transform.position.y + 4) / 8f;
            inputs[2] = (firstPipe.transform.position.x - transform.position.x) / 6;

            float[] outputs = brain.FeedForward(inputs);
            if (outputs[0] > .5f)
            {
                Jump();
            }
        }
    }
Exemplo n.º 10
0
	void OnEnable()
	{
		ps = (PipeSpawner)target;
	}
Exemplo n.º 11
0
 private void Start()
 {
     pipeSpawner = GameObject.FindGameObjectWithTag("PipeController").GetComponent <PipeSpawner>();
 }