/// <summary> /// Tweens: When gem explodes /// </summary> public void TweenToNewPositionExit() { // ADD PHYSICS TO THIS (OTHERWISE NON-PHYSICS GAME) JUST TO GET A NICE FALLING GEM APPEARANCE gameObject.AddComponent <Rigidbody2D>(); gameObject.GetComponent <BoxCollider2D>().enabled = false; gameObject.GetComponent <Rigidbody2D>().AddForce(TripleMatchConstants.GetGemExitPhysicsForce()); Destroy(gameObject, 3); _ShrinkAndExplode(); }
//-------------------------------------- // Constructor / Creation //-------------------------------------- //-------------------------------------- // Unity Methods //-------------------------------------- /// <summary> /// Start this instance. /// </summary> protected void Start() { ParticleSystem _particleSystem; GameObject particleSystemPrefabInstance; int particleSystemPrefabIndex_int = 0; // SETUP FOR 1 OR EVEN MORE PARTICLES TO WORK CONCURRENTLY... foreach (GameObject particleSystemPrefab in _particleSystemPrefabs) { particleSystemPrefabInstance = Instantiate(particleSystemPrefab) as GameObject; particleSystemPrefabInstance.transform.localPosition = new Vector3(0, 0, 0); //Some CFX prefabs are not at 0,0,0. Correct that. particleSystemPrefabInstance.transform.SetParent(transform, false); // _particleSystem = particleSystemPrefabInstance.GetComponent <ParticleSystem>(); TripleMatchConstants.InitializeParticleSystemForUnity46X(_particleSystem); particleSystemPrefabIndex_int++; } }
//-------------------------------------- // Constructor //-------------------------------------- /// <summary> /// Initialize the specified model and controller. /// </summary> /// <param name="model">Model.</param> /// <param name="controller">Controller.</param> override public void Initialize(Model model, Controller controller) { base.Initialize(model, controller); _model.OnTimeLeftInRoundChanged += _OnTimeLeftInRoundChanged; _model.OnTimeLeftInRoundExpired += _OnTimeLeftInRoundExpired; _model.OnGameResetted += _OnGameResetted; _sparksPercentageThroughPath_float = 0; ParticleSystem spark_particlesystem = _spark_gameobject.GetComponentInChildren <ParticleSystem>(); TripleMatchConstants.InitializeParticleSystemForUnity46X(spark_particlesystem); // //DYNAMITE IS 2+ PREFABS, SO SET EACH UP AND PLAY THEM LATER foreach (ParticleSystem particleSystemInstance in _dynamite_gameobject.GetComponentsInChildren <ParticleSystem>()) { TripleMatchConstants.InitializeParticleSystemForUnity46X(particleSystemInstance); particleSystemInstance.Stop(); } }
/// <summary> /// Reward one match. /// </summary> private void _RewardOneMatchFromGemVOList(List <GemVO> gemVOs) { List <GemViewComponent> gemViews = new List <GemViewComponent>(); //TODO: replace with linq for brevity GemViewComponent nextGemView; foreach (GemVO gemVO in gemVOs) { nextGemView = _GetGemViewForGemVo(gemVO); // The null-check is because // some match shapes like... // M // MMM // M // ...will destroy 3 horizontally, THEN just 2 vertically (or vice versa), // Instead of 3 then 3. This is ok. // if (nextGemView != null) { gemViews.Add(nextGemView); } } // Find centerpoints from the GameObjects of the GemViewComponents. Vector3 centerPointOfMatch_vector3 = TripleMatchConstants.GetCenterPointVector3FromGameObjectsList ( gemViews.Select(gvc => gvc.gameObject).ToList <GameObject>() ); // CREATE AND REPARENT _hudView.RewardOneMatch ( //NOTE: its important to NOT use the gemView count since some are being destroy // in arbitrary order during this time-frame // and their count may not be accurate. So we use gemVOs.count. Good! TripleMatchConstants.GetScoreRewardForMatchOfLength(gemVOs.Count), centerPointOfMatch_vector3 ); foreach (GemViewComponent gemView in gemViews) { gemView.TweenToNewPositionExit(); _gemViews.Remove(gemView); } if (AudioManager.IsInstantiated()) { AudioManager.Instance.PlayAudioResourcePath(TripleMatchConstants.PATH_GEM_EXPLOSION_AUDIO); } _controller.SetIsInputEnabledToFalse(); //local variable for readability bool willAllowConcurrentCalls_bool = false; CoroutineManager.Instance.WaitForSecondsToCall(_controller.SetIsInputEnabledToTrue, TripleMatchConstants.DURATION_DELAY_AFTER_MATCH_FOUND_BEFORE_INPUT_ENABLED, willAllowConcurrentCalls_bool); }
/// <summary> /// Tweens: When gem enters the screen for the first time. /// </summary> public void TweenToNewPositionEntry() { _TweenToNewPosition(TripleMatchConstants.GetGemTweenEntryDelay(_gemVO), _GetTargetPosition(), "_OnTweenToNewPositionEntryCompleted"); }