public void InitializeFromCharacter(Character Other, bool StayInPlace = false) { SetInitialCoordinates(Other.InitialCoordinates); if (!IsRewinding) { //CoordinatesList.Add(InitialCoordinates); } MapReference = Other.MapReference; if (!StayInPlace) { Coordinates = InitialCoordinates; transform.position = MapReference.MapCoordinatesToWorldSpace(InitialCoordinates); MapReference.CharacterOnBlock(this); NumberOfGhostCreated--; } else { //PreviousCommand.Add(MovementCommand.None); } PreviousCommand.AddRange(Other.PreviousCommand); if (GhostPath) { Destroy(GhostPath.gameObject); } GhostPath = Other.GhostPath; GhostPath.SetColor(Color); }
public void SetColor(Color color) { Color = color; GhostPath.SetColor(color); //TODO apply color to mesh SkinnedMeshRenderer meshRenderer = GetComponentInChildren <SkinnedMeshRenderer>(); foreach (Material mat in meshRenderer.materials) { mat.SetColor("Color_604A5A12", color); } }
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); } }