MidaDev проекты Slider

Ремейк Saboteur2 (ZX-Spectrum)
На движке GMS2
Ремейк Chronos (ZX-Spectrum)
На движке GMS2
Particle Designer
Конструктор частиц с экспортом готового кода в GMS2
Элементы GUI
GMS2
Элементы GUI
Ремейк RiverRaid (ZX-Spectrum)
На движке Unity3D
NinjaGaiden (Dendy)
Доработка(переработка) функциональных частей движка ремейка игры NinjaGaiden

Цветная бегущая строка в стиле ZX-Spectrum

Эффект бегущей строки.

в стиле ZX-Spectrum



chronos horizontal moiving text

 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

//скроллит текст горизонтально, посимвольно

public class HorizontalMovedTextChar : MyMonoBehaviour 
{
  //--------------------------------
  [Header("Состояние объекта изначально")]
  [SerializeField] private bool GameObjectSetActive	= true;

  [Header("Событие по которому строка начнёт движение")]
  [SerializeField] 	private GameEvents EventOnStart = GameEvents.nil;

  [Header("Событие которое сгенерируется по окончанию")]
  [SerializeField] 	private GameEvents GenerateEventOnEnd = GameEvents.nil;
  //--------------------------------
  private Text   text_component;
  private string text_original;
  private string text;
  //--------------------------------

  //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  void Start () 
  {
    text_component = this.GetComponent<Text>();
    text_original = text_component.text;
    if(EventOnStart 	!= GameEvents.nil) globalEManager.StartListening(EventOnStart, StartMoving);
    else StartMoving();

    gameObject.SetActive(GameObjectSetActive);
  }
  //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  public void StartMoving()
  {
    gameObject.SetActive(true);
    text = text_original;
    InvokeRepeating("MovingText",0,0.15f);
  }
  //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  
  //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  private void MovingText () 
  {
    //Debug.Log("HorizontalMovedTextChar : text.Length = " + text.Length);
    //21 именно как и ниже, чила там и тут должны быть одинаковыми
    if(text.Length<=21)
    {
      if(DebugLog==true) Debug.Log("HorizontalMovedTextChar : Cancel Invoka" );
      CancelInvoke();
      globalEManager.TriggerEvent(GenerateEventOnEnd,gameObject);
      gameObject.SetActive(GameObjectSetActive);
      return;
    }

    text =  text.Remove(0,1);

    text_component.text = InsertColor(text);
    //text = text.Remove(0,1);

    //Debug.Log("HorizontalMovedTextChar : text=" + text);
  }
  //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  private string InsertColor(string s)
  {
    //21 именно как и выше, чила там и тут должны быть одинаковыми
    s = s.Insert(21,"</color>");
    s = s.Insert(20,"<color=black>");

    s = s.Insert(20,"</color>");
    s = s.Insert(19,"<color=red>");

    s = s.Insert(19,"</color>");
    s = s.Insert(18,"<color=blue>");

    s = s.Insert(18,"</color>");
    s = s.Insert(17,"<color=magenta>");

    s = s.Insert(17,"</color>");
    s = s.Insert(16,"<color=green>");

    s = s.Insert(16,"</color>");
    s = s.Insert(15,"<color=cyan>");

    s = s.Insert(15,"</color>");
    s = s.Insert(14,"<color=yellow>");


    s = s.Insert(6,"</color>");
    s = s.Insert(5,"<color=yellow>");

    s = s.Insert(5,"</color>");
    s = s.Insert(4,"<color=cyan>");

    s = s.Insert(4,"</color>");
    s = s.Insert(3,"<color=green>");

    s = s.Insert(3,"</color>");
    s = s.Insert(2,"<color=magenta>");

    s = s.Insert(2,"</color>");
    s = s.Insert(1,"<color=blue>");

    s = s.Insert(1,"</color>");
    s = s.Insert(0,"<color=red>");

    return s;
  }
  //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  void OnDisable()
  {
    CancelInvoke();
  }
  //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
}