protected void ClearVisualEffects(bool clearModels) { GameObject effectObject = null; SimpleAnimator effectAnimator = null; if (visualEffectObjects != null) { for (int i = 0; i < visualEffectObjects.Length; i++) { effectAnimator = visualEffectAnimators[i]; effectAnimator.Clear(); visualEffectAnimators[i] = null; effectObject = visualEffectObjects[i]; Destroy(effectObject); visualEffectObjects[i] = null; } visualEffectAnimators = null; visualEffectObjects = null; } if (clearModels) { projectileLaunchFront = null; projectileLaunchBack = null; } }
void Awake() { anim = gameObject.GetComponent <Animator>(); sa = gameObject.GetComponentInParent <SimpleAnimator>(); point = transform.Find("Point"); point.localPosition = new Vector3(1.5f, 10.5f, 0f); }
private void CreateDebris(float offsetX, float offsetY) { GameObject newDebrisObject = null; SimpleAnimator newDebrisAnimator = null; float originX = 0f; float originY = 0f; newDebrisObject = Instantiate(debrisModel, Vector3.zero, Quaternion.identity) as GameObject; if (newDebrisObject != null) { newDebrisAnimator = newDebrisObject.GetComponent <SimpleAnimator>(); if (newDebrisAnimator != null) { newDebrisObject.transform.SetParent(transform, false); originX = -1f * (colliderWidth / 2f); originY = colliderHeight / 2f; newDebrisObject.transform.localPosition = new Vector3(originX + offsetX, originY + offsetY, -debrisDepth); UsefulFunctions.IncreaseArray <GameObject>(ref debrisObjects, newDebrisObject); UsefulFunctions.IncreaseArray <SimpleAnimator>(ref debrisAnimators, newDebrisAnimator); Debug.Log("Debug : ObstacleController : created debris with offsets (" + offsetX + ", " + offsetY + ")."); } else { Destroy(newDebrisObject); } } }
// Start is called before the first frame update void Start() { gameController = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>(); anim = GetComponent <SimpleAnimator>(); anim.Reset(); anim.spriteRenderer.sortingOrder = (int)(-transform.position.y * 100); }
private void Awake() { animator = GetComponentInChildren<SimpleAnimator>(); rbody2D = GetComponent<Rigidbody2D>(); nsystem = GameObject.FindGameObjectWithTag("Scene").GetComponent<NotesSystem>(); dsystem = GameObject.FindGameObjectWithTag("Scene").GetComponent<DialogueSystem>(); }
public void Clear() { SimpleAnimator effect = null; GameObject effectObject = null; if (effects != null) { for (int i = 0; i < effects.Length; i++) { effect = effects[i]; if (effect != null) { effect.Clear(); effect = null; effects[i] = null; } } effects = null; } if (effectObjects != null) { for (int i = 0; i < effectObjects.Length; i++) { effectObject = effectObjects[i]; if (effectObject != null) { GameObject.Destroy(effectObject); effectObject = null; effectObjects[i] = null; } } effectObjects = null; } }
protected void Start() { //TODO: Set up references and add event listener here. m_TextMesh.text = m_myNetId; m_TextAnimator = m_TextMesh.GetComponent <SimpleAnimator>(); m_SetTargetPstnBttn.onClick.AddListener(MoveTowardsOnClick); }
private void ValidateFlameModels() { GameObject model = null; SimpleAnimator modelAnimator = null; float modelChance = 0f; if (flamePieceModels != null) { for (int i = 0; i < flamePieceModels.Length; i++) { model = flamePieceModels[i]; if (model != null) { modelAnimator = model.GetComponent <SimpleAnimator>(); if (modelAnimator != null) { UsefulFunctions.IncreaseArray <GameObject>(ref flameModels, model); modelChance = DEFAULT_FLAME_CHANCE; if (flamePieceChances != null) { if (flamePieceChances.Length > i) { modelChance = flamePieceChances[i]; modelChance = (modelChance > 0f) ? modelChance : DEFAULT_FLAME_CHANCE; } } UsefulFunctions.IncreaseArray <float>(ref flameChances, modelChance); flameChancesSum += modelChance; } } } } }
private void ProgressFlames(float timeStep) { SimpleAnimator flameAnimator = null; if (flameAnimators != null) { for (int i = 0; i < flameAnimators.Length; i++) { flameAnimator = flameAnimators[i]; flameAnimator.Progress(timeStep); if (flameAnimator.IsOver()) { RemoveFlame(i); if (flameAnimators == null) { break; } else { i--; } } } } }
private void RemoveParticle(int particleIndex) { SimpleAnimator particleAnimator = null; GameObject particleObject = null; if (particleAnimators != null) { if ((particleIndex > -1) && (particleIndex < particleAnimators.Length)) { particleAnimator = particleAnimators[particleIndex]; if (particleAnimator != null) { particleAnimator.Clear(); particleAnimators[particleIndex] = null; } /*halmeida - relying on the coherence of all the "particle" arrays.*/ particleObject = particleObjects[particleIndex]; if (particleObject != null) { Destroy(particleObject); particleObjects[particleIndex] = null; } UsefulFunctions.DecreaseArray <float>(ref particleSpins, particleIndex); UsefulFunctions.DecreaseArray <Vector2>(ref particleSpeeds, particleIndex); UsefulFunctions.DecreaseArray <float>(ref particleAlphaSpeeds, particleIndex); UsefulFunctions.DecreaseArray <float>(ref particleOpaqueElapsed, particleIndex); UsefulFunctions.DecreaseArray <float>(ref particleOpaqueDurations, particleIndex); UsefulFunctions.DecreaseArray <SimpleAnimator>(ref particleAnimators, particleIndex); UsefulFunctions.DecreaseArray <GameObject>(ref particleObjects, particleIndex); } } }
public void Progress(float timeStep) { SimpleAnimator effect = null; if (effects != null) { for (int i = 0; i < effects.Length; i++) { effect = effects[i]; if (effect != null) { effect.Progress(timeStep); if (effect.IsOver()) { RemoveEffect(i); if (effects == null) { return; } i--; } } } } }
// Use this for initialization void Start() { _playerCanMove = true; DontDestroyOnLoad(gameObject); TextMessagePresent = false; MessageText = this.gameObject.GetComponent <GUIText>(); if (MessageText == null) { Debug.Log("Cannot find GuiText for Messages"); } MessageText.enabled = false; MessageBackground = this.gameObject.transform.GetChild(0).GetComponent <GUITexture>(); if (MessageBackground == null) { Debug.Log("Cannot find GUITexture for Messages"); } MessageBackground.enabled = false; _deadTimer = -1.0f; go_jump = new System.Collections.Generic.Dictionary <GameObject, float>(); //_animator = this.gameObject.GetComponentInChildren<SimpleAnimator>(); _animator = GameObject.FindGameObjectWithTag("DAWTFISTHISNOTWORKING").GetComponent <SimpleAnimator>(); _teleportTimer = _animator.Sprites.Length * (_animator.TimePerFrame / 1000); }
protected virtual void ProgressVisualEffects(float timeStep) { SimpleAnimator effectAnimator = null; if (visualEffectAnimators != null) { for (int i = 0; i < visualEffectAnimators.Length; i++) { effectAnimator = visualEffectAnimators[i]; effectAnimator.Progress(timeStep); if (effectAnimator.IsOver()) { RemoveVisualEffect(i); if (visualEffectAnimators == null) { return; } else { i--; } } } } }
public void Start() { SimpleAnimator animator = this.gameObject.AddComponent <SimpleAnimator>(); ECS_Provider provider = this.GetComponent <ECS_Provider>(); animator.InitData(provider); animator.PlayAnim(0); }
void Awake() { body = GetComponent <Rigidbody2D>(); box = GetComponent <BoxCollider2D>(); mySpriteRenderer = GetComponent <SpriteRenderer>(); simpleAnimator = GetComponent <SimpleAnimator>(); groundCheckResults = new RaycastHit2D[2]; }
void Awake() { point = transform.Find("Point"); point.localPosition = new Vector3(5.5f, 1f, 0f); ashes = point.GetComponent <SpriteRenderer>(); sa = gameObject.GetComponentInParent <SimpleAnimator>(); self = gameObject.GetComponent <SpriteRenderer>(); }
// Start is called before the first frame update void Start() { gameController = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>(); anim = GetComponent <SimpleAnimator>(); launcher = GetComponent <Launcher>(); launcher.Launch(); anim.PlayFromRandom(); launcher.Landed += Landed; }
public void Clear() { if (itemAnimator != null) { itemAnimator.Clear(); itemAnimator = null; } playerController = null; }
/// <summary> /// The screen scale animation from 1 to 0. /// </summary> /// <param name="duration">The duration of the animation.</param> /// <param name="delay">The delay before the animation.</param> protected void ScreenGoIn(float duration, float delay) { gameObject.SetActive(true); transform.localScale = Vector3.zero; StartCoroutine(SimpleAnimator.ScaleAnimation(gameObject, 1, duration, delay, () => { transform.localScale = Vector3.one; })); }
/// <summary> /// The screen scale animation from 0 to 1. /// </summary> /// <param name="duration">The duration of the animation.</param> /// <param name="delay">The delay before the animation.</param> protected void ScreenGoOut(float duration, float delay) { transform.localScale = Vector3.one; StartCoroutine(SimpleAnimator.ScaleAnimation(gameObject, 0, duration, delay, () => { transform.localScale = Vector3.zero; gameObject.SetActive(false); })); }
public void Progress(float timeStep) { SimpleAnimator debrisAnimator = null; if (!over) { if (debrisAnimators != null) { for (int i = 0; i < debrisAnimators.Length; i++) { debrisAnimator = debrisAnimators[i]; debrisAnimator.Progress(timeStep); if (debrisAnimator.IsOver()) { RemoveDebris(i); if (debrisAnimators == null) { break; } else { i--; } } } } if (destroyed) { if (debrisExtraDelay > 0f) { debrisExtraElapsed += timeStep; if (debrisExtraElapsed > debrisExtraDelay) { CreateAllDebris(debrisSlotDestruction); debrisExtraDelay = 0f; } } } if (obstacleAnimator != null) { obstacleAnimator.Progress(timeStep); if (obstacleAnimator.IsDead()) { /*halmeida - If the animations of the animator are not propperly configured, the animator * may die before we ask it to, which means it will die visually, but it will still be working * normally in terms of purpose.*/ if (!destroyed) { DestroyObstacle(); } /*halmeida - only after making sure it's propperly disabled we end it.*/ over = true; } } } }
protected virtual void ClearWaveAnimator() { waveParams = null; if (waveAnimator != null) { waveAnimator.Clear(); waveAnimator = null; } if (waveEmitterObject != null) { Destroy(waveEmitterObject); waveEmitterObject = null; } waveEmitterIndex = -1; }
protected override void Awake() { rewardXP = (rewardXP < 0) ? 0 : rewardXP; damageWaveLength = (damageWaveLength < 0f) ? 0f : damageWaveLength; enemyAnim = GetComponent <SimpleAnimator>(); waveColor = Color.white; waveFrontLimit = 3f * damageWaveLength; waveLengths = new Vector4(damageWaveLength, damageWaveLength / 4f, damageWaveLength / 8f, damageWaveLength / 12f); waveLengthsLast = waveLengths / 2f; waveLengthsLast.x /= 3f; waveAlphas = new Vector4(1f, 0.7f, 0.45f, 0.2f); waveAlphasLast = waveAlphas; waveSpeed = 10f * damageWaveLength; waveSpeedLast = waveSpeed / 6f; base.Awake(); }
void Start() { _isActive = false; // Find animator var hudObjects = GameObject.FindGameObjectsWithTag("Hud"); foreach (var hudObject in hudObjects) { if (hudObject.name == "Transition") { _animator = hudObject.GetComponent <SimpleAnimator>(); _remainingTimeUntilTeleport = (_animator.TimePerFrame / 1000) * _animator.Sprites.Length; break; } } }
protected virtual void CreateProjectileLaunchEffects(Vector3 projectilePosition, Vector2 normalizedDirection) { float angleWithRight = 0f; int totalEffects = 0; GameObject effectModel = null; GameObject effectObject = null; SimpleAnimator effectAnimator = null; Vector3 effectPosition = Vector3.zero; angleWithRight = UsefulFunctions.GetDirectionAngle(normalizedDirection); if (projectileLaunchFront != null) { totalEffects = projectileLaunchFront.Length; for (int i = 0; i < totalEffects; i++) { effectModel = projectileLaunchFront[i]; effectObject = Instantiate(effectModel, Vector3.zero, Quaternion.identity) as GameObject; effectObject.transform.localRotation = Quaternion.Euler(0f, 0f, angleWithRight); effectAnimator = effectObject.GetComponent <SimpleAnimator>(); /*halmeida - since the effects were validated in Awake(), both object and component are necessarily not null.*/ effectPosition = projectilePosition; effectPosition.z -= (totalEffects - i) * effectAnimator.GetChildSeparation(); effectObject.transform.position = effectPosition; UsefulFunctions.IncreaseArray <GameObject>(ref visualEffectObjects, effectObject); UsefulFunctions.IncreaseArray <SimpleAnimator>(ref visualEffectAnimators, effectAnimator); } } if (projectileLaunchBack != null) { totalEffects = projectileLaunchBack.Length; for (int i = 0; i < totalEffects; i++) { effectModel = projectileLaunchBack[i]; effectObject = Instantiate(effectModel, Vector3.zero, Quaternion.identity) as GameObject; effectObject.transform.localRotation = Quaternion.Euler(0f, 0f, angleWithRight); effectAnimator = effectObject.GetComponent <SimpleAnimator>(); /*halmeida - since the effects were validated in Awake(), both object and component are necessarily not null.*/ effectPosition = projectilePosition; effectPosition.z += (i + 1) * effectAnimator.GetChildSeparation(); effectObject.transform.position = effectPosition; UsefulFunctions.IncreaseArray <GameObject>(ref visualEffectObjects, effectObject); UsefulFunctions.IncreaseArray <SimpleAnimator>(ref visualEffectAnimators, effectAnimator); } } }
void Start() { SpriteRenderer = GetComponent <SpriteRenderer>(); Animator = GetComponent <Animator>(); SimpleAnimator = GetComponent <SimpleAnimator>(); CC = GetComponent <CharacterController2D>(); LeftFacing = false; SetState(kState_Idle); CC.onTriggerEnterEvent += onTriggerEvent; CC.onTriggerStayEvent += onTriggerStayEvent; foreach (var powerUp in GetComponents <PowerUp>()) { PowerUps.Add(powerUp.GetType(), powerUp); } }
private void CreateFlame(Vector3 flamePosition) { float chanceValue = 0f; int modelIndex = -1; GameObject flameModel = null; GameObject flameObject = null; SimpleAnimator flameAnimator = null; if (flameModels != null) { chanceValue = Random.Range(0f, flameChancesSum); for (int i = 0; i < flameChances.Length; i++) { if (chanceValue > flameChances[i]) { chanceValue -= flameChances[i]; } else { modelIndex = i; break; } } flameModel = flameModels[modelIndex]; flameObject = Instantiate(flameModel, Vector3.zero, Quaternion.identity) as GameObject; if (flameObject != null) { if (flamesParent != null) { flameObject.transform.SetParent(flamesParent.transform, false); } flameObject.transform.localPosition = flamePosition; flameAnimator = flameObject.GetComponent <SimpleAnimator>(); flameAnimator.SetOpaqueAlpha(flamePieceAlpha); flameAnimator.SetColorAddition(Vector4.Lerp(minimumColorAddition, maximumColorAddition, Random.Range(0f, 1f))); if (Random.Range(0, 2) == 1) { flameAnimator.RequestFlip(); } UsefulFunctions.IncreaseArray <GameObject>(ref flameObjects, flameObject); UsefulFunctions.IncreaseArray <SimpleAnimator>(ref flameAnimators, flameAnimator); } } }
protected void RemoveVisualEffect(int effectIndex) { GameObject effectObject = null; SimpleAnimator effectAnimator = null; if (visualEffectObjects != null) { if ((effectIndex > -1) && (effectIndex < visualEffectObjects.Length)) { /*halmeida - relying on the coherence of all the "visualEffect" arrays.*/ effectAnimator = visualEffectAnimators[effectIndex]; effectAnimator.Clear(); effectObject = visualEffectObjects[effectIndex]; Destroy(effectObject); UsefulFunctions.DecreaseArray <SimpleAnimator>(ref visualEffectAnimators, effectIndex); UsefulFunctions.DecreaseArray <GameObject>(ref visualEffectObjects, effectIndex); } } }
/// <summary> /// The background fade animation depending on the state. /// </summary> /// <param name="state">Fade in if true, fade out if false.</param> /// <param name="duration">The duration of the animation.</param> private void FadeBackground(bool state, float duration = 0.5f) { if (_menuBackground == null) { return; } _menuBackground.gameObject.SetActive(true); if (state) { StartCoroutine(SimpleAnimator.FadeAnimation(_menuBackground, duration, _menuBackgroundColor)); } else { var newColor = _menuBackgroundColor; newColor.a = 0f; StartCoroutine(SimpleAnimator.FadeAnimation(_menuBackground, duration, newColor)); } }
public void AddEffect(GameObject effectObjectModel, Vector2 worldPosition) { SimpleAnimator effect = null; Vector3 completePosition = Vector3.zero; GameObject newEffectObject = null; SimpleAnimator newEffect = null; GameObject[] newEffectObjects = null; SimpleAnimator[] newEffects = null; int length = 0; if (effectObjectModel != null) { effect = effectObjectModel.GetComponent <SimpleAnimator>(); if (effect != null) { newEffectObject = GameObject.Instantiate(effectObjectModel, Vector3.zero, Quaternion.identity) as GameObject; newEffect = newEffectObject.GetComponent <SimpleAnimator>(); if (effectObjects != null) { length = effectObjects.Length; } completePosition.x = worldPosition.x; completePosition.y = worldPosition.y; completePosition.z = baseZ + length * offsetZ; newEffectObject.transform.position = completePosition; newEffectObjects = new GameObject[length + 1]; newEffects = new SimpleAnimator[length + 1]; if (effectObjects != null) { for (int i = 0; i < length; i++) { newEffectObjects[i] = effectObjects[i]; newEffects[i] = effects[i]; } } newEffectObjects[length] = newEffectObject; newEffects[length] = newEffect; effectObjects = newEffectObjects; effects = newEffects; } } }
private void ProgressAuras(float timeStep) { int currentFlames = 0; float scale = 1f; float alpha = 0f; GameObject auraObject = null; SimpleAnimator auraAnimator = null; float scaleIncrease = 0f; float alphaReduction = 0f; if (auraAnimators != null) { if (flameObjects != null) { maxSimultaneousFlames = (flameObjects.Length > maxSimultaneousFlames) ? flameObjects.Length : maxSimultaneousFlames; currentFlames = flameObjects.Length; } if (maxSimultaneousFlames > 0) { scaleIncrease = AURA_SCALE_INCREASE * (float)maxSimultaneousFlames; scale = ((float)currentFlames + scaleIncrease) / ((float)maxSimultaneousFlames + scaleIncrease); alphaReduction = AURA_ALPHA_REDUCTION * (float)maxSimultaneousFlames; alpha = ((float)currentFlames - alphaReduction) / ((float)maxSimultaneousFlames - alphaReduction); } for (int i = 0; i < auraObjects.Length; i++) { auraObject = auraObjects[i]; auraObject.transform.localScale = new Vector3(scale, scale, 1f); } for (int i = 0; i < auraAnimators.Length; i++) { auraAnimator = auraAnimators[i]; auraAnimator.SetOpaqueAlpha(alpha); auraAnimator.StartAlphaFading(1f, false, false, false); auraAnimator.Progress(timeStep); } } }
public void Show( SimpleAnimator.AnimationComplete onCompletion = null ) { Util.AnimateBackgroundOpacity( View, 0.80f, onCompletion ); Util.AnimateBackgroundOpacity( BusyIndicator, 1.00f, null ); }
private void Awake() { animator = GetComponentInChildren<SimpleAnimator>(); //rdbody2D = GetComponent<Rigidbody2D>(); }
void AnimateImageView( View imageView, PointF startPos, PointF endPos, System.Drawing.SizeF startSize, System.Drawing.SizeF endSize, float duration, SimpleAnimator.AnimationComplete completeDelegate ) { // calculate the deltas once before we start float xDelta = endPos.X - startPos.X; float yDelta = endPos.Y - startPos.Y; float deltaWidth = endSize.Width - startSize.Width; float deltaHeight = endSize.Height - startSize.Height; // create an animator SimpleAnimator_Float imageAnimator = new SimpleAnimator_Float( 0.00f, 1.00f, duration, delegate( float percent, object value ) { Rock.Mobile.Threading.Util.PerformOnUIThread( delegate { // each update, interpolate the deltas and apply imageView.SetX( startPos.X + ( xDelta * percent ) ); imageView.SetY( startPos.Y + ( yDelta * percent ) ); imageView.LayoutParameters.Width = (int)( startSize.Width + ( deltaWidth * percent ) ); imageView.LayoutParameters.Height = (int)( startSize.Height + ( deltaHeight * percent ) ); // force the image to re-evaluate its size imageView.RequestLayout( ); } ); }, //ANIMATION COMPLETE delegate { if ( completeDelegate != null ) { Rock.Mobile.Threading.Util.PerformOnUIThread( delegate { completeDelegate( ); } ); } } ); imageAnimator.Start( ); }
void Awake() { rbody = GetComponent<Rigidbody>(); animator = GetComponentInChildren<SimpleAnimator>(); meshRenderer = GetComponent<MeshRenderer>(); if (definition == null) { Debug.LogError("Missing shiity definition, shitload of errors incoming"); } gameScript = FindObjectOfType<GameScript>(); if (definition.team == GameScript.TEAM1) { animator.defaultAnimation = defaultAnimationTeam1; animator.clips = animationsTeam1; } else { animator.defaultAnimation = defaultAnimationTeam2; animator.clips = animationsTeam2; } ballDirection = new Vector3(definition.team == GameScript.TEAM1 ? -1 : 1, 0, 0); BallRelativePosition = Vector3.Scale(ballDirection, ballDistance); IsActive = true; UpdateFlip(definition.team == GameScript.TEAM1 ? -1 : 1); this.gameObject.name = definition.name; }