/** * Because C#'s list interface is apparantly void of functionality */ static void Swap(List <CBaseBlock> s, int i, int j) { CBaseBlock tmp = s[i]; s[i] = s[j]; s[j] = tmp; }
private void OnTriggerExit(Collider collider) { CBaseBlock blk = g.ToBaseBlock(collider.gameObject); if (blk != null) { m_aIntersecting.Remove(blk); } }
private void OnCollisionExit(Collision collision) { CBaseBlock blk = g.ToBaseBlock(collision.collider.gameObject); if (blk != null && blk.IsInstantiated()) { g.TowerBuilderRules().OnBlockFall(blk); } }
/**************************************************************************************** * Unity overrides ***************************************************************************************/ private void OnTriggerEnter(Collider collider) { CBaseBlock blk = g.ToBaseBlock(collider.gameObject); if (blk != null && !m_aIntersecting.Contains(blk)) { m_aIntersecting.Add(blk); g.TowerBuilderRules().OnBlockEnter(blk); } }
/************************************************************ * Unity overrides ***********************************************************/ private void OnTriggerEnter(Collider other) { CBaseBlock blk = other.gameObject.GetComponent <CBaseBlock>(); if (blk != null && blk.IsInstantiated()) { m_iCount++; g.TowerBuilderRules().OnBlockFall(blk); } }
//Called when a block enters the "veil" of the building area, usually when held by hand public void OnBlockEnter(CBaseBlock pBlock) { if (!pBlock.m_bHasEnteredBuildingArea) { pBlock.m_bHasEnteredBuildingArea = true; pBlock.SetGravityEnabledByDefault(true); if (!m_bDropBlocks) { CreateBlock(); } } }
public CBaseBlock CreateBlock() { CBaseBlock pBlock = m_pBlockSequencer.NextBlock(m_pBlockSequencer.GetTransform().position); pBlock.SetGravityEnabled(false); if (m_pBlockSequencer.NumGenerated() > 1 && m_bDropBlocks) { pBlock.TeleportDisplaced(new Vector3(0, 2, 0)); pBlock.m_bMoveDown = true; } return(pBlock); }
public override void Start() { base.Start(); m_qBlocks = new Queue <CBaseBlock>(); //get CBaseBlock references from objects I = g.ToBaseBlock(m_pI); O = g.ToBaseBlock(m_pO); T = g.ToBaseBlock(m_pT); L = g.ToBaseBlock(m_pL); S = g.ToBaseBlock(m_pS); }
/** * Duplicates the next piece to the given position */ public CBaseBlock NextBlock(Vector3 pos) { if (m_qBlocks.Count() == 0) { m_qBlocks = NextTetrisPieceSequence(); } CBaseBlock source = m_qBlocks.Dequeue(); CBaseBlock blk = g.ToBaseBlock(Instantiate(source.obj(), pos, obj().transform.rotation)); blk.m_pSource = source; m_iNumGeneratedBlocks++; return(blk); }
/** * Counts the total number of blocks instantiated from the given source. */ public static int countFromSource(CBaseBlock pSource) { int count = 0; for (int i = 0; i < CBaseEntity.g_aEntList.Count(); i++) { CBaseBlock pBlock = g.ToBaseEntity(i) as CBaseBlock; if (pBlock != null && pBlock.m_pSource == pSource) { count++; } } return(count); }
/** * Calls collider functions to detect what other CBaseEntity are colliding with this */ private void ReloadIntersecting() { float halfZ = m_flHeight / 2; float halfY = m_vMaxXYZ.y - m_vMinXYZ.y; float halfX = m_vMaxXYZ.x - m_vMinXYZ.x; Vector3 center = (m_vMinXYZ + m_vMaxXYZ) / 2; m_aIntersecting.Clear(); Collider[] colls = Physics.OverlapBox(center, new Vector3(halfX, halfY, halfZ)); foreach (Collider col in colls) { CBaseBlock ent = g.ToBaseBlock(col.gameObject); if (ent != null) { m_aIntersecting.Add(ent); } } }
//called when a block falls below the building platform public void OnBlockFall(CBaseBlock pBlock) { RestartRound(); }
//Called when a block exits the "veil" of the building area, //either bc the player took it out or the tower is falling down public void OnBlockExit(CBaseBlock pBlock) { }
public void OnBlockDropped(CBaseBlock pBlock) { UpdateDisplays(); }