Ejemplo n.º 1
0
        public ExplorerAgent(AIController ai, AssistAgent assist, String name) : base(ai, name)
        {
            ActorSelector selector = new ActorSelector()
            {
                registerCondition = gameObject => gameObject.GetComponent <FOWEntity>().IsOwnedByPlayer,
                fireCondition     = gameObject => true
            };

            Subscriber <FOWEntity.Actions, FOWEntity> .get.registerForAll(FOWEntity.Actions.DISCOVERED, OnEntityFound, selector);

            Subscriber <FOWEntity.Actions, FOWEntity> .get.registerForAll(FOWEntity.Actions.HIDDEN, OnEntityLost, selector);

            // Setup difficulty levels
            switch (ai.DifficultyLvl)
            {
            case 0:
                isEnabled = false;
                break;

            case 1:
                RescheduleSightRange              = 0;
                ReschuduleDiceFaces               = 1000;
                RescheduleRandomPointValue        = 1000;
                RescheduleRandomAroundTargetValue = 990;
                RescheduleRandomDirectionValue    = 970;
                MaxExplorerSquads = 1;
                break;

            case 2:
                RescheduleSightRange              = 15;
                ReschuduleDiceFaces               = 1000;
                RescheduleRandomPointValue        = 1000;
                RescheduleRandomAroundTargetValue = 990;
                RescheduleRandomDirectionValue    = 970;
                MaxExplorerSquads = 2;
                break;

            case 3:
            default:
                RescheduleSightRange              = 30;
                ReschuduleDiceFaces               = 1000;
                RescheduleRandomPointValue        = 1000;
                RescheduleRandomAroundTargetValue = 990;
                RescheduleRandomDirectionValue    = 970;
                MaxExplorerSquads = 2;
                break;
            }


            heroVisible = false;
            terrain     = Terrain.activeTerrain;
            fowManager  = FOWManager.Instance;
            heroLastPos = Vector3.zero;
            assistAgent = assist;
        }
Ejemplo n.º 2
0
 public void OnDisable()
 {
     if (activated)
     {
         FOWManager fow = FOWManager.Instance;
         if (fow)
         {
             fow.removeEntity(this);
         }
     }
 }
Ejemplo n.º 3
0
    //method to avoid having to call OnEnable Directly,
    private void onEnableSoft()
    {
        FOWManager fow = FOWManager.Instance;

        if (fow)
        {
            fow.addEntity(this);
            if (fow.Enabled)
            {
                IsRevealed = fow.isThereinRect(Bounds, FOWManager.visible.visible, !IsOwnedByPlayer);
            }
            notFullyOpaque = fow.NotFullyOpaque;
            if (!IsOwnedByPlayer)
            {
                changeRenders(IsRevealed);
            }
            //If the entity gets created in a visible zone it's still "discovered".
            //If it gets created deep in the FOW it doesn't count as "hidden"-
            if (IsRevealed)
            {
                fire(Actions.DISCOVERED);
            }
        }
    }
Ejemplo n.º 4
0
 void Start()
 {
     fow = FOWManager.Instance;
 }
Ejemplo n.º 5
0
 void Start()
 {
     fow = FOWManager.Instance;
 }
Ejemplo n.º 6
0
		public ExplorerAgent(AIController ai, AssistAgent assist, String name) : base(ai, name)
        {
            ActorSelector selector = new ActorSelector()
            {
                registerCondition = gameObject => gameObject.GetComponent<FOWEntity>().IsOwnedByPlayer,
                fireCondition = gameObject => true
            };
            Subscriber<FOWEntity.Actions, FOWEntity>.get.registerForAll(FOWEntity.Actions.DISCOVERED, OnEntityFound, selector);
            Subscriber<FOWEntity.Actions, FOWEntity>.get.registerForAll(FOWEntity.Actions.HIDDEN, OnEntityLost, selector);

            // Setup difficulty levels
            switch (ai.DifficultyLvl)
            {
                case 0:
                    isEnabled = false;
                    break;

                case 1:
                    RescheduleSightRange = 0;
                    ReschuduleDiceFaces = 1000;
                    RescheduleRandomPointValue = 1000;
                    RescheduleRandomAroundTargetValue = 990;
                    RescheduleRandomDirectionValue = 970;
                    MaxExplorerSquads = 1;
                    break;

                case 2:
                    RescheduleSightRange = 15;
                    ReschuduleDiceFaces = 1000;
                    RescheduleRandomPointValue = 1000;
                    RescheduleRandomAroundTargetValue = 990;
                    RescheduleRandomDirectionValue = 970;
                    MaxExplorerSquads = 2;
                    break;
                    
                case 3:
                default:
                    RescheduleSightRange = 30;
                    ReschuduleDiceFaces = 1000;
                    RescheduleRandomPointValue = 1000;
                    RescheduleRandomAroundTargetValue = 990;
                    RescheduleRandomDirectionValue = 970;
                    MaxExplorerSquads = 2;
                    break;
            }
            

            heroVisible = false;
            terrain = Terrain.activeTerrain;
            fowManager = FOWManager.Instance;
            heroLastPos = Vector3.zero;
            assistAgent = assist;
        }
Ejemplo n.º 7
0
        bool findPlaceToExplore(FOWManager.visible[] grid, Vector2 size, out Vector3 targetPoint, Vector3 center, float maxRadius, int maxTries = 5)
        {
            bool found = false;
            targetPoint = Vector3.zero;

            for (int i = 0; i < maxTries && !found; ++i)
            {
                if (!DetourCrowd.Instance.RandomValidPointInCircle(center, maxRadius, ref targetPoint))
                {
                    return false;
                }

                Vector2 gridPos = fowManager.CoordtoGrid(targetPoint);
                if ((FOWManager.visible.unexplored & grid[(int)(gridPos.x + gridPos.y * size.y)]) == FOWManager.visible.unexplored)
                {
                    found = true;
                }
            }

            return found;
        }
Ejemplo n.º 8
0
        bool findPlaceToExplore(FOWManager.visible[] grid, Vector2 size, out Vector3 targetPoint, bool enforceDirection, Vector3 currentPos, Vector3 currentPoint, int maxTries = 5)
        {
            bool found = false;
            targetPoint = Vector3.zero;

            Vector3 direction = Vector3.zero;

            if (enforceDirection)
            {
                direction = (currentPoint - currentPos).normalized;
            }

            for (int i = 0; i < maxTries && !found; ++i)
            {
                if (!DetourCrowd.Instance.RandomValidPoint(ref targetPoint))
                {
                    return false;
                }

                Vector2 gridPos = fowManager.CoordtoGrid(targetPoint);
                if ((FOWManager.visible.unexplored & grid[(int)(gridPos.x + gridPos.y * size.y)]) == FOWManager.visible.unexplored)
                {
                    if (enforceDirection)
                    {
                        float angle = angleDirection(currentPos, currentPoint, targetPoint);
                        if (angle < -10f || angle > 10f)
                        {
                            continue;
                        }
                    }

                    found = true;
                }
            }

            return found;
        }
Ejemplo n.º 9
0
 bool findPlaceToExplore(FOWManager.visible[] grid, Vector2 size, out Vector3 targetPoint, int maxTries = 5)
 {
     return findPlaceToExplore(grid, size, out targetPoint, false, Vector3.zero, Vector3.zero, maxTries);
 }