Beispiel #1
0
    void Awake()
    {
        input        = GetComponent <PlayerInput>();
        camera       = FindObjectOfType <CameraController>();
        audioManager = FindObjectOfType <AudioManager>();

        rb           = GetComponent <Rigidbody>();
        mainCollider = GetComponent <CapsuleCollider>();

        modelTransform = GameObject.Find("PlayerModel").transform;
        animator       = modelTransform.GetComponent <Animator>();

        debugText        = GameObject.Find("debugText").GetComponent <Text>();
        hangCollider     = GameObject.Find("HangCollider").GetComponent <DelayedCollider>();
        grabArmCollider  = GameObject.Find("GrabArmCollider").GetComponent <DelayedCollider>();
        interactHintText = GameObject.Find("InteractHint").GetComponent <Text>();

        groundDetector   = new GroundDetector(transform);
        interactDetector = new InteractDetector(transform, modelTransform);
        ledgeDetector    = new LedgeDetector(transform, modelTransform);

        climbController = GetComponent <ClimbController>();

        dialogueManager = FindObjectOfType <DialogueManager>();

        currentCheckpoint = GameObject.Find(defaultCheckpoint).GetComponent <CheckpointManager>();

        livesUI = new LivesUI(lives);
    }
        public void Update(float frameTime)
        {
            if (Body != null && IsClimbing)
            {
                if (_climbController != null && (_climbController.IsBlocked || !_climbController.IsActive))
                {
                    if (Body.TryRemoveController <ClimbController>())
                    {
                        _climbController = null;
                    }
                }

                if (IsClimbing)
                {
                    Body.WakeBody();
                }

                if (!IsOnClimbableThisFrame && IsClimbing && _climbController == null)
                {
                    IsClimbing = false;
                }

                IsOnClimbableThisFrame = false;
            }
        }
 /// <summary>
 /// Make the owner climb from one point to another
 /// </summary>
 public void TryMoveTo(Vector2 from, Vector2 to)
 {
     if (Body != null)
     {
         _climbController = Body.EnsureController <ClimbController>();
         _climbController.TryMoveTo(from, to);
     }
 }
 private void GrabObject(ClimbController _climbController = null)
 {
     if (holdingTarget.GetComponent <InteractableObject>().Climbable)
     {
         holdingTarget.GetComponent <InteractableObject>().GrabMe(this, _climbController);
     }
     else
     {
         holdingTarget.GetComponent <InteractableObject>().GrabMe(this);
     }
     isGrabbing = true;
 }
 private void UnGrabObject(ClimbController _climbController = null)
 {
     if (holdingTarget && holdingTarget.GetComponent <InteractableObject>().IsGrabbing(this) &&
         holdingTarget.GetComponent <InteractableObject>().Climbable)
     {
         holdingTarget.GetComponent <InteractableObject>().UngrabMe(this, _climbController);
     }
     else if (holdingTarget && holdingTarget.GetComponent <InteractableObject>().IsGrabbing(this) &&
              !holdingTarget.GetComponent <InteractableObject>().Climbable)
     {
         holdingTarget.GetComponent <InteractableObject>().UngrabMe(this);
     }
     isGrabbing = false;
 }
Beispiel #6
0
    void Start()
    {
        m_Animator      = GetComponent <Animator>();
        m_Rigidbody     = GetComponent <Rigidbody>();
        m_Capsule       = GetComponent <CapsuleCollider>();
        m_CapsuleHeight = m_Capsule.height;
        m_CapsuleCenter = m_Capsule.center;

        m_Rigidbody.constraints   = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;
        m_OrigGroundCheckDistance = m_GroundCheckDistance;

        climbController                  = GetComponentInChildren <ClimbController>();
        climbController.climbEvent      += OnClimb;
        climbController.climbSlopeEvent += OnAutoClimbSlope;
    }
Beispiel #7
0
 void Start()
 {
     lastPosition      = gameObject.transform.position;
     defaultFog        = RenderSettings.fog;
     defaultFogColor   = RenderSettings.fogColor;
     defaultFogDensity = RenderSettings.fogDensity;
     defaultSkybox     = RenderSettings.skybox;
     if (soundSource == null)
     {
         soundSource = GetComponent <AudioSource>();
     }
     targetCam       = GameObject.FindGameObjectWithTag(swimTowardCamLook).GetComponent <Camera>();
     climbController = (climbController == null) ? GetComponent <ClimbController>() : climbController;
     moveController  = (moveController == null) ? GetComponent <MovementController>() : moveController;
     weaponManager   = (weaponManager == null) ? GetComponentInChildren <WeaponManagerNew>() : weaponManager;
 }
Beispiel #8
0
    public void UngrabMe(GrabObjController _hand, ClimbController _climbController = null)
    {
        if (Climbable)
        {
            _mainHandClimb = null;
            _climbController.DropHand(_hand.gameObject);
            return;
        }

        if (_mainHandGrab == _hand)
        {
            _mainHandGrab = null;
        }
        if (_offHandGrab == _hand)
        {
            _offHandGrab = null;
        }
    }
Beispiel #9
0
    private void Start()
    {
        // get the components on the object we need ( should be not null due to require component so no need to check )
        agent                       = GetComponentInChildren <NavMeshAgent>();
        character                   = GetComponent <ClimbCharacter>();
        climbController             = GetComponentInChildren <ClimbController>();
        climbController.climbEvent += ClimbEvent;
        GetComponentInChildren <PlayerDetector>().detectPlayerEvent += OnDetectPlayer;
        GetComponentInChildren <MeleeAttack>().attackEvent          += AttackEvent;
        m_Sound = GetComponent <SoundManager>();

        agent.updateRotation = false;
        agent.updatePosition = true;


        fsm = new FSM(this, new FSM.StateMethod[] { Wander, Chase, ClimbInChase, JumpInChase, Die, Attack });

        fsm.Start();
    }
Beispiel #10
0
 public void GrabMe(GrabObjController _hand, ClimbController _climbController = null)
 {
     if (Climbable)
     {
         _mainHandClimb = _hand;
         _climbController.StartClimbObject(_hand.gameObject);
         return;
     }
     if (!PickupAble)
     {
         return;
     }
     if (!_mainHandGrab)
     {
         _mainHandGrab = _hand;
     }
     else
     {
         _offHandGrab = _hand;
     }
 }
Beispiel #11
0
    private void Start()
    {
        // get the transform of the main camera
        if (Camera.main != null)
        {
            m_Cam = Camera.main.transform;
        }
        else
        {
            Debug.LogWarning(
                "Warning: no main camera found. Third person character needs a Camera tagged \"MainCamera\", for camera-relative controls.", gameObject);
            // we use self-relative controls in this case, which probably isn't what the user wants, but hey, we warned them!
        }

        // get the third person character ( this should never be null due to require component )
        m_Character                 = GetComponent <ClimbCharacter>();
        climbController             = GetComponentInChildren <ClimbController>();
        climbController.climbEvent += ClimbEvent;
        //climbController.jumpEvent += JumpEvent; //Uncomment to hablity jump against wall or double jump
        frisbeeThrower = GetComponentInChildren <FrisbeeThrower>();
        GetComponent <Health>().onChangeHealthEvent += ChangeHealth;
    }
 private void Start()
 {
     interactable    = GetComponent <XRSimpleInteractable>();
     climbController = GetComponentInParent <ClimbController>();
     isGrabbing      = false;
 }