mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 19:34:47 +00:00
24 lines
884 B
C#
24 lines
884 B
C#
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<SpriteRenderer>().color = EggColor;
|
|
return base.Tick(dt, args);
|
|
}
|
|
}
|
|
|
|
} |