private void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("Player") && !isActivated) { Player_Character player = collision.GetComponent <Player_Character>(); player.SetCurrentCheckpoint(this); audioSource.Play(); } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.CompareTag("Player")) { Player_Character player = collision.GetComponent <Player_Character>(); player.Respawn(); } else { } }
void TryFollow(Player_Character _leader, Player_Character _follower) { Vector3 distance = _leader.transform.position - _follower.transform.position; distance.y = 0; //If the distance is just 1 the follow, this will make characters not move too far if (distance.sqrMagnitude == 1) { _follower.TryMove(distance, MoveTime); } }
public void Previous() { characterList[index].SetActive(false); if (index == 0) { index = characterList.Count - 1; } else { index--; } selected_name.text = characterList[index].name.Replace("(Clone)", ""); characterList[index].SetActive(true); current_character = characterList[index].GetComponent <player_selection_script>().character; charwins.text = PlayerPrefsHandler.GetPersistentVar <int>(Statics.character_wins(current_character), 0).ToString(); updatelabels(); warning.text = ""; }
// A function to check if the player passes ALL requirements. // Each other req object handles their own pass/fail but you must cycle through // The ones you have. public bool Passes(Player_Character pc) { if (!skillReqs.Passes(pc)) { return(false); } else if (!characterReqs.Passes(pc)) { return(false); } foreach (Contact_Reqs cr in contactReqs) { if (!cr.Passes(pc)) { return(false); } } return(true); }
private void initiateSelector() { GameObject[] characters = Resources.LoadAll <GameObject>("Players"); foreach (GameObject c in characters) { player = c.GetComponent(typeof(Player)) as Player; GameObject _char = Instantiate(c) as GameObject; _char.transform.SetParent(GameObject.Find("Character_controller").transform); characterList.Add(_char); _char.SetActive(false); selected_name.text = characterList[index].name.Replace("(Clone)", ""); characterList[index].SetActive(true); current_character = characterList[index].GetComponent <player_selection_script>().character; charwins.text = PlayerPrefsHandler.GetPersistentVar <int>(Statics.character_wins(current_character), 0).ToString(); updatelabels(); } }
public static string character_wins(Player_Character character) { return(character.ToString() + "_wins"); }
bool CanMove(Player_Character _character, Vector3 _direction) { return(true); #region Raycast Method //Set up first ray Vector3 Ray1Origin = PlayerCharacters[0].transform.position; //Increase Z and X by 0.5 to recenter origin Ray1Origin.z += 0.5f; Ray1Origin.x += 0.5f; #region Change Height //Round up the height if on stairs aka not at a factor of 0.5f if (Ray1Origin.y % 0.5f > 0.1f) { Ray1Origin.y += 0.25f; } //Up the start point to be 0.125 or 25% of height Ray1Origin.y += 0.125f; #endregion Ray Ray1 = new Ray(Ray1Origin, _direction); RaycastHit hit1Results = new RaycastHit(); //If the forward ray hits if (Physics.Raycast(Ray1, out hit1Results, 0.75f + 0.01f)) { //Debug.Log(hitResults.distance); Debug.Log("Origin Point: " + Ray1.origin); Debug.Log("Contact Point: " + hit1Results.distance); //If you hit after the 0.5 point (flat wall) then you hit a ramp if (hit1Results.distance > 0.6f) { //If it hits but its a ramp return(true); } else { //If it hits but its a wall return(false); } } //If it doesnt hit else { #region Downwards ray //Set up second ray Vector3 Ray2Origin = Ray1Origin + (_direction * 0.75f); //Create the 2nd ray to shoot downwards to see if you hit flat ground or a ramp Ray Ray2 = new Ray(Ray2Origin, new Vector3(0, -1, 0)); RaycastHit hit2Results = new RaycastHit(); //Shoot the ray downward if (Physics.Raycast(Ray2, out hit2Results, 0.25f + 0.01f)) { //If it hit, return true return(true); } else { //If it doesnt hit return false return(false); } #endregion } #endregion #region Height Difference Method #endregion }
// This handles all the attribute trees in every loader. private void handleAttribs(XmlTextReader reader, Player_Character character) { XmlNodeType nType = reader.NodeType; string fullSkill = ""; string tmp = ""; do { reader.Read (); nType = reader.NodeType; if(nType == XmlNodeType.Element) { if(reader.Name == "Attribute") { fullSkill += reader.GetAttribute("name"); tmp = reader.ReadElementContentAsString(); if(tmp.StartsWith("+") || tmp.StartsWith("-")) { // We are going to modify the value. if(tmp.StartsWith("+")) { // Going to add it. tmp = tmp.Substring(1); int currentValue = character.getAttrib(fullSkill); if (currentValue > 0) character.setAttrib(fullSkill, currentValue + int.Parse(tmp)); } else if (tmp.StartsWith("-")) { // Going to subtract it. tmp = tmp.Substring(1); int currentValue = character.getAttrib(fullSkill); if (currentValue > 0) character.setAttrib(fullSkill, currentValue - int.Parse(tmp)); } } else { // We are just going to set the value hard. character.setAttrib(fullSkill, int.Parse(tmp), true); } fullSkill = fullSkill.Remove(fullSkill.LastIndexOf("|") + 1); } else { fullSkill += reader.Name + "|"; } } else if(nType == XmlNodeType.EndElement) { if(fullSkill.IndexOf(reader.Name) >= 0) fullSkill = fullSkill.Remove(fullSkill.IndexOf(reader.Name)); } }while(!(reader.Name == "Attribs" && nType == XmlNodeType.EndElement)); }
// This goes through and loads the base class. private void loadBaseClass(XmlTextReader reader, Player_Character character) { XmlNodeType nType = reader.NodeType; do { reader.Read(); nType = reader.NodeType; if(nType == XmlNodeType.Element) if(reader.Name == "Attribs") { handleAttribs(reader, character); } } while(!(reader.Name == "Base_Class" && nType == XmlNodeType.EndElement) && !reader.EOF); }
// This goes through and loads all the subclass stuff that needs to be loaded. private void handleSubClass(string mainClass, string subClass, Player_Character character) { #if UNITY_EDITOR Debug.Log("Loading subclass info."); if(!File.Exists(Application.dataPath + "/Resources/Classes/SC_" + mainClass +".atr")) { Debug.LogError("Could not find file: " + Application.dataPath + "/Resources/Classes/SC_" + mainClass +".atr"); Debug.Break(); } #endif XmlTextReader reader = new XmlTextReader(Application.dataPath + "/Resources/Classes/SC_" + mainClass +".atr"); skipToAttribute(reader, "SubClass", "name", subClass); XmlNodeType nType; do { reader.Read (); nType = reader.NodeType; if(nType == XmlNodeType.Element) { if(reader.Name == "Attribs") { handleAttribs(reader, character); } } }while(!(reader.Name == "SubClass" && nType == XmlNodeType.EndElement)); reader.Close(); }
// This goes through and loads all the base stuff that needs to be loaded. private void handleMainClass(string mainClass, Player_Character character) { XmlTextReader reader = new XmlTextReader(Application.dataPath + "/Resources/Classes/Main_Class.atr"); #if UNITY_EDITOR Debug.Log("Loading Base Class"); #endif loadBaseClass(reader, character); #if UNITY_EDITOR Debug.Log("Loading Class info."); #endif skipToAttribute(reader, "Class", "name", mainClass); XmlNodeType nType; do { reader.Read (); nType = reader.NodeType; if(nType == XmlNodeType.Element) { if(reader.Name == "Attribs") { handleAttribs(reader, character); } } }while(!(reader.Name == "Class" && nType == XmlNodeType.EndElement)); reader.Close(); }