Exemplo n.º 1
0
 public void AttemptCollect(CoinCollector collector)
 {
     if (!m_Collected)
     {
         Collect(collector);
     }
 }
 // Start is called before the first frame update
 void Start()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Exemplo n.º 3
0
 private void Awake()
 {
     _distanceUpdater        = FindObjectOfType <UpdatePassedDistance>();
     _energySliderController = FindObjectOfType <EnergySliderController>();
     _spawner       = FindObjectOfType <Spawner>();
     _coinCollector = FindObjectOfType <CoinCollector>();
 }
Exemplo n.º 4
0
 // Start is called before the first frame update
 protected virtual void Start()
 {
     myRigidBody            = GetComponent <Rigidbody2D>();
     currentPlaceTileHealth = defaultPlaceTileHealth;
     collector       = GetComponent <CoinCollector>();
     defaultWallTile = wallTile;
     curPlaceCost    = 0;
     activeButton    = defaultActiveButton;
     s = GameObject.Find("Tilemap").GetComponent <GroundSpawner>();
 }
Exemplo n.º 5
0
    // Update is called once per frame
    //	void Update () {
    //
    //	}

    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Player")
        {
            CoinCollector collector = other.GetComponent <CoinCollector> ();
            if (collector.numCoins >= coinRequirement)
            {
                other.GetComponent <PlayerMove> ().MoveByDelta(deltaX, deltaY);
            }
        }
    }
Exemplo n.º 6
0
    void Collect(CoinCollector collector)
    {
        m_Collected = true;

        var eventData = new CollectableEventData();

        m_Events.WasCollected.Invoke(eventData);

        collector.Collected(this);

        Destroy(gameObject);
    }
Exemplo n.º 7
0
    public override void InitializeAgent()
    {
        player    = gameObject.GetComponent <PlayerController>();
        collector = gameObject.GetComponent <CoinCollector>();

        var obj = GameObject.Find("ActionText");

        obj.GetComponent <Text>().text = "Action: Not set yet";
        Debug.Log("Agent Created");

        this.GiveBrain(GameObject.Find("Ball3DBrain").GetComponent <Brain>());
    }
Exemplo n.º 8
0
    // Start is called before the first frame update
    void Start()
    {
        coinCollector = FindObjectOfType <CoinCollector>();
        coinCollector.AddListenerOnCoinCollectedEvent(ChangeCoinText);

        carController = FindObjectOfType <CarController>();
        carController.AddListenerOnPickUpFareEvent(ChangeFareImageColor);
        carController.AddListenerOnTransferFareEvent(ChangeFareImageColor);

        stash = GameDatas.GetStash();
        ChangeCoinText(0);

        SetFareImages();
    }
Exemplo n.º 9
0
    public void destroyCoinDestroysCoin()
    {
        GameObject    collectorObject = new GameObject();
        CoinCollector coinCollector   = collectorObject.AddComponent <CoinCollector>();

        GameObject uiContainer = new GameObject();

        uiContainer.AddComponent <AudioSource>();
        coinCollector.ui          = uiContainer.AddComponent <UIscript>();
        coinCollector.ui.coinText = uiContainer.AddComponent <Text>();

        GameObject coin = new GameObject();

        coinCollector.DestroyCoin(coin);

        Assert.IsTrue(!coin.activeSelf);
    }
Exemplo n.º 10
0
    private void OnTriggerEnter(Collider other)
    {
        Rigidbody otherRigidbody = other.attachedRigidbody;

        if (otherRigidbody == null)
        {
            return;
        }

        // Проверка компонента на Rigidbody, который вошел в триггер
        CoinCollector coinCollector = otherRigidbody.GetComponent <CoinCollector>();

        if (coinCollector != null)         // coinCollector будет null, если компонент на otherRigidbody нет нужного компонента
        {
            coinCollector.Collect(Value);
            Destroy(gameObject);
        }
    }
Exemplo n.º 11
0
    public void destroyCoinGetsCoin()
    {
        GameObject    collectorObject = new GameObject();
        CoinCollector coinCollector   = collectorObject.AddComponent <CoinCollector>();

        GameObject uiContainer = new GameObject();

        uiContainer.AddComponent <AudioSource>();
        coinCollector.ui          = uiContainer.AddComponent <UIscript>();
        coinCollector.ui.coinText = uiContainer.AddComponent <Text>();

        GameObject coin = new GameObject();

        int oldCoins = coinCollector.ui.coins;

        coinCollector.DestroyCoin(coin);

        Assert.IsTrue(coinCollector.ui.coins > oldCoins);
    }
Exemplo n.º 12
0
    void Start()
    {
        gameManager = FindObjectOfType <GameManager>();
        if (gameManager == null)
        {
            throw new System.Exception($"Unable to find object of type {nameof(GameManager)}");
        }

        resourceManager = FindObjectOfType <ResourceManager>();
        if (resourceManager == null)
        {
            throw new System.Exception($"Unable to find object of type {nameof(ResourceManager)}");
        }

        coinCollector = FindObjectOfType <CoinCollector>();
        if (coinCollector == null)
        {
            throw new System.Exception($"Unable to find object of type {nameof(CoinCollector)}");
        }
    }
Exemplo n.º 13
0
 void OnTriggerEnter2D()
 {
     audiocoins.Play();
     CoinCollector.AddCoins(CoinsToAdd);
     Destroy(this.gameObject);
 }
Exemplo n.º 14
0
 void Awake()
 {
     rb2d          = GetComponent <Rigidbody2D> ();
     coinCollector = GetComponent <CoinCollector> ();
 }
Exemplo n.º 15
0
 // Use this for initialization
 void Start()
 {
     playerPhysicsBody = this.GetComponent <Rigidbody2D>();
     playerAnimator    = this.GetComponent <Animator>();
     coinCollector     = GetComponent <CoinCollector>();
 }
Exemplo n.º 16
0
 public void EndGame()
 {
     Debug.Log("EndGame");
     CoinCollector.Reset();
 }
 // Use this for initialization
 void Start()
 {
     coinCollector = GameObject.Find("CoinCollector").GetComponent <CoinCollector>();
 }
Exemplo n.º 18
0
 // Use this for initialization
 void Start()
 {
     coinCol  = GetComponent <CoinCollector> ();
     control  = GetComponent <PlayerControl> ();
     shopText = GameObject.Find("Notice").GetComponent <NotificationText> ();
 }
Exemplo n.º 19
0
 // Use this for initialization
 void Start()
 {
     time          = 0;
     player        = GameObject.Find("Player");
     coinCollector = GameObject.Find("CoinCollector").GetComponent <CoinCollector>();
 }
Exemplo n.º 20
0
	// Use this for initialization
	void Start () {
		coinCol = GetComponent<CoinCollector> ();
		control = GetComponent<PlayerControl> ();
		shopText = GameObject.Find ("Notice").GetComponent<NotificationText> ();
	}