//Detect collisions with other gameObjects. Log and update health/points as needed.
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.tag == "prize")
        {
            Debug.Log("Collision with " + other.gameObject.tag);
            Player.Instance.Points += 10;
            AudioSource coinSound =
                gameObject.GetComponent <AudioSource> ();
            if (coinSound != null)
            {
                coinSound.Play();
            }
        }
        else if (other.gameObject.tag == "fire")
        {
            Debug.Log("Collision with " + other.gameObject.tag);
            Player.Instance.Health -= 10;
            AudioSource fireSound =
                fire.GetComponent <AudioSource> ();
            if (fireSound != null)
            {
                fireSound.Play();
            }
        }

        CoinController sp = other.gameObject.GetComponent <CoinController> ();

        if (sp != null)
        {
            sp.Reset();
        }
    }
Beispiel #2
0
    // Update is called once per frame
    void Update()
    {
        if (player.transform.position.x > (segmentWidth * currentSegments.Count) - segmentWidth)
        {
            int randomSegmentNumber    = Random.Range(0, worldSegments.Length);
            int randomBackgroundNumber = Random.Range(0, backgrounds.Length);

            GameObject newSegment = Instantiate(worldSegments[randomSegmentNumber], new Vector2(segmentWidth * currentSegments.Count, 0), Quaternion.identity);
            Instantiate(backgrounds[randomBackgroundNumber], new Vector3(segmentWidth * currentSegments.Count, 0, -7.61f), Quaternion.identity);
            currentSegments.Add(newSegment);
            CoinController.createCoin(newSegment.transform, coinObject[0], enemy, powerup);

            randomSegmentNumber    = Random.Range(0, worldSegments.Length);
            randomBackgroundNumber = Random.Range(0, backgrounds.Length);

            newSegment = Instantiate(worldSegments[randomSegmentNumber], new Vector2(segmentWidth * currentSegments.Count, 0), Quaternion.identity);
            Instantiate(backgrounds[randomBackgroundNumber], new Vector3(segmentWidth * currentSegments.Count, 0, -7.61f), Quaternion.identity);
            currentSegments.Add(newSegment);
            CoinController.createCoin(newSegment.transform, coinObject[0], enemy, powerup);
        }
        else
        {
            //print((player.transform.position.x) + " =-= " + ((segmentWidth * currentSegments.Count) - segmentWidth));
        }

        foreach (GameObject segment in currentSegments)
        {
            if (Vector3.Distance(segment.transform.position, player.transform.position) > 100)
            {
                segment.active = false;
            }
        }
    }
    // Start is called before the first frame update
    void Start()
    {
        if (Instance != null)
        {
            Destroy(this);
        }
        Instance   = this;
        GameType   = GameStatusScript.getInstance().GameType;
        WhiteDiscs = new List <GameObject>();
        BlackDiscs = new List <GameObject>();

        var whitecoins = transform.Find("WhiteCoins");

        for (int i = 0; i < whitecoins.childCount; i++)
        {
            WhiteDiscs.Add(whitecoins.GetChild(i).gameObject);
        }
        var blackcoins = transform.Find("BlackCoins");

        for (int i = 0; i < blackcoins.childCount; i++)
        {
            BlackDiscs.Add(blackcoins.GetChild(i).gameObject);
        }
        Queen = transform.Find("Queen").gameObject;
    }
Beispiel #4
0
        public void TryWriteCoinEmptyPayload()
        {
            var sozu = new VolatileCoinStore();

            var inbox      = new BoundedInbox();
            var outbox     = new BoundedInbox();
            var controller = new CoinController(inbox, outbox, sozu, _hash);

            controller.Lineage = MakeLineage();

            var clientId = new ClientId();
            var reqId    = new RequestId(1);

            var coin = GetCoin(_rand);

            var writeCoinRequest = ProduceCoinRequest.From(reqId, clientId, coin.Outpoint,
                                                           (OutpointFlags)coin.OutpointFlags,
                                                           new BlockAlias(3), 100, 50, Span <byte> .Empty, clientId.Mask);

            inbox.TryWrite(writeCoinRequest.Span);
            controller.HandleRequest();

            var raw = outbox.Peek();

            Assert.Equal(ProduceCoinResponse.SizeInBytes, raw.Length);
            var response = new ProduceCoinResponse(raw.Span);

            // verify response contents
            Assert.Equal(reqId, response.MessageHeader.RequestId);
            Assert.Equal(clientId, response.MessageHeader.ClientId);
            Assert.Equal(MessageKind.ProduceCoinResponse, response.MessageHeader.MessageKind);
            Assert.Equal(ChangeCoinStatus.InvalidContext, response.Status);
        }
    private void OnTriggerEnter(Collider other)
    {
        CoinController coin = other.GetComponent <CoinController>();

        if (coin != null)
        {
            score += coin.Value;
            coin.Vanish();
            if (score >= 50)
            {
                _5_CoinsCollected.Invoke();
            }
            if (score >= 100)
            {
                _10_CoinsCollected.Invoke();
            }
            if (score >= 160)
            {
                _16_CoinsCollected.Invoke();
            }
            if (score >= 230)
            {
                _23_CoinsCollected.Invoke();
            }
        }
    }
	// Function that will be called automatically when the coin dies
	public void OnCoinDied (CoinController coinController){
		// We unsubscribe to avoid memory leaks
		coinController.onDied -= OnCoinDied;

		// Spawn a new coin
		SpawnPrefab();
	}
Beispiel #7
0
        public void TryReadingNonExistentCoin()
        {
            var sozu = new VolatileCoinStore();

            var inbox      = new BoundedInbox();
            var outbox     = new BoundedInbox();
            var controller = new CoinController(inbox, outbox, sozu, _hash);

            var clientId = new ClientId();
            var reqId    = new RequestId(1);

            var coin = GetCoin(_rand);

            var readCoinRequest = GetCoinRequest.From(reqId, clientId, coin.Outpoint,
                                                      new BlockAlias(3), clientId.Mask);

            inbox.TryWrite(readCoinRequest.Span);
            controller.HandleRequest();

            var raw      = outbox.Peek();
            var response = new GetCoinResponse(raw.Span);

            // verify response contents
            Assert.Equal(reqId, response.MessageHeader.RequestId);
            Assert.Equal(clientId, response.MessageHeader.ClientId);
            Assert.Equal(GetCoinStatus.OutpointNotFound, response.Status);
        }
Beispiel #8
0
    private void OnTriggerEnter(Collider other)
    {
        //print(other.name);
        CoinController coin = other.GetComponentInParent <CoinController>();

        coin.triggerStartTime = Time.time;
    }
Beispiel #9
0
    private void OnTriggerStay(Collider other)
    {
        CoinController coin = other.GetComponentInParent <CoinController>();

        if (Time.time - coin.triggerStartTime > killTime)
        {
            if (other.name == "Top Face collision")
            {
                topCount++;
            }
            if (other.name == "Bottom Face collision")
            {
                bottomCount++;
            }
            if (other.name == "Side Face collision")
            {
                sideCount++;
            }

            Destroy(coin.gameObject);

            //Debug//
            //PrintResults();
        }
    }
Beispiel #10
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.tag == "head")

        {
            HeadController headObj = other.gameObject.GetComponent <HeadController> ();

            Instantiate(explosion).GetComponent <Transform> ().position =
                other.gameObject.GetComponent <Transform> ().position;


            Damage(damage);

            headObj.Reset();
            headColl = other.gameObject.GetComponent <AudioSource> ();
            headColl.Play();
        }

        if (other.gameObject.tag == "coin")
        {
            CoinController coinObj = other.gameObject.GetComponent <CoinController> ();
            coinObj.Reset();
            Player.Instance.Money = Player.Instance.Money + 10;
            coinColl = other.gameObject.GetComponent <AudioSource> ();
            coinColl.Play();
        }
    }
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    //override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
    //
    //}



    // OnStateExit is called when a transition ends and the state machine finishes evaluating this state
    override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        var enemy = animator.GetComponent <EnemyController>();

        if (enemy == null)
        {
            enemy = animator.GetComponentInParent <EnemyController>();
        }
        PlayerLevelManager.Instance.GainXP(enemy.Experience);
        Destroy(enemy.gameObject);
        int amountOfCoins = Random.Range(2, 4);

        for (int i = 0; i < amountOfCoins; i++)
        {
            int value = 0;
            if (amountOfCoins >= 2 && amountOfCoins <= 3)
            {
                value = Random.Range(20, 25);
            }
            if (amountOfCoins > 3 || amountOfCoins == 4)
            {
                value = Random.Range(10, 12);
            }
            CoinController coin = Instantiate(enemy.coin, enemy.transform.position + new Vector3(Random.Range(-0.5f, 0.5f), 0, 0), Quaternion.identity) as CoinController;
            coin.value = value;
        }
    }
Beispiel #12
0
    CoinController NewCoinController()
    {
        GameObject     go = GameObject.Instantiate(m_Coin_Prefab) as GameObject;
        CoinController cC = go.GetComponent <CoinController> ();

        cC.IReset();
        return(cC);
    }
        public void GetAllCoinsTest()
        {
            CoinController controller = new CoinController();

            List <Coin> cList = controller.GetCoins();

            Assert.AreEqual(CoinController.coinList, cList, "Are not equal");
        }
Beispiel #14
0
    // Function that will be called automatically when the coin dies
    public void OnCoinDied(CoinController coinController)
    {
        // We unsubscribe to avoid memory leaks
        coinController.onDied -= OnCoinDied;

        // Spawn a new coin
        SpawnPrefab();
    }
    private void catchCoin(GameObject coin)
    {
        CoinController coinController = coin.GetComponent <CoinController>();

        coinSound.Play();
        rings += coinController.getCoinValue();
        Destroy(coin);
    }
Beispiel #16
0
 private void Start()
 {
     lc              = LevelController.lc;
     cc              = CoinController.cc;
     mcm             = GetComponent <MeCoinMovement>();
     lc.economyState = Random.Range(-1, 2);
     EconomyUpdate();
 }
    void CreateCoin()
    {// Objeto a Instanciar, posicion actual del gameObject, variable necesaria para el instantiate
        Vector3        transformUpdate = new Vector3(transform.position.x, transform.position.y, transform.position.z);
        GameObject     coin            = Instantiate(ItemToDrop, transformUpdate, Quaternion.identity);
        CoinController coinC           = coin.GetComponent <CoinController>();

        coinC.SendMessage("ImpulseCoin");
    }
Beispiel #18
0
	void Start () {
		touchMovement = GetComponent<TouchMovement> ();
		coinController = GetComponent<CoinController> ();
		stealth = GetComponent<StealthMode> ();
		playerEnabled = true;
		
		camFollow = GameObject.Find ("Player Camera").GetComponent<CameraFollow> ();
	}
        public void GetOneCoinTest()
        {
            CoinController controller = new CoinController();
            Coin           theCoin    = CoinController.coinList.Find(c => c.Id == 2);

            Coin coin = controller.GetOneCoin(2);

            Assert.AreEqual(theCoin, coin, "Are not equal");
        }
Beispiel #20
0
    void _CreateCoin()
    {
        Debug.Log("_CreateCoin");
        GameObject coin = Instantiate(Resources.Load <GameObject>("Prefab/Coin"));

        CoinController controller = coin.GetComponent <CoinController>();

        controller.CoinMove(CarDirection.Center);
    }
Beispiel #21
0
 public void HandleSafeDestroyed(int numCoins, Transform safeLocation)
 {
     for (int i = 0; i < numCoins; i++)
     {
         GameObject     coin           = SpawnGameObjectAtPosition(coinPrefab, safeLocation.position);
         CoinController coinController = coin.GetComponent <CoinController>();
         coinController.LerpToPosition(GetRandomLocationOnscreen(), .5f);
     }
 }
Beispiel #22
0
    void FindObjectOfTypeCoinController()
    {
        coinController = FindObjectOfType <CoinController>();

        if (coinController == null)
        {
            Debug.LogError("[UIManager] coinController == null");
        }
    }
Beispiel #23
0
    // Use this for initialization
    void Start()
    {
        _headsImage = headsImage.GetComponent <RawImage>();
        _tailsImage = tailsImage.GetComponent <RawImage>();

        _coin = coin.GetComponent <CoinController>();

        _headsImage.gameObject.SetActive(false);
        _tailsImage.gameObject.SetActive(false);
    }
Beispiel #24
0
    void OnTriggerExit(Collider other)
    {
        CoinController cc = other.gameObject.GetComponent <CoinController>();

        if (null != cc &&
            false == cc.IsAttached())
        {
            cc.Attach(++coinsAttached);
        }
    }
    public void PickupCoin(CoinController coin)
    {
        // get player's RigidBody2D
        var rigidBody = GetComponent <Rigidbody2D>();

        // Increase mass
        rigidBody.mass += coin.weight;
        // Add the coin's value
        coinCount += coin.value;
    }
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != null)
     {
         Destroy(gameObject);
     }
 }
Beispiel #27
0
    void Start()
    {
        healthController = gameObject.GetComponent <HealthController>();

        GameObject player = GameObject.FindGameObjectWithTag("Player");

        coinController = player.GetComponent <CoinController>();

        alive           = true;
        lives           = 3;
        healthText.text = "Health = 100";
    }
Beispiel #28
0
    void Start()
    {
        audioManager   = FindObjectOfType <AudioManager>();
        sceneLoader    = FindObjectOfType <SceneLoader>();
        coinController = FindObjectOfType <CoinController>();
        scoreText      = GetComponentInChildren <TMP_Text>();

        //       activeScene = SceneManager.GetActiveScene().name;

        //       print("[UIManager] activeScene " + activeScene);
        //        buildIndex = activeScene.buildIndex;
    }
Beispiel #29
0
    void FixedUpdate()
    {
        CoinController.AddTrajectoryPoint(transform.position);

        float horizontalInput = Input.GetAxis("Horizontal");
        float verticalInput   = Input.GetAxis("Vertical");

        rb.AddTorque(transform.right * torque * verticalInput);
        float f = force * (horizontalVelocityLimit - Mathf.Abs(rb.velocity.x));

        rb.AddForce(transform.right * f * horizontalInput);
    }
 // Use this for initialization
 void Start()
 {
     userScript          = FindObjectOfType <UserController>();
     caughtScript        = FindObjectOfType <UserCaught>();
     enemyScript         = FindObjectOfType <EnemyController>();
     coinScript          = FindObjectOfType <CoinController>();
     userScript.enabled  = false;
     enemyScript.enabled = false;
     user.parent         = board;
     enemy.parent        = board;
     scoreText.text      = "Score : 0";
 }
Beispiel #31
0
        public void RemoveProductionAndConsumption()
        {
            var sozu = new VolatileCoinStore();

            var inbox      = new BoundedInbox();
            var outbox     = new BoundedInbox();
            var controller = new CoinController(inbox, outbox, sozu, _hash);

            controller.Lineage = new MockLineage();

            var clientId = new ClientId();
            var reqId    = new RequestId(1);

            var coin = GetCoin(_rand);

            sozu.AddProduction(
                _hash.Hash(ref coin.Outpoint),
                ref coin.Outpoint,
                false, coin.Payload,
                new BlockAlias(2),
                null);

            sozu.AddConsumption(
                _hash.Hash(ref coin.Outpoint),
                ref coin.Outpoint,
                new BlockAlias(2),
                null);

            var buffer            = new byte[RemoveCoinRequest.SizeInBytes];
            var removeCoinRequest = new RemoveCoinRequest(
                buffer, reqId, ref coin.Outpoint, new BlockAlias(2).ConvertToBlockHandle(clientId.Mask), true, true);

            inbox.TryWrite(removeCoinRequest.Span);
            controller.HandleRequest();

            var raw = outbox.Peek();

            Assert.Equal(RemoveCoinResponse.SizeInBytes, raw.Length);
            var response = new RemoveCoinResponse(raw.Span);

            // verify response contents
            Assert.Equal(reqId, response.MessageHeader.RequestId);
            Assert.Equal(clientId, response.MessageHeader.ClientId);
            Assert.Equal(MessageKind.RemoveCoinResponse, response.MessageHeader.MessageKind);
            Assert.Equal(ChangeCoinStatus.Success, response.Status);

            sozu.TryGet(_hash.Hash(ref coin.Outpoint), ref coin.Outpoint, new BlockAlias(2), null, out var coin2,
                        out var pe, out var ce);

            Assert.False(pe.IsDefined);
            Assert.False(ce.IsDefined);
        }
    void Start()
    {
        GameObject coinControllerObject = GameObject.FindWithTag("CoinController");

        if (coinControllerObject != null)
        {
            _coinController = coinControllerObject.GetComponent <CoinController>();
        }
        else
        {
            Debug.Log("Cannot find 'CoinController' script");
        }
    }
	public void SetUp(){
		testObject = new GameObject ();
		testObject.AddComponent<CoinController> ();
		coinController = testObject.GetComponent<CoinController> ();
	}
	public void FreeCoinController (CoinController cC)
	{
		m_CoinController_Pool.Free (cC);
	}