public void Move() { const float WALL_RIGHT = -3.1f; const float WALL_LEFT = 3.1f; const float WALL_UP = 2.3f; const float WALL_DOWN = -2.0f; //Hit horizontal walls or move if (this.X <= WALL_RIGHT && this._State != BubbleState.Bouncing) { this._State = BubbleState.HitWallRight; } else if (this.X >= WALL_LEFT && this._State != BubbleState.Bouncing) { this._State = BubbleState.HitWallLeft; } else { this.X += this.NextX; } //Hit vertical walls or move if (this.Y <= WALL_DOWN && this._State != BubbleState.Bouncing) { this._State = BubbleState.HitWallDown; } else if (this.Y >= WALL_UP && this._State != BubbleState.Bouncing) { this._State = BubbleState.HitWallUp; } else { this.Y += this.NextY; } }
public void Init(int power, BubbleState bubbleState) { rb.bodyType = RigidbodyType2D.Kinematic; Power = power; SetState(bubbleState); }
private void onPromptButtonPressed(DPrompt.ButtonFlags pressed) { if (pressed != DPrompt.ButtonFlags.YES) { return; } LocomotionController currentController = LocomotionHelper.GetCurrentController(base.gameObject); if (currentController is SitController) { LocomotionHelper.SetCurrentController <SwimController>(base.gameObject); } bubbleState = BubbleState.TransitionToHidden; playAudioEvent(mutableData.AirCriticalAudioEvent, EventAction.StopSound); GameObject gameObject = GameObject.FindWithTag(UIConstants.Tags.UI_Tray_Root); if (gameObject != null) { StateMachineContext component = gameObject.GetComponent <StateMachineContext>(); if (component != null) { component.SendEvent(new ExternalEvent("Root", "noUI")); } } Invoke("startBubbleScreenWipe", 0.7f); swimController.ResurfaceAccepted(); dispatcher.DispatchEvent(default(DivingEvents.PlayerResurfaced)); }
// Update is called once per frame void Update() { switch (state) { case BubbleState.BS_HIDE: { transform.localScale = new Vector3(scale, scale, 1); } break; case BubbleState.BS_BUBBLE: { ScaleVal.Update(); BubbleVal.Update(); scale = ScaleVal.val; transform.localScale = new Vector3(ScaleVal.val, ScaleVal.val, 1); transform.rotation = Quaternion.Euler(0, 0, BubbleVal.val); if (ScaleVal.IsFinish() && BubbleVal.IsFinish()) { setButton(true); state = BubbleState.BS_FIX; } } break; case BubbleState.BS_FIX: { transform.localScale = new Vector3(scale, scale, 1); } break; } }
public Bubble(float xPos, float yPos, Dictionary<BubbleState,Texture2D> textureList, BubbleType bubbleType ) { currentState = BubbleState.APPEARING; this.textureList = textureList; this.pos = new Vector2(xPos, yPos); this.xPos = xPos; this.yPos = yPos; this.maxScale = 0.50f; this.bubbleType = bubbleType; //time required for the joint to stay in this bubble so that it will pop this.popTime = GameConfig.BUBBLE_POP_TIME; //alpha value, 1.0f is default this.alpha = 0.80f; //collision radius this.radius = 25; this.collisionBox = new Rectangle((int)xPos - radius, (int)yPos - radius, radius*2, radius*2); //the duration this bubble remains n screen //when duration is over, it will go to the disappearing state this.stayingDuration = GameConfig.BUBBLE_SOLO_DURATION; this.stayingDurationCtr = stayingDuration; }
private void Initialize(Direct3D.Device NewParentDevice, float NewX, float NewY, float NewZ) { //recreate the master sprites if they dont exist if (BubbleAccess.MasterBubbleSprite == null) { BubbleAccess.MasterBubbleSprite = new SpriteAccess(NewParentDevice, GameConfig.Files.Bubbles, 0, 0, 0, 32, 32, 64, 64, Color.FromArgb(0xFF, 0x00, 0x00, 0xFF), 0, 0); } if (BubbleAccess.MasterItemSprite == null) { BubbleAccess.MasterItemSprite = new SpriteAccess(NewParentDevice, GameConfig.Files.Items, 0, 0, 0, 32, 32, 128, 128, Color.FromArgb(0xFF, 0x00, 0x00, 0xFF), 0, 0); } this.X = NewX; this.Y = NewY; this.Z = NewZ; //have this bubble sprites refer to the master sprites this.BubbleSprite = new SpriteAccess(BubbleAccess.MasterBubbleSprite, this.X, this.Y, this.Z); this.ItemSprite = new SpriteAccess(BubbleAccess.MasterItemSprite, this.X, this.Y, this.Z); this._State = BubbleState.NeedsFreshAngle; this._Item = (ItemType)(int)((1.0f + (float)ItemType.Warp) * SpaceAndTime.RandomPercent); this.ItemSprite.Frame = (int)this._Item; }
public void BubbleMissed(BubbleState state) { if (++missedBubbles >= MaxBubblesMissed) { LevelState = ELevelState.Failed; } }
public void popup() { BubbleVal.morphBubble(0, 0, 20, 60, Delay); ScaleVal.morphEasein(0, fixScale, 15, Delay); state = BubbleState.BS_BUBBLE; setButton(false); }
private void InitSpeechBubble() { if (_initialized) { initAgain = false; if (!style.IsNone) { bubbleStyle = _skin.GetStyle(style.Value + "_" + System.Enum.GetName(typeof(CornerEnum), corner).ToLower()); if (bubbleStyle == null) { bubbleStyle = _skin.GetStyle(style.Value); } } else { bubbleStyle = _skin.GetStyle(_style + "_" + System.Enum.GetName(typeof(CornerEnum), corner).ToLower()); if (bubbleStyle == null) { bubbleStyle = _skin.GetStyle(_style); } } #if UNITY_IPHONE if (bubbleStyle != null) { bubbleStyle.fontSize = 0; bubbleStyle.fontStyle = FontStyle.Normal; } #endif if (!offset.IsNone) { bubbleOffset = offset.Value; } else { bubbleOffset = _offset; } bubbleOffsetVector = _offsetVector; if (!id.IsNone) { rawText = Lang.GetText( dictionary.IsNone ? "" : dictionary.Value, id.Value, text.IsNone ? "" : text.Value.Trim() ); lastLanguage = Lang.selectedLanguage; } else { rawText = text.IsNone ? "" : text.Value.Trim(); } Say(rawText); bubbleState = SpeechBubble.BubbleState.effectin; } else { initAgain = true; } }
public void InstantiateOpponentBubble(BubbleState bubbleState) { //for opponnent bubbles - right part of screen bubbleState.StartPosition = new Vector2(bubbleState.StartPosition.x + OpponentLevelBounds.x - PlayerLevelBounds.x , bubbleState.StartPosition.y); var bubbleObject = InstanatiateBubble(bubbleState); bubbleObject.generatedtTexture = TextureFactory.Instance.GetTexture(bubbleState.Size / level.BubblesSizeRange.y, true); opponentBubbles.Add(bubbleState.ID, bubbleObject); }
//更改内容 IEnumerator ChangeDialog() { state = BubbleState.waiting; yield return(new WaitForSeconds(Random.Range(minDialogInterval, maxDialogInterval))); targetString = data.contents[Random.Range(0, data.contents.Count)].dialogText; state = BubbleState.typing; OnShow?.Invoke(); }
void FixedUpdate() { float completed = 0f; switch (state) { case BubbleState.NOTHING: break; case BubbleState.DESTROYING: currenttime += Time.deltaTime; completed = 1f - currenttime / 0.2f; setAlpha(completed); setScale(completed); if (completed <= 0) { GameObject.Destroy(this.gameObject); } break; case BubbleState.SHOWING: Vector3 destination; if (finalPosition == null) { destination = Vector3.zero; } else { destination = finalPosition; } destination = Vector3.Lerp(this.bubblePos.anchoredPosition, destination, easing); destination.z = camZ; completed = 1f - (Vector2.Distance(destination, finalPosition) / distance); if (float.IsNaN(completed)) { completed = 1f; } setAlpha(completed); setScale(completed); this.bubblePos.anchoredPosition = destination; if (completed >= 1f) { this.state = BubbleState.NOTHING; } break; } }
private void handleEnteringFreeAirZone(Collider zoneCollider) { if (!targetColor.Equals(PLENTIFUL_AIR_BUBBLE_COLOR)) { turnPlentifulAreaTriggerLightsOn(zoneCollider.gameObject.GetComponent <FreeAirZone>(), isOn: true); bubbleState = BubbleState.TransitionToPlentifulAir; updateBubbleState(); State = DivingState.PlentifulAir; } }
public BubbleState GetBubble(Vector4 LevelBounds) { var bubble = new BubbleState(); bubble.Size = UnityEngine.Random.Range(BubblesSizeRange.x, BubblesSizeRange.y); var posX = UnityEngine.Random.Range(LevelBounds.x + bubble.Size / 2f, bubble.Size / 2f); var posY = LevelBounds.w - bubble.Size / 2f; bubble.StartPosition = new Vector2(posX, posY); bubble.Speed = LevelNumber * LevelSpeed + Mathf.Lerp(BubblesSpeedRange.y, BubblesSpeedRange.x, bubble.Size / BubblesSizeRange.y); return bubble; }
//Coroutime to make Gregg walk off-camera public IEnumerator greggDisappearHelper() { _bubbleState = BubbleState.APPEARING; yield return(new WaitForSeconds(4)); _bubbleState = BubbleState.DISAPPEARING; yield return(new WaitForSeconds(3)); _greggState = GreggState.DISAPPEARING; }
void Awake() { bubbleState = BubbleState.Waiting; verticalValues = new List <float>(); // Vertical values contains every possible position that bubble can be stay. for (int i = 0; i < 17; i++) { verticalValues.Add(minimunVerticalValue + (verticalOffset * i)); } }
public SlotInfo(Vector2Int v, SlotType sType, BubbleType type, BubbleState state, GameObject bubble, Vector3 loc, GameObject entity) { Pos = v; slotType = sType; InsideBubbleType = type; InsideBubbleState = state; ConnectedBubble = bubble; Location = loc; Entity = entity; }
private IEnumerator InitializeBubbleCoroutine(string path, GameObject prefab) { bubble = UnityEngine.Object.Instantiate(prefab); bubble.SetActive(value: false); Transform jnt = null; while (jnt == null) { jnt = base.transform.Find("hips_jnt/backbone_jnt/chest_jnt/neck_jnt"); yield return(new WaitForEndOfFrame()); } CameraFacingController cameraFacingController = bubble.GetComponent <CameraFacingController>(); if (cameraFacingController != null) { cameraFacingController.AttachPoint = jnt; bubble.transform.SetParent(base.gameObject.transform, worldPositionStays: false); } else { bubble.transform.SetParent(jnt.transform, worldPositionStays: false); bubble.transform.position = jnt.transform.position; } bubble.SetActive(value: true); swimController = GetComponent <SwimController>(); bubbleMaterial = bubble.GetComponentInChildren <MeshRenderer>().material; float totalAirQuantity = 10f - AirThreshold; warningThreshold = AirThreshold + totalAirQuantity * 0.4f; dangerThreshold = AirThreshold + totalAirQuantity * 0.2f; bubbleState = getStartingBubbleState(AirSupply); updateBubbleState(); if (isLocalPlayer) { CoroutineRunner.Start(UpdateLocalPlayerBubbleCoRoutine(), this, "UpdateLocalPlayerBubbleCoRoutine"); CoroutineRunner.Start(SyncAirSupplyNetwork(), this, "SyncAirSupplyNetwork"); yield break; } DataEntityHandle handle = GetComponent <AvatarDataHandle>().Handle; if (!handle.IsNull) { AirBubbleData component = dataEntityCollection.GetComponent <AirBubbleData>(handle); if (component != null) { dataEntityCollection.GetComponent <AirBubbleData>(handle).AirBubbleChanged += OnRemotePlayerAirBubbleChanged; } else { Log.LogError(this, "Failed to get the air bubble data for the remote player"); } } }
void Start() { buttonObjList = GetComponents <ButtonObject> (); BubbleVal = new MorphObject(); ScaleVal = new MorphObject(); state = BubbleState.BS_HIDE; scale = 0; fixScale = transform.localScale.x; transform.localScale = new Vector3(scale, scale, 1); popup(); //Debug.Log ("BubbleScale = " + fixScale); }
// Update is called once per frame void Update() { if (preset == true) { preset = false; bubbleState = BubbleState.Stopped; Destroy(currentBody); //Play Bounce off marshmellow sound FindObjectOfType <AudioManager>().Play("Bounce"); transform.localRotation = Quaternion.identity; Vector3 thePosition = transform.localPosition; thePosition.x = Mathf.Round(thePosition.x); thePosition.y = Mathf.Floor(thePosition.y); //Debug.Log("[OnCollisionEnter] Before Round:" + thePosition); if (thePosition.y % 2 >= 1) { if (thePosition.x + horizontalOffset >= maximunHorizontalValue) { thePosition.x = maximunHorizontalValue; } else { thePosition.x += horizontalOffset; } } else { if (thePosition.x + horizontalOffset >= maximunHorizontalValue) { thePosition.x = maximunHorizontalValue - horizontalOffset; } } Debug.Log("[OnCollisionEnter]Position: " + Mathf.FloorToInt(thePosition.y) + " - " + 1 + " = " + (Mathf.FloorToInt(thePosition.y) - 1)); thePosition.y = verticalValues[(Mathf.FloorToInt(thePosition.y) - 1)]; Debug.Log("[OnCollisionEnter] After Round:" + thePosition); transform.localPosition = Vector3.one * 100; //The offset will be set in the returnCorrectPosition after check where bubble can be place. transform.localPosition = returnCorretPosition(thePosition); } }
// Use this for initialization void Start() { //resize (); text = this.transform.Find("Text"); text.GetComponent <Text>().text = data.Line; rectTransform = this.GetComponent <RectTransform>(); /*float guiscale = Screen.height/600f; * * text.GetComponent<Text>().fontSize = Mathf.RoundToInt(guiscale * 20);*/ this.rectTransform.anchoredPosition = data.origin; this.moveTo(data.destiny); this.state = BubbleState.SHOWING; }
private void updateAirSupplyLocalPlayer() { lerpAirSupply(0.01f); if (AirSupply < AirThreshold && !swimController.TriggerResurface && bubbleState != BubbleState.Hidden) { swimController.TriggerResurface = true; bubbleState = BubbleState.TransitionToHidden; if (swimController.CurState != SwimController.State.Resurfacing) { playAudioEvent(mutableData.AirCriticalAudioEvent, EventAction.StopSound); Invoke("startBubbleScreenWipe", 2f); } } dispatcher.DispatchEvent(new DivingEvents.AirSupplyUpdated(AirSupply)); }
/// <summary> /// Initialization method. /// Set up the image, text and audio of the bubble. /// </summary> protected void Start() { currentVelocity = Vector3.zero; canvasRectTransform = transform.parent.GetComponent <RectTransform>(); // Image set up if (Data.Image) { image.texture = Data.Image; // In case of a LayoutElement is present in the image, we set up its sizes var layoutElement = image.GetComponent <LayoutElement>(); if (layoutElement) { // The height and width of the element will be fixed to the height, but the image has to adjust // its width based on the image ratio var ratio = Data.Image.width / (float)Data.Image.height; var height = Mathf.Min(Height, Mathf.Min(Height, Data.Image.width) / ratio); var width = height * ratio; layoutElement.preferredHeight = height; layoutElement.preferredWidth = width; } } // Audio set up if (Data.Audio) { audioSource.clip = Data.Audio; audioSource.Play(); } // Text set up if (!string.IsNullOrEmpty(Data.Line)) { SetTextProgress(0); } // We set up the screen position (anchored position) using the origin screen position to make the bubble // pop up from the character of specified location this.rectTransform.anchoredPosition = Data.origin; this.MoveTo(Data.destiny); // Make sure the state is showing when started unless it's being destroyed (due to fast clicking for example) if (this.state != BubbleState.DESTROYING) { this.state = BubbleState.FADING; completed = 0; } }
public bool CheckPlayerCollisions(PlayableCharacterAccess Player) { bool RetVal = false; //Dont bother checking with bubbles that are popped if (this._State != BubbleState.Popped && this._State != BubbleState.Popping) { if (this.BubbleSprite.CollisionRects.CheckObjectRectAgainst(Player, this.BubbleSprite.Frame, this.X, this.Y) != CollisionRectAccess.HitSide.None) { this._State = BubbleState.Popping; RetVal = true; } } return(RetVal); }
private void ActionPop() { // Pop 0 to 3 if (this.BubbleSprite.Frame < 0 || this.BubbleSprite.Frame > 3) { this.BubbleSprite.Frame = 0; } else if (this.BubbleSprite.Frame == 3) { this._State = BubbleState.Popped; } else { this.BubbleSprite.Frame++; } }
void CheckMouseExit() { RaycastHit hitInfo = ActionHelpers.MousePick(rayDistance, ActionHelpers.LayerArrayToLayerMask(layerMask, invertMask)); bool didPick = hitInfo.collider != null; if (didPick == false) { mouseExit = true; bubbleState = SpeechBubble.BubbleState.effectout; } else { if (go.name != hitInfo.collider.gameObject.name) { mouseExit = true; bubbleState = SpeechBubble.BubbleState.effectout; } } }
//打字 void UpdateContentString() { timerValue += Time.deltaTime * typingSpeed; int timer = Mathf.Min(Mathf.FloorToInt(timerValue), targetString.Length); if (timer != lastTimerValue) { lastTimerValue = timer; var tempString = targetString.Substring(0, timer); OnTyping?.Invoke(tempString); } if (timer == targetString.Length) { state = BubbleState.show; timerValue = 0; return; } }
public void ChangeState() { if (this._State == BubbleState.NeedsFreshAngle) { this.ActionGetFirstAngle(); } else if (this._State == BubbleState.Popping) { this.ActionPop(); } else if (this._State == BubbleState.Bouncing) { this._State = BubbleState.Floating; } else if (this._State >= BubbleState.HitWallUp && this._State <= BubbleState.HitWallLeft) { this.ActionBounceOffWall(); } }
public void SetState(BubbleState newState, float?customTransitionDuration = null) { Color targetColor; bool targetTrailTurnedOn = false; switch (newState) { case BubbleState.GUN: SetInteractible(false); targetColor = bubblesConfig.bubbleGunColor; targetTrailTurnedOn = true; break; case BubbleState.GUN_ALT: SetInteractible(true); targetColor = bubblesConfig.bubbleGunAltColor; targetTrailTurnedOn = false; break; case BubbleState.GRID: SetInteractible(true); targetColor = bubblesConfig.bubbleGridColor; targetTrailTurnedOn = false; break; case BubbleState.DYING: SetInteractible(false); targetColor = bubblesConfig.bubbleGridColor; targetTrailTurnedOn = false; break; default: Debug.LogWarning($"Unknown state {newState}"); targetColor = Color.white; break; } renderer.DOKill(true); float transitionDuration = customTransitionDuration.HasValue ? customTransitionDuration.Value : animationCfg.bubbleChangeColorDuration; renderer.DOColor(targetColor, transitionDuration).SetEase(animationCfg.bubbleChangeColorEase) .OnComplete(() => trail.gameObject.SetActive(targetTrailTurnedOn)); }
public override void Update(GameTime gameTime) { base.Update(gameTime); if (Age > MaxAge - 2) { _frameTimer += gameTime.ElapsedGameTime.TotalMilliseconds; if (_frameTimer > FrameTime) { _frameTimer = 0; if (_state == BubbleState.Explode1) { _state = BubbleState.Explode2; } else { _state = BubbleState.Explode1; } } } }
public override void Update(GameTime gameTime) { base.Update(gameTime); if (Age > MaxAge - 2) { _frameTimer += gameTime.ElapsedGameTime.TotalMilliseconds; if (_frameTimer > FrameTime) { _frameTimer = 0; if (_state == BubbleState.Explode1) { _state = BubbleState.Explode2; } else { _state = BubbleState.Explode1; } } } }
private void ActionBounceOffWall() { if (this._State == BubbleState.HitWallDown) { this.NextY = -this.NextY; } else if (this._State == BubbleState.HitWallUp) { this.NextY = -this.NextY; } else if (this._State == BubbleState.HitWallRight) { this.NextX = -this.NextX; } else if (this._State == BubbleState.HitWallLeft) { this.NextX = -this.NextX; } this._State = BubbleState.Bouncing; }
// Update is called once per frame void Update() { if (state == BubbleState.off) { StartCoroutine(ChangeDialog()); } if (state == BubbleState.typing) { UpdateContentString(); } if (state == BubbleState.show) { dialogTimer += Time.deltaTime; if (dialogTimer >= dialogTime) { dialogTimer = 0; state = BubbleState.off; OnOff?.Invoke(); } } }
// Use this for initialization void Start() { //Image if (data.Image) { image = this.transform.Find("RawImage"); image.GetComponent <RawImage>().texture = data.Image; var layoutElement = image.GetComponent <LayoutElement>(); var ratio = data.Image.width / (float)data.Image.height; var height = Mathf.Min(240f, Mathf.Min(240f, data.Image.width) / ratio); var width = height * ratio; layoutElement.preferredHeight = height; layoutElement.preferredWidth = width; } //Audio if (data.Audio) { var audioSource = GetComponent <AudioSource>(); audioSource.clip = data.Audio; audioSource.Play(); } //resize (); text = this.transform.Find("Text"); text.GetComponent <Text>().text = data.Line; rectTransform = this.GetComponent <RectTransform>(); /*float guiscale = Screen.height/600f; * * text.GetComponent<Text>().fontSize = Mathf.RoundToInt(guiscale * 20);*/ this.rectTransform.anchoredPosition = data.origin; this.moveTo(data.destiny); if (this.state != BubbleState.DESTROYING) { this.state = BubbleState.SHOWING; } }
public override void OnEnter() { go = gameObject.OwnerOption == OwnerDefaultOption.UseOwner ? Owner : gameObject.GameObject.Value; if (go == null) { Finish(); return; } delayTmp = delay.IsNone ? 0f : delay.Value; timeTmp = time.IsNone ? 0f : time.Value; depthTmp = depth.IsNone ? _guiDepth : depth.Value; waitForAudioFinish = false; alpha = 0f; bubbleState = SpeechBubble.BubbleState.none; audioFinished = false; if (!id.IsNone) { lastId = id.Value; } if (!audioGameObject.IsNone) { goaudio = audioGameObject.Value; } if (goaudio == null) { goaudio = go; } if (goaudio) { if (goaudio.audio) { audioSourceVolume = goaudio.audio.volume; } } audioStarted = false; audioDelaySet = false; InitSpeechBubble(); }
public override void OnUpdate(){ if(everyFrame) ReInitSayText(); if(bubbleState != SpeechBubble.BubbleState.finishing){ if(delayTmp >= 0f) { delayTmp -= Time.deltaTime; } else { if(mouseExit) CheckMouseExit(); if((lastLanguage != Lang.selectedLanguage) || (!id.IsNone && lastId != id.Value)){ lastLanguage = Lang.selectedLanguage; if(!id.IsNone) { lastId = id.Value; rawText = Lang.GetText( dictionary.IsNone ? "" : (dictionary.Value + (_appendLanguage ? "_" + Lang.selectedLanguage.ToString() : "")), id.Value, text.IsNone ? "" : text.Value.Trim() ); } else { rawText = text.IsNone ? "" : text.Value.Trim(); } Say(rawText); } if(_initialized && delayTmp < 0f ){ if(!audioDelaySet){ audioDelayTmp = audioDelay.IsNone ? _audioDelay : audioDelay.Value; audioDelaySet = true; } if(!audioStarted) { if(audioDelayTmp > 0f){ audioDelayTmp -= Time.deltaTime; } else { PlayAudio(); audioStarted = true; } } if(bubbleState == SpeechBubble.BubbleState.effectin && alpha <= 1f) { alpha += (1f/(fadeIn.IsNone ? _fadeIn : fadeIn.Value))*Time.deltaTime; if(alpha > 1f) { alpha = 1f; bubbleState = SpeechBubble.BubbleState.bubble; } if(fadeAudioIn) if(goaudio && goaudio.audio) { goaudio.audio.volume = audioSourceVolume + (((volume.IsNone? _volume : volume.Value) - audioSourceVolume) * alpha); } } if(bubbleState == SpeechBubble.BubbleState.effectout && alpha >= 0f) { alpha -= (1f/(fadeOut.IsNone ? _fadeOut : fadeOut.Value))*Time.deltaTime; if(alpha < 0f) { alpha = 0f; bubbleState = SpeechBubble.BubbleState.finishing; Finish(); if(audioFinished) { if(audioFinishedEvent != null) Fsm.Event(audioFinishedEvent); } else { if(finishedEvent != null) Fsm.Event(finishedEvent); } } if(fadeAudioOut) if(goaudio && goaudio.audio) goaudio.audio.volume = (volume.IsNone? _volume : volume.Value) * alpha; return; } } if(!time.IsNone && bubbleState != SpeechBubble.BubbleState.effectout) { if(timeTmp > 0f) { timeTmp -= Time.deltaTime; } else { bubbleState = SpeechBubble.BubbleState.effectout; } } } if(!greaterThanFinish.IsNone && goaudio != null){ if(goaudio.audio != null && goaudio.audio.clip != null){ if(goaudio.audio.isPlaying && goaudio.audio.time > greaterThanFinish.Value - (fadeOut.IsNone ? _fadeOut : fadeOut.Value)) { audioFinished = true; bubbleState = SpeechBubble.BubbleState.effectout; } } } if(waitForAudioFinish && bubbleState != SpeechBubble.BubbleState.effectout) { if(audio.isPlaying && audio.time > audio.clip.length - (fadeOut.IsNone ? _fadeOut : fadeOut.Value)) { audioFinished = true; bubbleState = SpeechBubble.BubbleState.effectout; } } } }
void CheckMouseExit(){ RaycastHit hitInfo = ActionHelpers.MousePick(rayDistance, ActionHelpers.LayerArrayToLayerMask(layerMask, invertMask)); bool didPick = hitInfo.collider != null; if(didPick == false){ mouseExit = true; bubbleState = SpeechBubble.BubbleState.effectout; } else { if(go.name != hitInfo.collider.gameObject.name){ mouseExit = true; bubbleState = SpeechBubble.BubbleState.effectout; } } }
private void InitSpeechBubble(){ if(_initialized){ initAgain = false; if(!style.IsNone) { bubbleStyle = _skin.GetStyle(style.Value + "_" + System.Enum.GetName(typeof(CornerEnum), corner).ToLower()); if(bubbleStyle == null) bubbleStyle = _skin.GetStyle(style.Value); } else { bubbleStyle = _skin.GetStyle(_style + "_" + System.Enum.GetName(typeof(CornerEnum), corner).ToLower()); if(bubbleStyle == null) { bubbleStyle = _skin.GetStyle(_style); } } #if UNITY_IPHONE if(bubbleStyle != null) { bubbleStyle.fontSize = 0; bubbleStyle.fontStyle = FontStyle.Normal; } #endif if(!offset.IsNone) bubbleOffset = offset.Value; else bubbleOffset = _offset; bubbleOffsetVector = _offsetVector; if(!id.IsNone) { rawText = Lang.GetText( dictionary.IsNone ? "" : dictionary.Value, id.Value, text.IsNone ? "" : text.Value.Trim() ); lastLanguage = Lang.selectedLanguage; } else { rawText = text.IsNone ? "" : text.Value.Trim(); } Say(rawText); bubbleState = SpeechBubble.BubbleState.effectin; } else { initAgain = true; } }
public override void OnEnter() { go = gameObject.OwnerOption == OwnerDefaultOption.UseOwner ? Owner : gameObject.GameObject.Value; if(go == null) { Finish(); return; } delayTmp = delay.IsNone ? 0f : delay.Value; timeTmp = time.IsNone ? 0f : time.Value; depthTmp = depth.IsNone ? _guiDepth : depth.Value; waitForAudioFinish = false; alpha = 0f; bubbleState = SpeechBubble.BubbleState.none; audioFinished = false; if(!id.IsNone) lastId = id.Value; if(!audioGameObject.IsNone) goaudio = audioGameObject.Value; if(goaudio == null) goaudio = go; if(goaudio) if(goaudio.audio) audioSourceVolume = goaudio.audio.volume; audioStarted = false; audioDelaySet = false; InitSpeechBubble(); }
private void updateCounter() { stayingDurationCtr--; if (stayingDurationCtr <= 0) { this.currentState = BubbleState.DISAPPEARING; } }
public void setState(BubbleState newState) { currentState = newState; }
public void Update() { updateCounter(); switch (currentState) { case BubbleState.NORMAL_STATE: popCounter = 0; break; case BubbleState.HIGHLIGHTED_STATE: if (this.bubbleType != BubbleType.INACTIVE_STATIC_HAND) { popCounter += 1; if (popCounter >= popTime) { currentState = BubbleState.POP_STATE; } } break; case BubbleState.APPEARING: if (scale < 0.60f){ scale += 0.05f; } else if (scale > 0.50f && scale < 0.60f) { scale = maxScale; } else { currentState = BubbleState.NORMAL_STATE; } break; case BubbleState.POP_STATE: scale += 0.03f; alpha -= 0.02f; if (alpha <= 0) { currentState = BubbleState.REMOVAL_STATE; } break; case BubbleState.DISAPPEARING: scale -= 0.01f; alpha -= 0.02f; if (alpha <= 0) { currentState = BubbleState.REMOVAL_STATE; } break; case BubbleState.REMOVAL_STATE: alpha = 0; break; } }
public void destroy() { this.state = BubbleState.DESTROYING; }
// Stop on game board. private void StopOnBoard(Bubble collidedBubble) { Rigidbody2D rb = GetComponent<Rigidbody2D> (); rb.velocity = Vector2.zero; rb.isKinematic = true; // Snap this bubble to game board. this.GameBoard.SnapBubble (this, collidedBubble); // Erase and fall bubbles if possible. this.GameBoard.EraseAndFall (this); // Set stopping flag. this.State = BubbleState.Stopped; // Load a new bubble. this.BubbleLauncher.LoadBubble (); }
private BubbleObject InstanatiateBubble(BubbleState bubbleState) { var bubbleObject = (Instantiate(BubblePrefab) as GameObject).GetComponent<BubbleObject>(); bubbleObject.BubbleState = bubbleState; return bubbleObject; }
public void BubbleBursted(BubbleState state) { this.levelScore += (int)(state.Size * 1000); //People love big numbers! }
// Use this for initialization void Start() { //resize (); text = this.transform.FindChild ("Text"); text.GetComponent<Text> ().text = data.Line; bubblePos = this.GetComponent<RectTransform> (); /*float guiscale = Screen.height/600f; text.GetComponent<Text>().fontSize = Mathf.RoundToInt(guiscale * 20);*/ this.bubblePos.anchoredPosition = data.origin; this.moveTo (data.destiny); this.state = BubbleState.SHOWING; }
void MessageHandler(string msg) { var blocks = msg.Split(Connection.MESSAGE_SEPARATOR.ToCharArray(), 2); var messageType = Helper.StringToEnum<EMessageType>(blocks[0], EMessageType.Unknown); switch (messageType) { case EMessageType.GetName: { OtherPlayer.SendMessage(EMessageType.SendName.ToString(), PlayerName); break; } case EMessageType.SendName: { OtherPlayerName = blocks[1]; break; } case EMessageType.Ready: { if (GameStatus == EGameStatus.WaitingForAnswer) { gameController.StartLevel(); GameStatus = EGameStatus.Playing; } else { GameStatus = EGameStatus.OpponentReady; } break; } case EMessageType.BubbleCreated: { var bubbleState = new BubbleState(); bubbleState.DeserializeFromString(blocks[1]); gameController.InstantiateOpponentBubble(bubbleState); break; } case EMessageType.BubbleBursted: { int id = int.Parse(blocks[1]); gameController.OpponetBubbleBursted(id); break; } case EMessageType.BubbleMissed: { int id = int.Parse(blocks[1]); gameController.OpponentBubbleMissed(id); break; } case EMessageType.GameLost: { gameController.StopLevel(); GameStatus = EGameStatus.GameFinished; break; } case EMessageType.ReplayGame: { gameController.RestartLevel(); GameStatus = EGameStatus.Playing; break; } case EMessageType.Leave: { ResetGame(); break; } default: { Logger.LogWarning("Unknown state: " + blocks[0]); break; } } }
void FixedUpdate() { float completed = 0f; switch (state) { case BubbleState.NOTHING: break; case BubbleState.DESTROYING: currenttime += Time.deltaTime; completed = 1f - currenttime / 0.2f; setAlpha (completed); setScale (completed); if (completed <= 0) { GameObject.Destroy (this.gameObject); } break; case BubbleState.SHOWING: Vector3 destination; if (finalPosition == null) { destination = Vector3.zero; } else { destination = finalPosition; } destination = Vector3.Lerp (this.bubblePos.anchoredPosition, destination, easing); destination.z = camZ; completed = 1f - (Vector2.Distance (destination, finalPosition) / distance); if (float.IsNaN (completed)) completed = 1f; setAlpha (completed); setScale (completed); this.bubblePos.anchoredPosition = destination; if (completed >= 1f) { this.state = BubbleState.NOTHING; } break; } }