Beispiel #1
0
 void Start()
 {
     hasStealthChanged = sightRange;
     rigidbody2D       = GetComponent <Rigidbody2D>();
     death             = GetComponent <AudioSource>();
     Player            = GameObject.Find("Player");
     BoxCollider2D[] bc2d = GetComponents <BoxCollider2D>();
     if (bc2d[0].isTrigger)
     {
         sightCollider = bc2d[0];
     }
     else
     {
         sightCollider = bc2d[1];
     }
     sightCollider.size = new Vector2(sightRange, 2f);//??
     coinDropper        = GetComponent <CoinDropper>();
     animator           = GetComponent <Animator>();
 }
Beispiel #2
0
    public void DropGems(int numGemsToLose)
    {
        int numGems;

        if (chestManager == null)
        {
            numGems = chestTrigger.NumGemsInChest();
            if (numGems <= 0)
            {
                return;
            }
        }
        else
        {
            numGems = chestManager.NumGemsInChest();
            if (numGems <= 0)
            {
                return;
            }
        }
        GameObject coinDropper = Instantiate(coinDropperPrefab);
        Vector3    position    = this.transform.position;

        position.y += 2f;
        coinDropper.transform.position = position;
        CoinDropper coinDropperScript = coinDropper.GetComponent <CoinDropper> ();

        coinDropperScript.throwSpeedMin = throwSpeedMin;
        coinDropperScript.throwSpeedMax = throwSpeedMax;
        int numPointsToLose = Mathf.Min(numGemsToLose, numGems);

        coinDropperScript.SetNumberOfPointsToDrop(numPointsToLose);

        if (chestManager == null)
        {
            chestTrigger.RemoveGems(numPointsToLose);
        }
        else
        {
            chestManager.RemoveGems(numPointsToLose);
        }
    }
Beispiel #3
0
    public void DropGold(bool willDie = false)
    {
        //if (points <= 0)
        //	return;
        GameObject coinDropper = Instantiate(coinDropperPrefab);
        Vector3    position    = this.transform.position;

        position.y += 5f;
        coinDropper.transform.position = position;
        CoinDropper coinDropperScript = coinDropper.GetComponent <CoinDropper> ();

        coinDropperScript.SetTeam(team);
        int numPointsToLose = 1;

        //if (willDie) {
        //	// drop all points
        //	numPointsToLose = this.points;
        //} else {
        //	numPointsToLose = Mathf.Min (1, this.points);
        //}
        coinDropperScript.SetNumberOfPointsToDrop(numPointsToLose);
        //points = Mathf.Max (0, points - numPointsToLose);
    }