Exemplo n.º 1
0
    bool ScanForTarget()
    {    //scan for the targets, if the timeLimit is over, then charge the targets in its influence area with certain probablity
        Collider2D[] colliders;
        //colliders.Initialize();
        //Vector3 pos = new Vector3(thisT.position.x, thisT.position.y+thisObj.GetComponent<BoxCollider2D>().size.y/2.0f, thisT.position.z);
        Vector3 pos = new Vector3(thisT.position.x, thisT.position.y, thisT.position.z);

        colliders = Physics2D.OverlapCircleAll(pos, baseTower.range, LayerMask.GetMask("Visitor"));
        float       hpIncrease;
        UnitVisitor tempVisitor;
        Vector3     tempPos;
        float       yratio = 2.0408163f;   // 1/(0.7^0.7)
        Vector3     dir;

        if (colliders.Length > 0)
        {
            isCount = true;
            if (baseTower.stunDuration * 5 >= baseTower.attackInterval)
            //if(baseTower.stunDuration >= baseTower.timeLimit)
            {
                foreach (Collider2D collider in colliders)
                {
                    dir = collider.transform.position - thisT.position;
                    if (dir.x * dir.x + dir.y * dir.y * yratio < baseTower.range * baseTower.range)
                    {
                        tempVisitor = collider.GetComponent <UnitVisitor>();
                        hpIncrease  = PoolManager.GetPref(towerID, tempVisitor.visitorAttri.visitorID);
                        tempVisitor.TakeRecover(hpIncrease * (1 - tempVisitor.visitorAttri.decrement));
                        ScoreControl.CoinIncrease((int)(hpIncrease * tempVisitor.visitorAttri.capacity));
                        tempPos    = thisT.position;
                        tempPos.y += thisT.GetComponent <BoxCollider2D>().size.y / 2;
                        Instantiate(coinHead, tempPos, Quaternion.identity);
                        //PoolManager.Spawn(GameManager.gameManager.coinHead,tempPos,Quaternion.identity);
                        //Debug.Log(hpIncrease*tempVisitor.visitorAttri.capacity);
                    }
                }
                baseTower.stunDuration = 0;
            }
            return(true);
        }
        else
        {
            isCount = false;
            return(false);
        }
    }
Exemplo n.º 2
0
    public void _SelectDismantleUI()
    {
        GameObject obj;

        PoolManager.Unspawn(selectedTower.transform);
        AudioManager.PlayTowerSold();
        GameManager.ClearIndicator();
        ScoreControl.CoinIncrease(selectedTower.baseTower.price);

        obj = PoolManager.Spawn(GameManager.gameManager.buildingFlag, selectedTower.transform.position, Quaternion.identity);
        obj.GetComponent <SpriteRenderer>().sortingLayerName = selectedTower.GetComponent <SpriteRenderer>().sortingLayerName;

        //GameManager.ClearUpgradeUI();
        //GameManager.ClearDismantleUI ();
        //selectedTower = null;
        GameManager.ClearSelection();
    }