private void Awake() { if (IsPlayer()) { SetInitialCoordinates(Coordinates); //CoordinatesList.Add(Coordinates); MapReference = FindObjectOfType <Map>(); MapReference.RegisterPlayer(this); MapReference.OnGameOver += GameOver; GameObject go = Instantiate(GhostTrailPrefab, MapReference.MapCoordinatesToWorldSpace(Coordinates), Quaternion.Euler(0, 0, 0)); GhostPath = go.GetComponent <GhostPath>(); GhostPath.SetInitialPoint(InitialCoordinates); GhostPath.SetColor(Color); GetComponentInChildren <SkinnedMeshRenderer>().shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On; } audioSource = GetComponent <AudioSource>(); }
public void CreateNextGhost() { if (PreviousCommand.Count >= 2) { PreviousCommand.RemoveAt(PreviousCommand.Count - 1); Character ghost = MapReference.AddGhost(this); ghost.SetColor(MaterialIndexer.GhostColors[NumberOfGhostCreated % MaterialIndexer.GhostColors.Length]); NumberOfGhostCreated++; GameObject go = Instantiate(GhostTrailPrefab, MapReference.MapCoordinatesToWorldSpace(Coordinates), Quaternion.Euler(0, 0, 0)); GhostPath = go.GetComponent <GhostPath>(); PreviousCommand.Clear(); InitialCoordinates = PreviousCoordinates; GhostPath.SetInitialPoint(InitialCoordinates); GhostPath.SetColor(Color); SoundsManager.instance.PlaySoundOneShot(SoundsManager.SoundName.ghostPop, audioSource); } }