IEnumerator ManageValues()
    {
        while (true)
        {
            int   highestKey   = 0;;
            float highestValue = 0;
            foreach (KeyValuePair <int, float> entry in valuesDict)
            {
                if (entry.Value >= highestValue)
                {
                    highestValue = entry.Value;
                    highestKey   = entry.Key;
                }
                // do something with entry.Value or entry.Key
            }

            //print("key " + highestKey);
            //print("value " + highestValue);

            if (iBehaveScripts[highestKey] != currentScript)
            {
                currentScript.StopScript();

                currentScript = iBehaveScripts[highestKey];

                currentScript.StartScript();
            }

            yield return(new WaitForSeconds(0.1f));
        }
    }
Пример #2
0
        public Blob(string name, int health, int damage, IBehave behavior, IAttack attack)
        {
            this.Name = name;
               this.Health = health;
               this.Damage = damage;
               this.Behavior = behavior;
               this.Attack = attack;

               this.halfhealth = this.Health/2;
        }
Пример #3
0
        bool CanRun()
        {
            if (m_Pause || m_Agent.Equals(null))
            {
                return(false);
            }

            IBehave behave = m_Agent as IBehave;

            if (!behave.Equals(null) && !behave.BehaveActive)
            {
                return(false);
            }

            return(true);
        }
    // Use this for initialization
    void Awake()
    {
        iBehaveScripts = new Dictionary <int, IBehave>();

        valuesDict = new Dictionary <int, float>();
        valuesDict.Add(1, 1);

        getIBehaveScripts = GetComponents <IBehave>();

        foreach (IBehave i in getIBehaveScripts)
        {
            iBehaveScripts.Add(i.ReturnScriptNr(), i);
            //print(i);
            //print(i.ReturnScriptNr());
        }

        currentScript = iBehaveScripts[0];
        //print(currentScript);
        StartCoroutine(ManageValues());
    }
Пример #5
0
 public IBlob Create(string name, int health, int damage, IBehave behavior, IAttack attack)
 {
     return new Blob(name,health,damage,behavior,attack);
 }