コード例 #1
0
        private ACharacter FindAimedCharacter()
        {
            var        opponents = GameManager.Instance.GetOpponents(controlledCharacter);
            ACharacter target    = null;

            if (opponents.Count > 0)
            {
                var bestTarget = opponents.OrderByDescending(c =>
                {
                    var dir = c.CharacterTransform.position - controlledCharacter.CharacterTransform.position;
                    dir.y   = 0;
                    dir.Normalize();

                    return(Vector3.Dot(dir, AimDirection));
                }).ElementAt(0);

                var bestDir = bestTarget.CharacterTransform.position - controlledCharacter.CharacterTransform.position;
                bestDir.y = 0;
                bestDir.Normalize();

                if (Vector3.Dot(bestDir, AimDirection) >= (1 - AimAssist))
                {
                    target = bestTarget;
                }
            }

            return(target);
        }
コード例 #2
0
        public override void PreInitComponent(ACharacter controlledChar)
        {
            base.PreInitComponent(controlledChar);

            Action keyboardAction = SetRightStickFromKeyboard;
            Action gamepadAction  = SetRightStickFromGamepad;

            getRightStickAction = ((CharacterPlayer)controlledChar).UseKeyboardMouse ? keyboardAction : gamepadAction;

            mainCamera = Camera.main;
        }