public void Init() { IConfiguration config = new BlockCorpseDisintigrationFixConfig(SEARCH_RADIUS, WORLD_HEIGHT, 0, CACHE_PERSISTANCE, true, false); corpseBlock = new BlockValue(); fakeWorld = new FakeWorld(config); positioner = new ZombieCorpsePositioner(Console.WriteLine, location => fakeWorld.GetBlockAt(location).IsStableBlock, (location, corpseBlock) => fakeWorld.GetBlockAt(location).IsValidSpawnPosition, new GroundFinder(config, location => fakeWorld.GetBlockAt(location).IsCollideMovement, new GroundPositionCache(new CacheTimer(config.CACHE_PERSISTANCE, GetTick))), config); }
public void Init() { fakeTimer = new FakeCacheTimer(); fakeTimer.IsCacheValid = true; IConfiguration config = new BlockCorpseDisintigrationFixConfig(5, WORLD_HEIGHT, 0, CACHE_PERSISTANCE, true, false); fakeWorld = new FakeWorld(config); groundFinder = new GroundFinder(config, location => fakeWorld.GetBlockAt(location).IsCollideMovement, new GroundPositionCache(fakeTimer)); }
public override NodeState Run(Agent agent) { Door door = FakeWorld.GetNearestObjectOfType <Door>(agent); if (door == null) { return(NodeState.Aborted); //there is no door(1) } if (Vector3.Distance(agent.transform.position, door.transform.position) <= 0.5f) { return(NodeState.Aborted); //door is too far away(2) } Vector3 dir = (door.transform.position - agent.transform.position).normalized; agent.transform.position += dir * 3f * Time.deltaTime; return(NodeState.Running); }
public override NodeState Run(Agent agent) { Door door = FakeWorld.GetNearestObjectOfType <Door>(agent); if (door == null) { return(NodeState.Aborted); //there is no door(1) } if (Vector3.Distance(agent.transform.position, door.transform.position) > 0.5f) { return(NodeState.Aborted); //door is too far away(2) } door.locked = false; door.GetComponent <Renderer>().material.color = Color.red; Debug.Log("Door smashed"); GameObject.Destroy(door); return(NodeState.Done); }
public override NodeState Run(Agent agent) { Door door = FakeWorld.GetNearestObjectOfType <Door>(agent); if (door == null) { return(NodeState.Aborted); //there is no door(1) } if (Vector3.Distance(agent.transform.position, door.transform.position) > 0.5f) { return(NodeState.Aborted); //door is too far away(2) } if (door.locked) { return(NodeState.Aborted); //door locked(3) } //if (!agent.hasKey) // return NodeState.Aborted; //have no keys available(3) //at this point i'm sure that: there is a door(1), the door is in range(2) and door is no lcoked(3), i can open door. door.GetComponent <Renderer>().material.color = Color.green; Debug.Log("Door opened without key"); return(NodeState.Done); }
public override NodeState Run(Agent agent) { Door door = FakeWorld.GetNearestObjectOfType <Door>(agent); if (door == null) { return(NodeState.Aborted); //there is no door(1) } if (Vector3.Distance(agent.transform.position, door.transform.position) > 0.5f) { return(NodeState.Aborted); //door is too far away(2) } if (!agent.hasKey) { return(NodeState.Aborted); //have no keys available(4) } if (!door.locked) { return(NodeState.Aborted); //door locked(3) } door.locked = false; Debug.Log("Unlocked door with key"); return(NodeState.Done); }
// Use this for initialization void Start() { FakeWorld.AddWorldObject <Door>(gameObject.name, this); }