/// <inheritdoc/>
        public override void Init(AIEntity entity)
        {
            base.Init(entity);

            walkRand = new AIWalkRandPos(entity, new Vector2(2, 3), 2.5f);

            //Switch close agents to attention as well
            List <AIEntity> aiInZone = entity.assignedZone.assignedAIs;

            for (int i = 0; i < aiInZone.Count; i++)
            {
                if (aiInZone[i] == entity)
                {
                    continue;
                }

                float distance = Vector3.Distance(entity.transform.position, aiInZone[i].transform.position);
                if (distance < entity.Sensors.HearingRadius)
                {
                    aiInZone[i].Attention();
                }
            }

            //Setup timer to idle
            entity.Data.currentAttentionWaitTime           = entity.Data.AttentionWaitTime;
            entity.Data.currentAttentionPlayerSpotWaitTime = entity.Data.AttentionPlayerSpotWaitTime;
            entity.Sensors.OnHearSound += Sensors_OnHearSound;
        }
Esempio n. 2
0
        /// <inheritdoc/>
        public override void Init(AIEntity entity)
        {
            base.Init(entity);

            weaponBehaviour = new AIWeaponBehaviour(entity);
            walkRand        = new AIWalkRandPos(entity, new Vector2(1, 2), 3.5f);

            //Move to last player position and setup timer
            if (!entity.InFear)
            {
                controller?.MoveTo(entity.Data.lastSeenPlayerPosition);
            }
            entity.Data.currentAggresionWaitTime = entity.Data.AggresionWaitTime;

            entity.Sensors.OnHearSound += Sensors_OnHearSound;

            if (controller && Utils.CalculateChance(controller.CoverOnAggressionChance) && !entity.InFear)
            {
                controller.GetCover();
            }
        }