public static FreezeEffect instance; // "Reference" to this instance, so that when we () // Use this for pre-initialization void Awake() { //set the "instance" to this instance = this; //this script is on the freeze effect gameobject in the scene... so freezeEffectGameObject is this.gameObject. freezeEffectGameObject = this.gameObject; }
private int numOfTimesScoreTimesTwoLaunched; // the number of times that the Freeze Banana has been launched // Use this for pre-initialization void Awake() { //make sure our static LaunchController Instance is set to THIS gameObject LaunchControllerInstance = this; //our timer reference by calling GetComponent on THIS gameObject timer = GetComponent <CountdownTimer>(); //Use GameObjects FindObjectWithTag method to setup our references to the freeze,frenzy, and 2xScore objects/classes. Using our Const Strings in "Tags" freezeEffectReference = GameObject.FindGameObjectWithTag(Tags.freezeEffectGameObjectTag).GetComponent <FreezeEffect>(); frenzyEffectReference = GameObject.FindGameObjectWithTag(Tags.frenzyEffectGameObjectTag).GetComponent <FrenzyEffect>(); twoTimesScoreEffectReference = GameObject.FindGameObjectWithTag(Tags.twoTimesScoreEffectGameObjectTag).GetComponent <TwoTimesScoreEffect>(); //Use GameObjects FindObjectWithTag method to setup our references to the bottom and side fruitLaunchers. bottomFruitLaunchers = GameObject.FindGameObjectsWithTag(Tags.bottomFruitLaunchers); sideFruitLaunchers = GameObject.FindGameObjectsWithTag(Tags.sideFruitLaunchers); //Initialize the lists "bottomLaunchersScriptReference" && "sideLaunchersScriptReference" bottomLaunchersScriptReference = new List <FruitLauncher>(); sideLaunchersScriptReference = new List <FruitLauncher>(); //loop through all of the bottom fruit launchers for (int i = 0; i < bottomFruitLaunchers.Length; i++) { //now add each bottom fruit launcher to our List ("bottomLaunchersScriptReference") bottomLaunchersScriptReference.Add(bottomFruitLaunchers[i].GetComponent <FruitLauncher>()); } //loop through all of the side fruit launchers for (int j = 0; j < sideFruitLaunchers.Length; j++) { //now add each side fruit launcher to our List ("sideLaunchersScriptReference") sideLaunchersScriptReference.Add(sideFruitLaunchers[j].GetComponent <FruitLauncher>()); } }
/// <summary> /// The StartEffect() method starts the Frenzy Effect. /// </summary> public void StartEffect() { //set boolean to true //frenzyEffectIsOn = true; ////assign the startAndEndColor to changingColorSprite.color //changingColorSprite.color = startAndEndColor; ////Start Coroutine( TweenSpriteColor( the amount of time to wait before starting... .05f )) //StartCoroutine(TweenSpriteColor(.05f)); ////Start Coroutine FadeImages (the image to fade, delay amt, what alpha to fade to, and what speed to fade at.) //StartCoroutine(FadeImages(frenzyScreenSprites[0], 0f, 1f, textFadeInSpeed));//text ////Invoke StartFrenzyParticleEffect in "textFadeInSpeed" //Invoke("StartFrenzyParticleEffect", textFadeInSpeed); ////call the EndEffect() method //EndEffect(); freezeEffect = GameObject.FindGameObjectWithTag(Tags.freezeEffectGameObjectTag).GetComponent <FreezeEffect>(); if (freezeEffect.freezeEffectIsOn) { Debug.Log("poison"); freezeEffect.freezeEffectIsOn = false; freezeEffect.EndPotionBombEffect(); return; } else { Debug.Log("Wrong man"); antidoteCount = Mathf.Min(1, antidoteCount + 1); } }
/**********************************************************************************/ // настраиваем эффекты // /**********************************************************************************/ private void SetEffects() { // эффект замораживания FreezeEffect fe = new FreezeEffect(); fe.ObjectUnderEffect = gameObject; m_effects[fe.Type] = fe; m_effects[UnitEffect.EFFECT_TYPE.ACID] = fe; }
protected void SubInflictEffect(GameObject affected) { //adds freeze effect FreezeEffect prevEffect = affected.GetComponent <FreezeEffect>(); if (prevEffect != null) { prevEffect.Refresh(); } else { affected.AddComponent <FreezeEffect>(); affected.GetComponent <FreezeEffect>().StartEffect(); } }
/**********************************************************************************************/ // инициализация дефолтного набора эффектов // /**********************************************************************************************/ protected virtual void SetEffectsCollection() { // добавляем всем юнитам эффект урона DamageEffect de = new DamageEffect(); de.ObjectUnderEffect = gameObject; m_effectMaster.SetEffect(de.Type, de); // для отображения кислотного урона DamageEffect ade = new DamageEffect(); ade.ObjectUnderEffect = gameObject; ade.SetAcidType(); m_effectMaster.SetEffect(ade.Type, ade); // эффект нанесения урона кислотой AcidEffect ae = new AcidEffect(); ae.ObjectUnderEffect = gameObject; m_effectMaster.SetEffect(ae.Type, ae); // эффект замораживания FreezeEffect fe = new FreezeEffect(); fe.ObjectUnderEffect = gameObject; m_effectMaster.SetEffect(fe.Type, fe); // получаем саб компоненты Transform[] allChildren = GetComponentsInChildren <Transform>(); for (int ind = 0; ind < allChildren.Length; ind++) { GameObject component = allChildren[ind].gameObject; // настраваем FreezeEffect if (component.tag == "FreezeEffect") { Animator freezeEffectAnimator = component.GetComponent <Animator>(); if (freezeEffectAnimator == null) { Debug.Log("ERROR! freezeEffect Animator is NULL!!!"); return; } // вручаем ему аниматор fe.EffectAnimator = freezeEffectAnimator; } } }
void Awake() { //I usually use awake for setting up references, so we will do that first. //the next three lines will get a reference to the 3 gameObjects in the game scenes that control the powerUp //effects. These gameObjects each have a spriteRenderer that is used to display the powerUp labels and some have //borders (like Freeze Effect). //all of the tags in the game are stored in [const readonly strings], in our Tags Class. There was quite a few //different tags, and since I would prefer the scripts to autoComplete, I created read only strings for them. freezeEffectGameObject = GameObject.FindGameObjectWithTag(Tags.freezeEffectGameObjectTag).GetComponent <FreezeEffect>(); frenzyEffectGameObject = GameObject.FindGameObjectWithTag(Tags.frenzyEffectGameObjectTag).GetComponent <FrenzyEffect>(); twoTimesScoreEffectGameObject = GameObject.FindGameObjectWithTag(Tags.twoTimesScoreEffectGameObjectTag).GetComponent <TwoTimesScoreEffect>(); //cache a reference to this gameObject. thisGameObject = this.gameObject; //Setup Shake and Chroma Script References... both scripts are on the main camera shake = Camera.main.GetComponent <SimpleCameraShake>(); chroma = Camera.main.GetComponent <ChromaticAberration>(); }
/**********************************************************************************/ // работаем с внутренними компонентами объекта игрока // получаем ссылку на ShieldController и настраиваем FreezeEffect // /**********************************************************************************/ private void GetInnerComponents() { // получаем саб компоненты Transform[] allChildren = GetComponentsInChildren <Transform>(); for (int ind = 0; ind < allChildren.Length; ind++) { GameObject component = allChildren[ind].gameObject; if (component.tag == "ShieldGen") { m_shieldCtr = component.GetComponent <ShieldController>(); if (m_shieldCtr == null) { Debug.Log("ERROR! Shield ctr is NULL!!!"); return; } // устанавливаем продолжительность работы щита m_shieldCtr.ShieldDuration = this.ShieldDuration; m_shieldCtr.ShieldMaxPower = this.ShieldMaxPoints; } // настраваем FreezeEffect if (component.tag == "FreezeEffect") { Animator freezeEffectAnimator = component.GetComponent <Animator>(); if (freezeEffectAnimator == null) { Debug.Log("ERROR! freezeEffect Animator is NULL!!!"); return; } // вручаем ему аниматор FreezeEffect fe = m_effects[UnitEffect.EFFECT_TYPE.ACID] as FreezeEffect; fe.EffectAnimator = freezeEffectAnimator; } } }
// Start is called before the first frame update public virtual void Start() { freezeEffect = GetComponent <FreezeEffect>(); currentHealth = maxHealth; }