using System.Collections; using System.Collections.Generic; using UnityEngine; namespace BehaviorTreeSlayer { public class CreateItem : ActionNode { [OutField] public Color EggColor; [OutField] public string ItemName = "egg"; public override TaskResult Tick(double dt, object args = null) { BehaviorTree behaviorTree = args as BehaviorTree; GameObject obj = behaviorTree[ItemName] as GameObject; GameObject egg = GameObject.Instantiate(obj); Vector3 bias = new Vector3((float)(behaviorTree.MyRandom.NextDouble() * 5 - 2.5), (float)(behaviorTree.MyRandom.NextDouble() * 3 - 1.5)); egg.transform.position = behaviorTree.transform.position + bias; egg.GetComponent().color = EggColor; return base.Tick(dt, args); } } }