protected void OnSuccess() { // get player's position GameObject player = Mgr <Scene> .Singleton._gameObjectList.GetOneGameObjectByName( m_playerGameObjectName); if (player == null) { return; } // create and config destination object GameObject prefab = Mgr <CatProject> .Singleton.prefabList.GetItem(m_destinationPrefabName); Serialable.BeginSupportingDelayBinding(); GameObject destinationGameObject = prefab.DoClone() as GameObject; Serialable.EndSupportingDelayBinding(); // set position destinationGameObject.Position = new Vector3( player.AbsPosition.X + 3.0f, destinationGameObject.Position.Y, destinationGameObject.Position.Z); Mgr <Scene> .Singleton._gameObjectList.AddGameObject( destinationGameObject); }
// move to child private void CreateFly(GameObject _blockGameObject, int _index) { GameObject prefab = Mgr <CatProject> .Singleton.prefabList.GetItem(m_flyPrefabName); _blockGameObject.ForceUpdateAbsTransformation(); //float randy = (float)m_rand.NextDouble() * m_blockWidth; Serialable.BeginSupportingDelayBinding(); GameObject fly = prefab.DoClone() as GameObject; fly.Position = _blockGameObject.AbsPosition + new Vector3(0.0f, m_flyHeight, 0.0f); Mgr <Scene> .Singleton._gameObjectList.AddGameObject(fly); ButterflyController bfc = fly.GetComponent(typeof(ButterflyController).ToString()) as ButterflyController; if (bfc != null) { bfc.HorizontalVelocity += (float)(m_rand.NextDouble() * 2.0f - 1.0f) * m_flyHorizontalVelocityBias; } Serialable.EndSupportingDelayBinding(); }
private void CreateRelic(GameObject _blockGameObject, int _index) { GameObject prefab = Mgr <CatProject> .Singleton.prefabList.GetItem(m_relicName); _blockGameObject.ForceUpdateAbsTransformation(); Serialable.BeginSupportingDelayBinding(); GameObject relic = prefab.DoClone() as GameObject; relic.Position = new Vector3((float)m_rand.NextDouble() * m_blockWidth, relic.Position.Y, relic.Position.Z); relic.AttachToGameObject(_blockGameObject); Mgr <Scene> .Singleton._gameObjectList.AddGameObject(_blockGameObject); Serialable.EndSupportingDelayBinding(); }
private GameObject CreateBlock(int _index) { GameObject prefab = Mgr <CatProject> .Singleton.prefabList.GetItem(m_blockPrefabName); Serialable.BeginSupportingDelayBinding(); GameObject newGameObject = prefab.DoClone() as GameObject; Serialable.EndSupportingDelayBinding(); newGameObject.Position = new Vector3( _index * m_blockWidth, newGameObject.Position.Y, newGameObject.Position.Z); newGameObject.AttachToGameObject(m_gameObject); // do post create block PostCreatGameObject(newGameObject, _index); Mgr <Scene> .Singleton._gameObjectList.AddGameObject(newGameObject); return(newGameObject); }
// move to child private void CreateStack(GameObject _blockGameObject, int _index, int _stackNum = 2) { GameObject prefab = Mgr <CatProject> .Singleton.prefabList.GetItem(m_barrierPrefabName); _blockGameObject.ForceUpdateAbsTransformation(); Random ran = new Random(_index); float randx = (float)ran.NextDouble() * m_blockWidth; Serialable.BeginSupportingDelayBinding(); for (int i = 0; i < _stackNum; ++i) { GameObject barrier = prefab.DoClone() as GameObject; barrier.Position = _blockGameObject.AbsPosition + new Vector3(randx, 0.4f + 0.1f * i, 0.0f); Mgr <Scene> .Singleton._gameObjectList.AddGameObject(barrier); } Serialable.EndSupportingDelayBinding(); }
private void CreateWildGoose(GameObject _blockGameObject, int _index, int _num) { GameObject prefab = Mgr <CatProject> .Singleton.prefabList.GetItem(m_wildgoosePrefabName); _blockGameObject.ForceUpdateAbsTransformation(); Random ran = new Random(_index); float randx = (float)ran.NextDouble() * m_blockWidth; Serialable.BeginSupportingDelayBinding(); for (int i = 0; i < _num; ++i) { GameObject wildgoose = prefab.DoClone() as GameObject; wildgoose.Position = new Vector3(randx + 0.05f * i, m_wildgooseHeight + (float)ran.NextDouble() * 0.02f, 0.0f); wildgoose.AttachToGameObject(_blockGameObject); Mgr <Scene> .Singleton._gameObjectList.AddGameObject(wildgoose); } Serialable.EndSupportingDelayBinding(); }