コード例 #1
0
        ///<inheritdoc/>
        public override void Init(AIEntity entity)
        {
            base.Init(entity);

            weaponBehaviour = new AIWeaponBehaviour(entity);
            visionResult    = new AISensors.VisionResult();
            //set random cover time from cover and move to it
            done = false;
            time = Random.Range(currentCover.TimeInCover.x, currentCover.TimeInCover.y);
            controller?.ForceMoveTo(currentCover.transform.position);
        }
コード例 #2
0
        ///<inheritdoc/>
        public override void Init(AIEntity entity)
        {
            base.Init(entity);

            entity.Data.sleepTimer = maxTime = entity.Data.SleepTimeRange.GetRandom() * Multiplier;
            //entity.sensors.OnHearSound += Sensors_OnHearSound;
            //Clear movement
            controller?.Stop();
            controller?.AnimationAnchor.Animator.SetTrigger("SleepStart");
            controller?.AnimationAnchor.Animator.SetBool("Sleep", true);
        }
コード例 #3
0
        ///<inheritdoc/>
        public override void Init(AIEntity entity)
        {
            base.Init(entity);

            if (controller)
            {
                controller.NavMeshAgent.speed = climbData.speed;
                controller.AnimationAnchor.Animator.SetBool(climbData.down ? "RopeClimbDown" : "RopeClimb", true);
                controller.AnimationAnchor.Animator.SetBool(!climbData.down ? "RopeClimbDown" : "RopeClimb", false);
            }
        }
コード例 #4
0
        /// <summary>
        /// Register the entity in the AIManager and assign the AIZone for it based on its position.
        /// </summary>
        public void RegisterAI(AIEntity ai)
        {
            ais.Add(ai);

            AIZone zone = AIZone.GetZoneByPos(ai.transform.position);

            if (zone == null)
            {
                zone = AIZone.CreateSceneSizeZone();
            }

            zone.AddAI(ai);

            UpdateAttackOrder();
        }
コード例 #5
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();
            }
        }
コード例 #6
0
 /// <summary>
 /// Create AIBehaviour object and link to the owner
 /// </summary>
 public AIBehaviour(AIEntity entity)
 {
     this.entity = entity;
 }
コード例 #7
0
 ///<inheritdoc/>
 public AIWeaponBehaviour(AIEntity entity) : base(entity)
 {
 }
コード例 #8
0
 ///<inheritdoc/>
 public AIWalkRandPos(AIEntity entity, Vector2 updateRange, float maxDistance) : base(entity)
 {
     this.maxDistance = maxDistance;
     this.updateRange = updateRange;
     UpdateRandPos();
 }
コード例 #9
0
 /// <summary>
 /// Index of the entity
 /// </summary>
 public int GetIndex(AIEntity entity)
 {
     return(ais.IndexOf(entity));
 }
コード例 #10
0
 /// <summary>
 /// Can the entity use a weapon?
 /// </summary>
 public bool CanFire(AIEntity entity)
 {
     return(aisAttack[GetIndex(entity)]);
 }
コード例 #11
0
ファイル: GameUI.cs プロジェクト: alex-kulikov/outblock-unity
 /// <summary>
 /// Set last hitted enemy.
 /// </summary>
 public void EnemyDamage(AIEntity entity)
 {
     lastEnemy        = entity;
     lastEnemyTimeout = lastEnemyCooldown;
 }
コード例 #12
0
ファイル: GameUI.cs プロジェクト: alex-kulikov/outblock-unity
        private void Update()
        {
            if (pauseDelayed != pause && !pauseUpdating)
            {
                StartCoroutine(UpdatePause());
            }

            if (saveLoadIndicatorTime > 0)
            {
                saveLoadIndicatorTime -= Time.unscaledDeltaTime;
                Color color = saveLoadIndicator.color;
                color.a = saveLoadIndicatorTime;
                saveLoadIndicator.color = color;
            }

            if (lastEnemyTimeout > 0)
            {
                lastEnemyTimeout  -= Time.deltaTime;
                enemyHP.fillAmount = lastEnemy ? lastEnemy.HPRatio : 0;

                if (lastEnemyTimeout <= 0)
                {
                    lastEnemy = null;
                }
            }
            enemyHPHolder.SetActive(lastEnemyTimeout > 0);

            if (bonusFadeOutTime > 0)
            {
                bonusFadeOutTime -= Time.deltaTime;
            }
            bonusHolder.alpha = bonusFadeOutTime;

            hpSegments.gameObject.SetActive(!(pause && !pauseWindow.activeSelf));

            if (messageTime > 0)
            {
                messageTime -= Time.deltaTime;
                float alpha = Mathf.Clamp01(messageTime);
                messageText.canvasRenderer.SetAlpha(alpha);
            }

            if (pauseWindow.activeSelf)
            {
                bonusHolder.alpha = 1;
            }

            AIManager.States state = AIManager.Instance().GetAIStatus(out float cooldown);
            switch (state)
            {
            case AIManager.States.Idle:
                stealth.color     = Color.clear;
                alertSound.volume = 0;
                alarmSound.volume = 0;
                break;

            case AIManager.States.Attention:
                if (stealth.color == Color.clear)
                {
                    soundContainer.PlaySound("alert");
                }
                stealth.color     = new Color(1, 1, 1, Mathf.PingPong(Time.time * 2, 1));
                alertSound.volume = 0.06f;
                alarmSound.volume = 0;
                break;

            case AIManager.States.Aggresion:
                stealth.color     = Color.red;
                alertSound.volume = 0;
                alarmSound.volume = 0.06f;
                break;
            }

            cooldownHolder.SetActive(cooldown > 0 && cooldown < 1);
            cooldownFill.fillAmount = cooldown;
        }