Exemple #1
0
        public override void OnCreate()
        {
            r    = 0.0f;
            arg1 = arg2 = false;
            RewardFunc[] funcs = new RewardFunc[NB_OF_ARGS];

            if (negativeRewardFuncPath != null && positiveRewardFuncPath != null)
            {
                funcs[0] = GetNode(positiveRewardFuncPath) as RewardFunc;
                funcs[1] = GetNode(negativeRewardFuncPath) as RewardFunc;
                funcs[0].Subscribe(this);
                funcs[1].Subscribe(this);
            }
            else
            {
                var count = 0;
                foreach (Node node in GetChildren())
                {
                    if (node.GetType().IsSubclassOf(typeof(RewardFunc)))
                    {
                        RewardFunc r = node as RewardFunc;
                        funcs[count++] = r;
                        r.Subscribe(this);
                        if (count >= NB_OF_ARGS)
                        {
                            break;
                        }
                    }
                }
            }
            positiveRewardFunc = funcs[0];
            negativeRewardFunc = funcs[1];
        }
Exemple #2
0
        public override void OnCreate()
        {
            arguments = new RewardFunc[NB_OF_ARGS];

            if (argOneRewardFuncPath != null && argTwoRewardFuncPath != null)
            {
                arguments[0] = GetNode(argOneRewardFuncPath) as RewardFunc;
                arguments[1] = GetNode(argTwoRewardFuncPath) as RewardFunc;
                arguments[0].Subscribe(this);
                arguments[1].Subscribe(this);
            }
            else
            {
                var count = 0;
                foreach (Node node in GetChildren())
                {
                    if (node.GetType().IsSubclassOf(typeof(RewardFunc)))
                    {
                        RewardFunc r = node as RewardFunc;
                        arguments[count++] = r;
                        r.Subscribe(this);
                        if (count >= NB_OF_ARGS)
                        {
                            break;
                        }
                    }
                }
            }
        }
 public override void OnCreate()
 {
     events = new List <RewardFunc>();
     if (eventsPath != null)
     {
         for (int i = 0; i < eventsPath.Count; i++)
         {
             RewardFunc rf = GetNode(eventsPath[i]) as RewardFunc;
             events.Add(rf);
             rf.Subscribe(this);
         }
     }
     else
     {
         foreach (Node node in GetChildren())
         {
             if (node.GetType().IsSubclassOf(typeof(RewardFunc)))
             {
                 RewardFunc r = node as RewardFunc;
                 events.Add(r);
                 r.Subscribe(this);
             }
         }
     }
 }