// Use this for initialization
    void Start()
    {
        level                = GameObject.Find("Level").GetComponent <LevelController> ();
        this.renderer        = GetComponent <Renderer> ();
        this.defaultMaterial = renderer.material;
        this.painMaterial    = Resources.Load("Materials/Pain", typeof(Material)) as Material;
        player               = GameObject.Find("Player").GetComponent <PlayerController>();

        resting     = new AutomataNode("idle", typeof(BossIdleBehaviour));
        casting     = new AutomataNode("casting", typeof(BossCastingBehaviour));
        teleporting = new AutomataNode("teleporting", typeof(BossTeleportBehaviour));

        cast     = new Symbol("cast");
        rest     = new Symbol("rest");
        teleport = new Symbol("teleport");

        resting.AddTransition(cast, casting);

        casting.AddTransition(rest, resting);
        casting.AddTransition(teleport, teleporting);

        teleporting.AddTransition(rest, resting);

        current          = resting;
        currentBehaviour = (MonoBehaviour)gameObject.AddComponent(current.Behaviour);

        StartCoroutine("checkForPlayerNearby");

        lastHitPoints = hitPoints;
    }
        public void Add(string str, int value)
        {
            ReadOnlySpan <byte> bytes = Encoding.UTF8.GetBytes(str);
            AutomataNode        node  = this.root;

            while (bytes.Length > 0)
            {
                var key = AutomataKeyGen.GetKey(ref bytes);

                if (bytes.Length == 0)
                {
                    node = node.Add(key, value, str);
                }
                else
                {
                    node = node.Add(key);
                }
            }
        }
 public AutomataDictionary()
 {
     root = new AutomataNode(0);
 }
 private void ChangeState(Symbol symbol)
 {
     current = current.ApplySymbol(symbol);
     Destroy(currentBehaviour);
     currentBehaviour = (MonoBehaviour)gameObject.AddComponent(current.Behaviour);
 }
Esempio n. 5
0
 public void AddTransition(Symbol symbol, AutomataNode node)
 {
     transitions.Add(symbol, node);
 }