void OnCollisionEnter2D(Collision2D col) { if (col.gameObject.tag != "Player") { if (tag == "Lightning") { if (col.gameObject.tag == "MovingEnemy") { try { Settings.currentPlayer.UseArtifact(new LightningStick(), new Hero("", Race.HUMAN, Gender.MALE), 5); //Destroy (col.gameObject); } catch (Exception e) { TextExceptionScript.TextWrite(e.Message); } } if (col.gameObject.tag == "Target") { Slider slide = (GameObject.FindWithTag("PowerChoose")).GetComponent <Slider> (); float Power = slide.value * 100; if (Power == 0) { Power = 1; } try { Settings.currentPlayer.UseArtifact(new LightningStick(), TargetScript.Target, Power); } catch (Exception e) { TextExceptionScript.TextWrite(e.Message); } } } if (tag == "Spittle") { if (col.gameObject.tag == "Target") { try { Settings.currentPlayer.UseArtifact(new PoisonousSpittle(), TargetScript.Target); } catch (Exception e) { TextExceptionScript.TextWrite(e.Message); } } } if (tag == "Eye") { if (col.gameObject.tag == "Target") { try { Settings.currentPlayer.UseArtifact(new BasiliskEye(), TargetScript.Target); } catch (Exception e) { TextExceptionScript.TextWrite(e.Message); } } } rend.enabled = false; boxCol.isTrigger = true; transform.position = GameObject.FindWithTag("Player").transform.position; dir = 0; } }
void Update() { if (haveToCheck && EndColliderScript.IHaveIt) { anim.SetBool("IsAchieved", true); haveToCheck = false; TextExceptionScript.TextWrite("Цель достигнута!"); } }
void OnTriggerEnter2D(Collider2D col) { try{ if (col.gameObject.tag == "Player") { if (artName == "LittleLiveBottle") { Settings.currentPlayer.TakeArtifact(new LittleLiveBottle()); } if (artName == "MiddleLiveBottle") { Settings.currentPlayer.TakeArtifact(new MiddleLiveBottle()); } if (artName == "BigLiveBottle") { Settings.currentPlayer.TakeArtifact(new BigLiveBottle()); } if (artName == "LittleDeadBottle") { Settings.currentPlayer.TakeArtifact(new LittleDeadBottle()); } if (artName == "MiddleDeadBottle") { Settings.currentPlayer.TakeArtifact(new MiddleDeadBottle()); } if (artName == "BigDeadBottle") { Settings.currentPlayer.TakeArtifact(new BigDeadBottle()); } if (artName == "BasiliskEye") { Settings.currentPlayer.TakeArtifact(new BasiliskEye()); } if (artName == "FrogLegsDecoction") { Settings.currentPlayer.TakeArtifact(new FrogLegsDecoction()); } if (artName == "LightningStick") { Settings.currentPlayer.TakeArtifact(new LightningStick()); } if (artName == "PoisonousSpittle") { Settings.currentPlayer.TakeArtifact(new PoisonousSpittle()); } ButtonArtifactScript.UpdateTypeArray(); Destroy(gameObject); } } catch (Exception e) { TextExceptionScript.TextWrite(e.Message); } }
public void ThrowArtifact(int butNumber) { int[] arr = ButtonArtifactScript.TypeArray; try { if (arr[butNumber] == 1) { Settings.currentPlayer.ThrowArtifact(new LittleLiveBottle()); } if (arr[butNumber] == 2) { Settings.currentPlayer.ThrowArtifact(new MiddleLiveBottle()); } if (arr[butNumber] == 3) { Settings.currentPlayer.ThrowArtifact(new BigLiveBottle()); } if (arr[butNumber] == 4) { Settings.currentPlayer.ThrowArtifact(new LittleDeadBottle()); } if (arr[butNumber] == 5) { Settings.currentPlayer.ThrowArtifact(new MiddleDeadBottle()); } if (arr[butNumber] == 6) { Settings.currentPlayer.ThrowArtifact(new BigDeadBottle()); } if (arr[butNumber] == 7) { Settings.currentPlayer.ThrowArtifact(new BasiliskEye()); } if (arr[butNumber] == 8) { Settings.currentPlayer.ThrowArtifact(new FrogLegsDecoction()); } if (arr[butNumber] == 9) { Settings.currentPlayer.ThrowArtifact(new LightningStick()); } if (arr[butNumber] == 10) { Settings.currentPlayer.ThrowArtifact(new PoisonousSpittle()); } ButtonArtifactScript.UpdateTypeArray(); } catch (Exception e) { TextExceptionScript.TextWrite(e.Message); } }
void OnCollisionEnter2D(Collision2D col) { if ((col.gameObject.tag == "Wall") || (col.gameObject.tag == "MovingEnemy")) { direction *= -1f; } if (col.gameObject.tag == "Player") { if (attackTime == 0.8f) { anim.SetBool("Attack", true); isAttacking = true; Settings.currentPlayer.currentHP -= takeHP; col.gameObject.GetComponent <Rigidbody2D> ().AddForce(new Vector2(0, 450)); if ((col.gameObject.transform.position.x > gameObject.transform.position.x && direction < 0) || (col.gameObject.transform.position.x < gameObject.transform.position.x && direction > 0)) { direction *= -1f; } } } if (col.gameObject.tag == "Eye") { enemy.health = Health.PARALYSED; } if (col.gameObject.tag == "Spittle") { enemy.health = Health.POISONED; anim.SetBool("Hit", true); isHited = true; } if (col.gameObject.tag == "Lightning") { Slider slide = (GameObject.FindWithTag("PowerChoose")).GetComponent <Slider> (); float Power = slide.value * 100; if (Power == 0) { Power = 1; } try { Settings.currentPlayer.UseArtifact(new LightningStick(), enemy, Power);; anim.SetBool("Hit", true); isHited = true; } catch (Exception e) { TextExceptionScript.TextWrite(e.Message); } } }
private void Update() { EventSystem.current.SetSelectedGameObject(gameObject, null); if (Settings.currentPlayer.ableToMove && isGrounded && (Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.W))) { anim.SetBool("Grounded", false); GetComponent <Rigidbody2D>().AddForce(new Vector2(0, 600)); } if (Input.GetKey(KeyCode.Escape)) { Application.Quit(); } if (Input.GetKey(KeyCode.R)) { Settings.LevelFailed(); } if (isProtected && (ArmourScript.time >= 0.0f)) { TextExceptionScript.TextWrite(String.Format("Время действия брони " + ((int)(ArmourScript.time)).ToString())); ArmourScript.MakeProtection(); ArmourScript.time -= Time.deltaTime; } else { if (ArmourScript.time <= 0.0f) { ArmourScript.StopProtection(); } ArmourScript.time = 1f; } if (Settings.currentPlayer.health == Health.NONE) { conditionAnimator.SetFloat("Condition Number", 0); } if (Settings.currentPlayer.health == Health.PARALYSED) { conditionAnimator.SetFloat("Condition Number", 3); } PlayerInfoScript.TextWrite(); //HP = Settings.currentPlayer.currentHP; //Mana = Settings.currentPlayer.currentMana; //health = Settings.currentPlayer.health.ToString(); //lastpois = poisLastTime; }
void OnTriggerEnter2D(Collider2D col) { try { if (col.gameObject.tag == "Player") { anim.SetBool("Known", true); if (incName == "AddHealth") { Settings.currentPlayer.LearnIncantation(new AddHealth()); } if (incName == "Cure") { Settings.currentPlayer.LearnIncantation(new Cure()); } if (incName == "Antidote") { Settings.currentPlayer.LearnIncantation(new Antidote()); } if (incName == "Revive") { Settings.currentPlayer.LearnIncantation(new Revive()); } if (incName == "Armour") { Settings.currentPlayer.LearnIncantation(new Armour(ArmourScript.StartProtection)); } if (incName == "StartMoving") { Settings.currentPlayer.LearnIncantation(new StartMoving()); } Destroy(gameObject); } } catch (Exception e) { //textException=GameObject.FindWithTag("Exception"); TextExceptionScript.TextWrite(e.Message); } }
void OnTriggerEnter2D(Collider2D col) { if ((col.gameObject.tag == "Wall") || (col.gameObject.tag == "MovingEnemy")) { direction *= -1f; } if (col.gameObject.tag == "Eye") { enemy.health = Health.PARALYSED; } if (col.gameObject.tag == "Spittle") { enemy.health = Health.POISONED; anim.SetBool("Hit", true); isHited = true; } if (col.gameObject.tag == "Lightning") { Slider slide = (GameObject.FindWithTag("PowerChoose")).GetComponent <Slider> (); float Power = slide.value * 100; if (Power == 0) { Power = 1; } try { Settings.currentPlayer.UseArtifact(new LightningStick(), enemy, Power); anim.SetBool("Hit", true); isHited = true; } catch (Exception e) { TextExceptionScript.TextWrite(e.Message); } } }
public void UseArtifact(int butNumber) { Slider slide = (GameObject.FindWithTag("PowerChoose")).GetComponent <Slider>(); float Power = slide.value * 100; int[] arr = ButtonArtifactScript.TypeArray; if (Power == 0) { Power = 1; } try { if (arr[butNumber] == 1) { Settings.currentPlayer.UseArtifact(new LittleLiveBottle()); } if (arr[butNumber] == 2) { Settings.currentPlayer.UseArtifact(new MiddleLiveBottle()); } if (arr[butNumber] == 3) { Settings.currentPlayer.UseArtifact(new BigLiveBottle()); } if (arr[butNumber] == 4) { Settings.currentPlayer.UseArtifact(new LittleDeadBottle()); } if (arr[butNumber] == 5) { Settings.currentPlayer.UseArtifact(new MiddleDeadBottle()); } if (arr[butNumber] == 6) { Settings.currentPlayer.UseArtifact(new BigDeadBottle()); } if (arr[butNumber] == 7) { GameObject.FindWithTag("Eye").GetComponent <SpriteRenderer>().enabled = true; } if (arr[butNumber] == 9) { foreach (Artifact art in Settings.currentPlayer.bag) { if (art is LightningStick && art.capacity == 0) { throw new Exception("Артефакт уже истратил свою силу!"); } } GameObject.FindWithTag("Lightning").GetComponent <SpriteRenderer>().enabled = true; } if (arr[butNumber] == 10) { GameObject.FindWithTag("Spittle").GetComponent <SpriteRenderer>().enabled = true; } Toggle tog = (GameObject.FindWithTag("CheckInc")).GetComponent <Toggle>(); if (!tog.isOn) { if (arr[butNumber] == 8) { Settings.currentPlayer.UseArtifact(new FrogLegsDecoction()); } } else { if (arr[butNumber] == 8) { Settings.currentPlayer.UseArtifact(new FrogLegsDecoction(), TargetScript.Target); } } ButtonArtifactScript.UpdateTypeArray(); } catch (Exception e) { //textException=GameObject.FindWithTag("Exception"); TextExceptionScript.TextWrite(e.Message); } }
public void SayIncantation(string Incantation) { Slider slide = (GameObject.FindWithTag("PowerChoose")).GetComponent <Slider>(); TextExceptionScript.TextWrite(""); float Power = slide.value * 100; if (Power == 0) { Power = 1; } try { Toggle tog = (GameObject.FindWithTag("CheckInc")).GetComponent <Toggle>(); if (!tog.isOn) { if (Incantation == "AddHealth") { Settings.currentPlayer.SayIncantation(new AddHealth(), Power); } if (Incantation == "Cure") { Settings.currentPlayer.SayIncantation(new Cure(), Power); } if (Incantation == "Antidote") { Settings.currentPlayer.SayIncantation(new Antidote(), Power); } if (Incantation == "Revive") { Settings.currentPlayer.SayIncantation(new Revive(), Power); } if (Incantation == "Armour") { Settings.currentPlayer.SayIncantation(new Armour(ArmourScript.StartProtection), Power); } if (Incantation == "StartMoving") { Settings.currentPlayer.SayIncantation(new StartMoving(), Power); } } else { if (Incantation == "AddHealth") { Settings.currentPlayer.SayIncantation(new AddHealth(), TargetScript.Target, Power); } if (Incantation == "Cure") { Settings.currentPlayer.SayIncantation(new Cure(), TargetScript.Target, Power); } if (Incantation == "Antidote") { Settings.currentPlayer.SayIncantation(new Antidote(), TargetScript.Target, Power); } if (Incantation == "Revive") { Settings.currentPlayer.SayIncantation(new Revive(), TargetScript.Target, Power); } if (Incantation == "Armour") { Settings.currentPlayer.SayIncantation(new Armour(ArmourScript.StartProtection), TargetScript.Target, Power); } if (Incantation == "StartMoving") { Settings.currentPlayer.SayIncantation(new StartMoving(), TargetScript.Target, Power); } } } catch (Exception e) { //textException=GameObject.FindWithTag("Exception"); TextExceptionScript.TextWrite(e.Message); } }