示例#1
0
 void Awake()
 {
     if (!created)
     {
         Instance = this;
         created  = true;
     }
     splitRad = splitDegrees * Mathf.Deg2Rad;
 }
示例#2
0
    public void Zap()
    {
        Vector3 zapDirect = ZapManager.GetZapDirect(transform.position);

        GameObject prefab = ZapManager.Instance.nodePrefab;

        GameObject newNodeObj = Instantiate(prefab,
                                            transform.position + zapDirect * ZapManager.Instance.nodeStep,
                                            Quaternion.identity, transform);

        ZapNode newNode = newNodeObj.GetComponent <ZapNode>();

        newNode.MakeRoot(this);

        Debug.Log("zap zap");
    }
示例#3
0
        private IEnumerator spawnLaser()
        {
            ZapManager zapManager = GameMaster.Instance.m_ZapManager;

            if (zapManager)
            {
                ZapGrid zapGrid = zapManager.GetZapGrid();
                int     numRows = zapGrid.GetNumRows();
                int     numCols = zapGrid.GetNumCols(0);

                // get random row to spawn lasers on
                int randomRow = Random.Range(0, numRows);
                Zap zapInRow  = zapGrid.GetZap(randomRow, 0);

                // spawn on left or right side of the screen
                int     randomSide    = Random.Range(0, 2);
                bool    isOnRightSide = (randomSide == 1) ? true : false;
                Vector3 spawnPos      = Vector3.zero;

                // spawn the laser
                Laser laserInstance = Instantiate(m_LaserPrefab, this.transform);

                // make changes to lasers position based on if it is on left or right side of the screen.
                if (randomSide == 0) // spawn on left side of screen
                {
                    spawnPos = Utility.ScreenUtilities.GetWSofSSPosition(0.0f, 0.0f);
                }
                else // spawn on right side of screen
                {
                    spawnPos = Utility.ScreenUtilities.GetWSofSSPosition(1.0f, 0.0f);
                }

                // make sure the laser is spawned at the same y position as the zap row.
                spawnPos.y = zapInRow.GetOffsetPosition().y;
                spawnPos.z = 80.0f;
                laserInstance.SetPositionLaserPost(spawnPos, isOnRightSide);
            }

            yield return(new WaitForSeconds(m_SpawnTime));

            StartCoroutine(spawnLaser());
        }
示例#4
0
    void Extend()
    {
        isLeaf = false;

        Vector3 zapDirect = ZapManager.GetZapDirect(transform.position);

        float roll = Random.Range(0, 100);

        if (roll <= ZapManager.Instance.nodeSplitChance)
        {
            // make two child nodes
            Debug.Log("oh baby a double");
            Vector3 direct1 = Vector3.RotateTowards(zapDirect, transform.right, ZapManager.splitRad, 0f);
            Vector3 direct2 = Vector3.RotateTowards(zapDirect, -transform.right, ZapManager.splitRad, 0f);
            MakeNode(direct1);
            MakeNode(direct2);
        }
        else
        {
            // make one child node
            MakeNode(zapDirect);
        }
    }
示例#5
0
 void OnDestroy()
 {
     ZapManager.RemoveZap(this);
 }
示例#6
0
 void Awake()
 {
     ZapManager.RegisterZap(this);
 }