//Gravity Invert (Invertir) public CommandParser.enchantmentResponse gravityInvert(EnchantableObjTags.Tags tag) { if (PlayerGrimoire.GetInstance()._gravityBreak) { _listEnchantableObj = _levelManager.findEnchantableObj(tag); if (_listEnchantableObj.Count > 0) { foreach (GameObject aux in _listEnchantableObj) { Debug.Log(aux.name); if (aux.GetComponent <EnchantableObjProperties>().AllowChangeGravite) { aux.GetComponent <Rigidbody2D>().gravityScale *= -1; aux.GetComponent <EnchantableObj>().saveCurretGravityScale(); Instantiate(_objMagicCloud, aux.transform); // la nube magica } } _audioSource.clip = _gravityBreak; _audioSource.Play(); return(CommandParser.enchantmentResponse.SUCCESS); } else { return(CommandParser.enchantmentResponse.FAIL); } } else { return(CommandParser.enchantmentResponse.FAIL); } }
//Enchantments //Vision Magica (Muestra tags de objetos encantables) public CommandParser.enchantmentResponse showTags() { if (PlayerGrimoire.GetInstance()._showMeMore) { _listEnchantableObj = _levelManager.findEnchantableObj(); if (_listEnchantableObj.Count > 0) { foreach (GameObject aux in _listEnchantableObj) { if (aux.GetComponent <EnchantableObjProperties>()) // para no crear mas de un globo de texto al tiempo { if (aux.GetComponent <EnchantableObjProperties>().AllowShowTag) { aux.GetComponent <EnchantableObj>().TextBaloon.SetActive(true); aux.GetComponent <EnchantableObjProperties>().AllowShowTag = false; } } } _audioSource.clip = _magicTags; _audioSource.Play(); return(CommandParser.enchantmentResponse.SUCCESS); } else { return(CommandParser.enchantmentResponse.FAIL); } } else { return(CommandParser.enchantmentResponse.FAIL); } }
public void idle() { if (PlayerGrimoire.GetInstance()._stayPut) { AllowMove = false; _velocity = 0; } }
public static PlayerGrimoire GetInstance() { if (_instance == null) { _instance = new PlayerGrimoire(); } return(_instance); }
public void grab() { if (PlayerGrimoire.GetInstance()._grabObj) { if (GrabObj) { GetComponent <OcelotProperties>()._hasObj = true; GrabObj.GetComponent <EnchantableObj>().followCat(); } } }
public void run() { if (PlayerGrimoire.GetInstance()._run) { if (!_nearToObject) { AllowMove = true; _velocity = VELOCITY_RUN; } } }
public void walkForward() { if (PlayerGrimoire.GetInstance()._walkForward) { if (transform.rotation.y == -1) { GetComponent <Transform>().Rotate(new Vector3(0, -180, 0)); //lo resta lo que tenia antes para volver al origen } AllowMove = true; _velocity = VELOCITY_WALL; } }
public void walkBackwards() { if (PlayerGrimoire.GetInstance()._walkBackwards) { if (transform.rotation.y != -1) { GetComponent <Transform>().Rotate(new Vector3(0, 180, 0)); } AllowMove = true; _velocity = VELOCITY_WALL; } }
//Spark public CommandParser.enchantmentResponse spark(EnchantableObjTags.Tags tag) { if (PlayerGrimoire.GetInstance()._igniteSpark) { _listEnchantableObj = _levelManager.findEnchantableObj(tag); if (_listEnchantableObj.Count > 0) { foreach (GameObject aux in _listEnchantableObj) { Instantiate(_objSpark, aux.transform); if (aux.GetComponent <EnchantableObjProperties>().AllowIgnite) { aux.GetComponent <EnchantableObj>().turnOn(); aux.GetComponent <EnchantableObjProperties>().Onfire = true; } else if (aux.GetComponent <EnchantableObjProperties>().DestroyWhiteFire) { aux.AddComponent <SelfDestroy>().Time = 1; Instantiate(ObjFire, aux.transform); } else if (aux.GetComponent <EnchantableObjProperties>().OnBurn) { Instantiate(ObjFire, aux.transform).GetComponent <SelfDestroy>().enabled = false; aux.GetComponent <EnchantableObjProperties>().Onfire = true; } } _audioSource.clip = _ignite; _audioSource.Play(); return(CommandParser.enchantmentResponse.SUCCESS); } else { return(CommandParser.enchantmentResponse.FAIL); } } else { return(CommandParser.enchantmentResponse.FAIL); } }
//Make Smaller (x1/2) public CommandParser.enchantmentResponse makeSmaller(EnchantableObjTags.Tags tag) { if (PlayerGrimoire.GetInstance()._smallIscute) { _listEnchantableObj = _levelManager.findEnchantableObj(tag); if (_listEnchantableObj.Count > 0) { foreach (GameObject aux in _listEnchantableObj) { // comprueba si a ese objeto ya se le habia modificado el tamaño o si esta disponible para hacerlo pequeño if (aux.GetComponent <EnchantableObjProperties>().AllowMakeSmaller || !aux.GetComponent <EnchantableObjProperties>().AllowMakeBigger) { aux.transform.localScale = new Vector3(aux.transform.localScale.x / 2, aux.transform.localScale.y / 2, aux.transform.localScale.z); Instantiate(_objMagicCloud, aux.transform); // si el objeto era grande deja que lo vuelva a hacer grande o que lo siga pequeño if (!aux.GetComponent <EnchantableObjProperties>().AllowMakeBigger) { aux.GetComponent <EnchantableObjProperties>().AllowMakeBigger = true; } // si el objeto estaba normal no deja que lo siga agrandando else { aux.GetComponent <EnchantableObjProperties>().AllowMakeSmaller = false; } } } _audioSource.clip = _magic; _audioSource.Play(); return(CommandParser.enchantmentResponse.SUCCESS); } else { return(CommandParser.enchantmentResponse.FAIL); } } else { return(CommandParser.enchantmentResponse.FAIL); } }
public void jump() { if (PlayerGrimoire.GetInstance()._jump) { if (!NearToObject) { AllowMove = false; GetComponent <Rigidbody2D>().AddForce(Vector2.up * 150); } else { // mira si tiene el script luego mira si lo puede saltar if ((NearToCollision.GetComponent <EnchantableObj>().TopPoint.position.y - transform.position.y) <= 2.5f) { InJump = true; _rateVelocity = 1 / Vector3.Distance(transform.position, NearToCollision.GetComponent <EnchantableObj>().TopPoint.position) * 0.5f; if (_time == 0) { GetComponent <Rigidbody2D>().AddForce(Vector2.up * _forceJump); } if (_time <= 1) { _time += Time.deltaTime * _rateVelocity; AllowMove = true; transform.position = Vector3.Lerp(transform.position, NearToCollision.GetComponent <EnchantableObj>().TopPoint.position, _time); } else { InJump = false; _time = 0; _nearToObject = false; NearToCollision = null; AllowMove = false; } } } _anim.SetBool("Jump", InJump); _anim.SetFloat("Time_Jump", _time); } }
private void commandsUnlock() { foreach (PlayerGrimoire.commands commands in _unlockedCommands) { switch (commands) { case PlayerGrimoire.commands.WALK: PlayerGrimoire.GetInstance()._wall = true; break; case PlayerGrimoire.commands.RUN: PlayerGrimoire.GetInstance()._run = true; break; case PlayerGrimoire.commands.STAY_PUT: PlayerGrimoire.GetInstance()._stayPut = true; break; case PlayerGrimoire.commands.JUMP: PlayerGrimoire.GetInstance()._jump = true; break; case PlayerGrimoire.commands.WALK_FORWARD: PlayerGrimoire.GetInstance()._walkForward = true; break; case PlayerGrimoire.commands.WALK_BACKWARDS: PlayerGrimoire.GetInstance()._walkBackwards = true; break; case PlayerGrimoire.commands.GRAB: PlayerGrimoire.GetInstance()._grabObj = true; break; default: Debug.Log("no se encuentra ese comando para desbloquear"); break; } } }
private void enchantmentUnlock() { foreach (PlayerGrimoire.enchantment enchantment in _unlockedEnchantment) { switch (enchantment) { case PlayerGrimoire.enchantment.BIGGER_IS_BETTER: PlayerGrimoire.GetInstance()._biggerIsBetter = true; break; case PlayerGrimoire.enchantment.SMALLER_IS_CUTE: PlayerGrimoire.GetInstance()._smallIscute = true; break; case PlayerGrimoire.enchantment.GRAVITY_BREAKS: PlayerGrimoire.GetInstance()._gravityBreak = true; break; case PlayerGrimoire.enchantment.IGNITE_SPARK: PlayerGrimoire.GetInstance()._igniteSpark = true; break; } } }