private void OnCollisionEnter(Collision collision)
    {
        Rigidbody otherRB = collision.collider.attachedRigidbody;

        otherRB.isKinematic = false;

        CharacterController controller        = GetComponentInParent <CharacterController>();
        PoolCueBehavior     poolCue           = GetComponentInParent <PoolCueBehavior>();
        RagDollController   ragDollController = collision.gameObject.GetComponentInParent <RagDollController>();

        if (ragDollController)
        {
            ragDollController.isRagdollOn = true;
        }

        float movementScale = controller.velocity.magnitude / poolCue.poolCueMovementSpeed;

        float forceToApply = hitForce * movementScale;

        otherRB.AddForce(transform.forward * forceToApply, ForceMode.Impulse);
    }
示例#2
0
 public virtual void Start()
 {
     anim    = GetComponentInChildren <Animator>();
     ragdoll = GetComponent <RagDollController>();
     agent   = GetComponent <NavMeshAgent>();
 }
示例#3
0
 private void Awake()
 {
     ragDollController = GetComponent <RagDollController>();
 }
示例#4
0
    public void setUp(Transform newHead, RagDollController newRagdoll, Transform[] newAccessories)
    {
        head = newHead;
        ragDoll = newRagdoll;
        accessories = newAccessories;
        pathMover = GetComponent<PathMover>();
        player = GameObject.FindWithTag ("Player").transform;
        GameObject guardRoomObj = GameObject.FindWithTag("GuardRoom");
        if (guardRoomObj) guardRoom = guardRoomObj.GetComponent<GuardRoom>();

        enemyAI = GetComponent<EnemyAI>();
        enemyAnimator = GetComponent<EnemyAnimator>();
        characterController = GetComponent<CharacterController>();
        startWalking();
        Events.Listen(gameObject, "SoundEvents");

        //color the minimap dot
        Transform miniMapDot = transform.Find("MiniMapUnit");
        if (miniMapDot) {
            switch (EnemyType) {
            case EnemyTypes.Guard :
                miniMapDot.renderer.material.color = Color.red;
                break;
            case EnemyTypes.Janitor :
                miniMapDot.renderer.material.color = Color.cyan;
                break;
            default :
                miniMapDot.renderer.material.color = Color.black;
                break;
            }
            miniMapDot.renderer.material.renderQueue = 3000 + Random.Range(1, 500);
        }
    }
示例#5
0
    public void SetUp(Transform thiefHead, RagDollController thiefRagDoll, BombThrower newBombThrower, WristWeapon newWristWeapon)
    {
        ragDoll = thiefRagDoll;
        playerBombThrower = newBombThrower;
        wristWeapon = newWristWeapon;
        characterController = GetComponent<CharacterController>();
        playerAnimator = GetComponent<PlayerAnimator>();

        Transform miniMapDot = transform.Find("MiniMapUnit");
        if (miniMapDot) {
            miniMapDot.renderer.material.color = Color.yellow;
            miniMapDot.renderer.material.renderQueue = 3500;
        }
        GameObject gameControlObj = GameObject.Find ("GameControl");
        gameControl = gameControlObj.GetComponent<GameControl>();
    }