Пример #1
0
 // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     character = animator.gameObject.GetComponent <PhysicsCharacterController>();
     character.transform.position = character.targetCar.entryPoints[character.entryPoint].entryPoint.position;
     character.transform.rotation = character.targetCar.entryPoints[character.entryPoint].entryPoint.rotation;
     animator.SetBool("GetIn", true);
 }
Пример #2
0
    // Use this for initialization
    void Start()
    {
        // find the player and move to this location
        GameObject player = GameObject.Find("Player");

        if (player == null)
        {
            playerAndGUI = (GameObject)Instantiate(defaultPlayer, Vector3.zero, Quaternion.identity);            //AngleAxis(270.0f,Vector3.up) );
            foreach (Transform child in playerAndGUI.transform)
            {
                if (child.gameObject.name == "Player")
                {
                    player = child.gameObject;
                }
            }
        }
        if (playerStartLocation != null)
        {
            player.transform.position = playerStartLocation.transform.position;
        }
        else
        {
            player.transform.position = transform.position;
        }

        // stop any movement
        player.rigidbody.velocity = Vector3.zero;

        // make sure the camera is enabled
        PlayerAttributes pa = (PlayerAttributes)player.GetComponent("PlayerAttributes");

        pa.ActivateCamera();
        if (firstSpawnPoint != null)
        {
            pa.SetRespawn(firstSpawnPoint.transform.position);
        }
        else if (playerStartLocation != null)
        {
            pa.SetRespawn(playerStartLocation.transform.position);
        }
        else
        {
            pa.SetRespawn(gameObject.transform.position);
        }

        // make player unmoveable if animation needs playing
        if (playAnimationOnLevelStart)
        {
            physicsController = (PhysicsCharacterController)player.GetComponent("PhysicsCharacterController");
            physicsController.isControllable = false;
            anim = (Animation)GetComponent("Animation");
            anim.playAutomatically = true;
        }
        else
        {
            playerReady = true;
        }
        //Debug.Log("Level begin start");
    }
Пример #3
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.CompareTag("Player") && !isActivated)
     {
         Debug.Log("Player touched checkpoint.");
         PhysicsCharacterController player = collision.GetComponent <PhysicsCharacterController>();
         player.SetCurrentCheckpoint(this);
         audioSource.Play();
     }
 }
    void Awake()
    {
        characterController = gameObject.GetOrAddComponent <PhysicsCharacterController>();

        m_cameraTarget = Instantiate(settings.value.cameraTargetPrefab);
        if (m_cameraTarget != null)
        {
            m_cameraTarget.Init(this);
        }
    }
Пример #5
0
 // Update is called once per frame
 void Update()
 {
     if (reachedEnd)
     {
         if ((playAnimationOnLevelEnd && !animation.IsPlaying(clipForEnd.name)) || !playAnimationOnLevelEnd)
         {
             PhysicsCharacterController pa = (PhysicsCharacterController)GameObject.Find("Player").GetComponent("PhysicsCharacterController");
             pa.isControllable = false;
             Application.LoadLevel(nextLevel);
         }
     }
 }
    //OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        attackManager           = animator.GetComponent <AttackManager>();
        playerMovement          = animator.GetComponent <PhysicsCharacterController>();
        attackManager.CanAttack = false;

        if (Gamepad.current != null)
        {
            InputSystem.ResumeHaptics();
            Gamepad.current.SetMotorSpeeds(0.25f, 0.75f);
        }
    }
Пример #7
0
    /// <summary>
    /// initial setup of this controller
    /// </summary>
    private void InitController()
    {
        // TO REMOVE -  -   -   -   -
        Application.targetFrameRate = 140;
        QualitySettings.vSyncCount  = 0;

        // Get the reff for the physics controller
        physicsCharacter = GetComponentInChildren <PhysicsCharacterController>();
        // get the ref of the target animator
        playerTargetAnimator = GetComponentInChildren <Animator>();

        // Validate the reff
        // if fails to find the physics controller
        if (!physicsCharacter || !playerTargetAnimator)
        {
            // Close the aplication
            AplicationFuncs.CloseApp();
            return;
        }

        // Debug information and initialize  the parts
        InformationPanel.DebugConsoleInput("Physics System connected!");
        physicsCharacter.InitParts();

        // Define the maximum velocity
        physicsCharacter.SetCharacterMaxSpeed(characterMaxVelocity);
        // define the kill speed
        physicsCharacter.SetCharacterKillVelocity(this.killVelocity);

        // Stunted  -   -   -   -   -
        // regist the for the stunted event
        physicsCharacter.stuntedDelegate += StuntedCallback;
        // init vars
        stunted = false;


        // Grab controller  -   -   -   -   -
        // get ref to controller
        this.playerGrabController = this.GetComponentInChildren <GrabController>();
        // Init with enable tag
        this.playerGrabController.Init(controllerState: true, lHand: ref LeftHandGO, rHand: ref RightHandGO);

        // Regists for jump delegate
        InputManager.Instance.jumpDelegate += () => { physicsCharacter.Jump(this.JumpValue); };

        // regist the controller to the action event
        InputManager.Instance.actionDelegate += playerGrabController.ActionCallback;
    }
Пример #8
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        // Check if the player bumped us. We need to ignore triggers,
        // or the player's ground check trigger will count for hitting hazards.
        // This is bad because the ground check circle collider is bigger than the
        // player's actual physical hitbox, which would result in false positives.
        if (collision.CompareTag("Player") && !collision.isTrigger)
        {
            //SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
            Debug.Log("Player hit hazard!");

            PhysicsCharacterController player = collision.GetComponent <PhysicsCharacterController>();

            player.Respawn();
        }
    }
Пример #9
0
    void Start()
    {
        if (healthMeter != null)
        {
            healthCounter = (Counter)healthMeter.GetComponent("Counter");
            healthCounter.UpdateCounter(health);
        }
        else
        {
            Debug.LogWarning(gameObject.name + ": PlayerAttributes: healthMeter object has not been assigned in the inspector.");
        }

        if (livesMeter != null)
        {
            livesCounter = (Counter)livesMeter.GetComponent("Counter");
            livesCounter.UpdateCounter(playerLives - 1);
        }
        else
        {
            Debug.LogWarning(gameObject.name + ": PlayerAttributes: livesMeter object has not been assigned in the inspector.");
        }
        pcc = (PhysicsCharacterController)GetComponent("PhysicsCharacterController");
    }
Пример #10
0
 // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     character = animator.gameObject.GetComponent <PhysicsCharacterController>();
     character.targetCar.entryPoints[character.entryPoint].startTime = Time.time;
     character.targetCar.entryPoints[character.entryPoint].exit      = true;
 }
Пример #11
0
 // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     character = animator.gameObject.GetComponent <PhysicsCharacterController>();
     character.insideVehicle = true;
 }