コード例 #1
0
    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
ファイル: Blob.cs プロジェクト: cap7ainjack/OOP-Csharp
        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);
        }
コード例 #4
0
    // 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
ファイル: BlobFactory.cs プロジェクト: cap7ainjack/OOP-Csharp
 public IBlob Create(string name, int health, int damage, IBehave behavior, IAttack attack)
 {
     return new Blob(name,health,damage,behavior,attack);
 }