private void Start() { mv = PlayerMovement.GetInstance(); player = Player.GetInstance(); pa = PlayerActions.GetInstance(); fs = GetComponent <Footstep>(); }
void Start() { footstep = GameObject.FindWithTag("Player").GetComponentInChildren <Footstep>(); timer = 0; midpoint = new Vector2(transform.localPosition.x, transform.localPosition.y); }
// Start is called before the first frame update void Start() { nav = GetComponent <NavMeshAgent>(); player = GameObject.FindGameObjectWithTag("Player").transform; footstepScript = this.GetComponent <Footstep>(); StartCoroutine(WaitForFootstep(1)); }
public void LayStep(Transform t) { Footstep f = Instantiate(prefab, t.position + offset - monitor.Speed.normalized * trackLag, prefab.transform.rotation, parent); f.transform.Rotate(new Vector3(90, t.rotation.eulerAngles.y)); f.spriteRenderer.sprite = tracks.sprite; f.spriteRenderer.material.color = Color.white; f.StartCoroutine(Duration(f)); }
IEnumerator Duration(Footstep footstep) { float t = 0; while (footstep.mat.color.a > 0) { footstep.spriteRenderer.material.color = Vector4.Lerp(Color.white, Color.clear, t); t += tracks.fadeStep; yield return(tracks.fadeWait); } Destroy(footstep.gameObject); }
public void PlayFootstep(string foot) { string f = foot.ToLower(); Footstep currentFootstep = new Footstep(); for (int i = 0; i < footsteps.Count; i++) { if (footsteps[i].tag == currentSurface) { currentFootstep = footsteps[i]; } } footSource.PlayOneShot(currentFootstep.clips[Random.Range(0, currentFootstep.clips.Length)]); }
void Start() { characterMotor = GetComponent <CharacterMotor>(); vitality = GetComponent <Vitality>(); footstep = GetComponentInChildren <Footstep>(); skillMenu = GameObject.FindWithTag("Main").GetComponent <SkillMenu>(); skillMenu.unlockSkill(0); skillMenu.setSkillMessage(0, "Sprint"); soundEffectManager = GameObject.FindWithTag("Main").GetComponent <SoundEffectManager>(); sprintForwardSpeed = originalForwardSpeed * timesOfSpeed; sprintSidewaysSpeed = originalSidewaysSpeed * timesOfSpeed; sprintBackwardsSpeed = originalBackwardsSpeed * timesOfSpeed; }
private void Start() { // @Transform setups leftFootstepDetector = Instantiate(footstepDetector, Vector3.zero, Quaternion.identity); rightFootstepDetector = Instantiate(footstepDetector, Vector3.zero, Quaternion.identity); leftFootstepDetector.transform.SetParent(leftFoot); leftFootstepDetector.transform.localPosition = new Vector3(0f, -0.1f, 0f); rightFootstepDetector.transform.SetParent(rightFoot); rightFootstepDetector.transform.localPosition = new Vector3(0f, -0.1f, 0f); // @Subscribe to footstep triggering on the ground layers leftFootstepDetector.GetComponent <FootstepTrigger>().DispatchEvent.AddListener(PlayLeftFootstep); rightFootstepDetector.GetComponent <FootstepTrigger>().DispatchEvent.AddListener(PlayRightFootstep); // @Initialize Footstep Class footstep = new Footstep( // @The footstep manager soundbank GameObject.FindWithTag(Constants.FOOTSTEP_MANAGER).GetComponent <FootstepManager>(), // @An arbitrary 3D audio source, either from the left or right foot is fine leftFootstepDetector.GetComponent <AudioSource>() ); }
private void SubtractFootstepTTL(Footstep footstep, float dt) { footstep.TTL -= dt; }
private void RemoveStep(Footstep footstep) { footstepPositions.Remove(footstep.pos); footsteps.Remove(footstep); }
void Update() { if (health.CurrentValue == 0) { Die(); } if (isUsingGreenPotion == true) { greenPotion.SetActive(true); } else { greenPotion.SetActive(false); } if (isUsingBluePotion == true) { bluePotion.SetActive(true); } else { bluePotion.SetActive(false); } if (active == true && Input.GetKeyDown(KeyCode.E)) { ButtonPause.instancePause.ShopGame(); } if (isUsingGreenPotion) { timerGreen++; } if (timerGreen == 1000) { isUsingGreenPotion = false; timerGreen = 0; } if (isUsingBluePotion) { timerBlue++; } if (timerBlue == 1000) { isUsingBluePotion = false; controller.m_JumpForce -= 200; timerBlue = 0; } horizontalMove = Input.GetAxisRaw("Horizontal") * runSpeed; animator.SetFloat("Speed", Mathf.Abs(horizontalMove)); if (Input.GetButtonDown("Jump") && !controller.isUnderSomething) { jump = true; animator.SetBool("IsCrouching", false); m_CrouchDisableCollider.enabled = true; } if (Input.GetButtonDown("Crouch")) { crouch = true; animator.SetBool("IsCrouching", true); m_CrouchDisableCollider.enabled = false; } if ((Input.GetButtonUp("Crouch") && !controller.isUnderSomething) || (!controller.isUnderSomething && !Input.GetButton("Crouch"))) { crouch = false; m_CrouchDisableCollider.enabled = true; animator.SetBool("IsCrouching", false); } Experience.TextValue = level; if (rb.velocity.y > 0 && controller.getGrounded() == false) { animator.SetBool("IsJumping", true); animator.SetBool("IsFalling", false); } if (rb.velocity.y < 0 && controller.getGrounded() == false) { animator.SetBool("IsFalling", true); animator.SetBool("IsJumping", false); } timer -= Time.deltaTime; if (timer <= 0.0f && animator.GetFloat("Speed") > 0.1 && animator.GetBool("IsFalling") == false && animator.GetBool("IsJumping") == false) { switch (ground) { case "grass": Footstep.PlaySound("run"); break; case "bois": Footstep.PlaySound("bois"); break; case "metal": Footstep.PlaySound("metal"); break; } timer = 0.4f; } }
void OnGUI() { scrollPos = EditorGUILayout.BeginScrollView(scrollPos); SerializedObject serializedThis = new SerializedObject(this); selectedMap = Selection.activeGameObject; selectedTile = Selection.activeGameObject; EditorGUILayout.LabelField("Map Editor:", EditorStyles.boldLabel); EditorGUILayout.PropertyField(serializedThis.FindProperty("setupTiles"), new GUIContent("Setup Tiles"), true); if (GUILayout.Button("Toggle Grid")) { if (GameObject.Find("TempMapEditorGrid") != null) { DestroyImmediate(GameObject.Find("TempMapEditorGrid")); } else { HierarchyProperty prop = new HierarchyProperty(HierarchyType.GameObjects); GameObject gridObj = Instantiate(gridPrefab, new Vector3(0, 0, 0), Quaternion.Euler(90, 0, 0)); gridObj.name = "TempMapEditorGrid"; } } if (selectedTile != null) { if (Selection.activeGameObject.scene.name != null) { if (Selection.gameObjects.Length == 1) { if (selectedTile.GetComponent <Renderer>() != null) { if (selectedTile.GetComponent <MeshFilter>() != null) { EditorGUILayout.Separator(); EditorGUILayout.LabelField("Tile Editor:", EditorStyles.boldLabel); MeshFilter meshFilter = selectedTile.GetComponent <MeshFilter>(); Renderer renderer = selectedTile.GetComponent <Renderer>(); Material[] mat = renderer.sharedMaterials; if (meshFilter.sharedMesh.name.Contains("cliff") && mat.Length == 2) { mat[0] = (Material)EditorGUILayout.ObjectField("Cliff Mat", renderer.sharedMaterials[0], typeof(Material), false); } else if (meshFilter.sharedMesh.name.Contains("stair")) { mat[0] = (Material)EditorGUILayout.ObjectField("Stair Mat", renderer.sharedMaterials[0], typeof(Material), false); } bool found = false; if (mat.Length > 0) { for (int i = 0; i < mat.Length; i++) { if (found) { break; } for (int e = 0; e < castedPresets.Length; e++) { if (mat[i] != null) { if (mat[i].name == castedPresets[e]) { found = true; matInt = i; if (firstRun) { preset = (PresetTiles)e; } break; } } else { found = true; if (firstRun) { preset = PresetTiles.None; } } } if (!found) { if (firstRun) { preset = PresetTiles.None; } } } } if (preset == PresetTiles.None) { if (meshFilter.sharedMesh.name == "tile" && mat.Length == 1) { mat[0] = (Material)EditorGUILayout.ObjectField("Tile Mat", renderer.sharedMaterials[0], typeof(Material), false); } else if (meshFilter.sharedMesh.name.Contains("cliff") && mat.Length == 2) { mat[1] = (Material)EditorGUILayout.ObjectField("Overlay Mat", renderer.sharedMaterials[1], typeof(Material), false); } else if (meshFilter.sharedMesh.name == "stairDirt" && mat.Length == 2) { mat[1] = (Material)EditorGUILayout.ObjectField("Side Mat", renderer.sharedMaterials[1], typeof(Material), false); } } if (matInt < mat.Length && matInt >= 0) { if (!firstRun) { mat[matInt] = (Material)AssetDatabase.LoadAssetAtPath("Assets/MapCreation/Materials/" + castedPresets[(int)preset] + ".mat", typeof(Material)); } } if ((matInt < 0 || matInt >= mat.Length) || preset == PresetTiles.None) { matInt = EditorGUILayout.IntField("Mat Element", matInt); } firstRun = true; PresetTiles oldpreset = preset; if (meshFilter.sharedMesh.name != "stairRail") { preset = (PresetTiles)EditorGUILayout.EnumPopup("Tile Preset", preset); } if (oldpreset != preset) { firstRun = false; } if (selTile1 != null && mat != null) { if (selTile1.materials != null) { for (int i = mat.Length - 1; i < selTile1.materials.Length; i++) { mat[i] = selTile1.materials[i]; } } selTile1 = null; } if (setupTiles != null) { if (setupTiles.Length > 0) { if (GUILayout.Button("Select Setups")) { GenericMenu menu = new GenericMenu(); foreach (Tile tile in setupTiles) { AddTileItem1(menu, tile.name, tile); } menu.ShowAsContext(); } } } renderer.sharedMaterials = mat; } } else if (selectedTile.GetComponent <Footstep>() != null) { if (selTile2 != null) { if (selTile2.footstepSound == null) { selTile2 = null; } } Footstep footstep = selectedTile.GetComponent <Footstep>(); SerializedObject serializedObject = new SerializedObject(footstep); EditorGUILayout.Separator(); EditorGUILayout.LabelField("Footstep Editor:", EditorStyles.boldLabel); EditorGUILayout.PropertyField(serializedObject.FindProperty("walkClip"), new GUIContent("Footstep"), true); EditorGUILayout.PropertyField(serializedObject.FindProperty("gizmoColor"), new GUIContent("Gizmo Color"), true); EditorGUILayout.PropertyField(serializedObject.FindProperty("stepOnAnyObject"), new GUIContent("Any Object?"), true); if (selTile2 != null) { if (selTile2.footstepSound != null) { serializedObject.FindProperty("walkClip").objectReferenceValue = selTile2.footstepSound; } if (selTile2.footstepGizmo != null) { serializedObject.FindProperty("gizmoColor").colorValue = selTile2.footstepGizmo; } serializedObject.FindProperty("stepOnAnyObject").boolValue = selTile2.footstepAnyObject; } selTile2 = null; if (setupTiles != null) { if (setupTiles.Length > 0) { if (GUILayout.Button("Select Setups")) { GenericMenu menu = new GenericMenu(); foreach (Tile tile in setupTiles) { AddTileItem2(menu, tile.name, tile); } menu.ShowAsContext(); } } } serializedObject.ApplyModifiedProperties(); } EditorGUILayout.Separator(); if (selectedMap != null) { if (selectedMap.transform.parent != null) { selectedMap = selectedMap.transform.parent.gameObject; } EditorGUILayout.Separator(); if (selectedMap.GetComponent <MapCollider>() != null) { EditorGUILayout.LabelField("Map Collision:", EditorStyles.boldLabel); MapCollider mapCollider = selectedMap.GetComponent <MapCollider>(); if (GUILayout.Button("Generate Collision Mesh")) { mapCollider.shorthandCollisionMap = "0x4"; mapCollider.width = 2; mapCollider.length = 2; MapCompiler.Compile(selectedMap); } mapCollider.drawWireframe = EditorGUILayout.Toggle("Wireframe Gizmo", mapCollider.drawWireframe); mapCollider.wireframeColor = EditorGUILayout.ColorField("Wireframe Color", mapCollider.wireframeColor); } EditorGUILayout.Separator(); if (selectedMap.GetComponent <MapSettings>() != null) { EditorGUILayout.LabelField("Map Settings:", EditorStyles.boldLabel); MapSettings mapSettings = selectedMap.GetComponent <MapSettings>(); mapSettings.mapName = EditorGUILayout.TextField(new GUIContent("Map Name"), mapSettings.mapName); mapSettings.mapNameBoxTexture = (Sprite)EditorGUILayout.ObjectField("Map Name Box Sprite", mapSettings.mapNameBoxTexture, typeof(Sprite), false); mapSettings.mapNameColor = EditorGUILayout.ColorField("Map Name Color", mapSettings.mapNameColor); mapSettings.mapBGMClip = (AudioClip)EditorGUILayout.ObjectField("Map BGM", mapSettings.mapBGMClip, typeof(AudioClip), false); mapSettings.mapBGMNightClip = (AudioClip)EditorGUILayout.ObjectField("Map BGM 2", mapSettings.mapBGMNightClip, typeof(AudioClip), false); mapSettings.mapBGMLoopStartSamples = EditorGUILayout.IntField("Map BGM Loop Samples", mapSettings.mapBGMLoopStartSamples); mapSettings.mapBGMNightLoopStartSamples = EditorGUILayout.IntField("Map BGM 2 Loop Samples", mapSettings.mapBGMNightLoopStartSamples); EditorGUILayout.Space(); mapSettings.environment = (MapSettings.Environment)EditorGUILayout.EnumPopup("Map Environment", mapSettings.environment); mapSettings.environment2 = (MapSettings.Environment)EditorGUILayout.EnumPopup("Map Environment 2", mapSettings.environment2); mapSettings.pokemonRarity = (MapSettings.PokemonRarity)EditorGUILayout.EnumPopup("Pokémon Rarity", mapSettings.pokemonRarity); SerializedObject serializedObject = new SerializedObject(mapSettings); EditorGUILayout.PropertyField(serializedObject.FindProperty("encounters"), new GUIContent("Map Encounters"), true); serializedObject.ApplyModifiedProperties(); } } } else { EditorGUILayout.LabelField("Cannot process multiple selections!", EditorStyles.boldLabel); } } else { EditorGUILayout.LabelField("Cannot process non-scene objects!", EditorStyles.boldLabel); } } else { EditorGUILayout.LabelField("No tile selected!", EditorStyles.boldLabel); } serializedThis.ApplyModifiedProperties(); EditorGUILayout.EndScrollView(); }