Esempio n. 1
0
    private void RunGOAP()
    {
        var actions = new List <GOAPAction <BomberEnemy> >();

        actions.Add(new GOAPAction <BomberEnemy>
                    (
                        "GoCore",
                        1f,
                        bomber => bomber.currentLife > bomber.maxLife / 2,
                        bomber =>
        {
            BomberEnemy bomberEnemy = this;

            var tempPath = LazyAStar.Run(target, IsTarget, NeightAndDanger, DistanceToCoreNode).ToList();
            for (int i = 0; i < tempPath.Count - 1; i++)
            {
                bomberEnemy.path.Enqueue(tempPath[i].Item2);
            }
            return(bomberEnemy);
        }

                    ));

        actions.Add(new GOAPAction <BomberEnemy>
                    (
                        "AttackCore",
                        0.5f,
                        bomber => bomber.target.nextNodes.First() == NodeConteiner.instance.TargetNode(),
                        bomber =>
        {
            BomberEnemy bomberEnemy = this;
            bomberEnemy.target      = NodeConteiner.instance.TargetNode();
            return(bomberEnemy);
        }

                    ));

        GOAP.Run(this, x => x.target = NodeConteiner.instance.TargetNode(),
                 actions, Heuristic);
    }
Esempio n. 2
0
 public IEnumerable <Tuple <bool, GoapState, IEnumerable <GoapState> > > Execute()
 {
     return(LazyAStar.Run(_currentState, SatisfiesGoal, Expand, Heuristic, Equals));
 }