コード例 #1
0
ファイル: AICover.cs プロジェクト: 329258385/War-of-Free
        /// <summary>
        /// Told by the brains to take a cover closer to the enemy.
        /// </summary>
        public void ToTakeCoverCloseTo(AIBaseRegrouper regrouper)
        {
            _takeAnyCover = false;
            nullCover();

            if (isActiveAndEnabled)
            {
                _takeCloseToRadius = regrouper.Radius;

                var movement = regrouper.GetComponent <AIMovement>();
                _takeCloseToPosition = regrouper.transform.position;

                if (movement != null)
                {
                    _takeCloseToPosition = movement.Destination;
                }

                _covers.Reset(_takeCloseToPosition, MaxCoverDistance);

                _mode     = TakeMode.takeCloseTo;
                _modeWait = 2;
                Message("OnCoverSearch");
            }

            updateRegistration();
        }
コード例 #2
0
ファイル: AICover.cs プロジェクト: nhutkhanhng/GameDesign
        /// <summary>
        /// Told by the brains to take a cover closer to the enemy.
        /// </summary>
        public void ToTakeCoverCloseTo(AIBaseRegrouper regrouper)
        {
            _targetCover = null;

            if (isActiveAndEnabled)
            {
                var movement = regrouper.GetComponent <AIMovement>();
                var position = regrouper.transform.position;

                if (movement != null)
                {
                    position = movement.Destination;
                }

                _covers.Reset(position, MaxCoverDistance);

                foreach (var item in _covers.Items)
                {
                    if (Vector3.Distance(item.Position, position) <= regrouper.Radius)
                    {
                        if (isValidCover(item.Cover, item.Position, item.Direction, true))
                        {
                            takeCover(item.Cover, item.Position, item.Direction, 1);
                            Message("OnFoundCover");
                            return;
                        }
                    }
                }
            }

            updateRegistration();
        }