Esempio n. 1
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.");
            // 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 = GetComponentInChildren<HumanCharacter>();
        m_CharacterAim = GetComponent<HumanMovement>();
        //col = GetComponent<CapsuleCollider>();
        //startHeight = col.height;
        m_RigidBody = GetComponent<Rigidbody>();
        anim = GetComponentInChildren<Animator>();
        charStats = GetComponent<CharacterStats>();
        weaponManager = GetComponent<WeaponManager>();
        cameraFunctions = Camera.main.gameObject.GetComponentInParent<FreeCameraLook>();
        offsetCross = cameraFunctions.crosshairOffsetWiggle;
        //m_RigidBody.AddForce(1, 1, 1);

        //m_Character.Move(m_Move, crouch, m_Jump, false, lookPos);
    }
Esempio n. 2
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.");
            // 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    = GetComponentInChildren <HumanCharacter>();
        m_CharacterAim = GetComponent <HumanMovement>();
        //col = GetComponent<CapsuleCollider>();
        //startHeight = col.height;
        m_RigidBody     = GetComponent <Rigidbody>();
        anim            = GetComponentInChildren <Animator>();
        charStats       = GetComponent <CharacterStats>();
        weaponManager   = GetComponent <WeaponManager>();
        cameraFunctions = Camera.main.gameObject.GetComponentInParent <FreeCameraLook>();
        offsetCross     = cameraFunctions.crosshairOffsetWiggle;
        //m_RigidBody.AddForce(1, 1, 1);

        //m_Character.Move(m_Move, crouch, m_Jump, false, lookPos);
    }
Esempio n. 3
0
    private void Start()
    {
        Camera camera = Camera.main;

        float[] distances = new float[32];
        distances[10]             = 150;
        camera.layerCullDistances = distances;

        lerpTime            = 3;
        currentLerpTime     = 0;
        minAngleDiffForSwap = 10;
        maxSwapDistance     = 6;

        justSwitched   = false;
        swappingTarget = false;

        pitchMinMax = new Vector2(-5, 55);

        minDistance = 1.0f;
        maxDistance = 4.0f;

        mouseSensitivity   = 10;
        dstFromTarget      = 7.5f;
        rotationSmoothTime = 0.12f;

        target = Human;
        other  = Dog;

        humanPivot = GameObject.Find("HumanPivot").transform;
        dogPivot   = GameObject.Find("DogPivot").transform;

        targetPivot = humanPivot;
        otherPivot  = dogPivot;

        humanMovement = Human.GetComponent <HumanMovement>();
        dogMovement   = Dog.GetComponent <DogMovement>();

        humanAI = Human.GetComponent <HumanAI>();
        dogAI   = Dog.GetComponent <DogAI>();

        targetCC = target.GetComponent <CharacterController>();
        otherNVA = other.GetComponent <NavMeshAgent>();


        yaw = 90;

        if (lockCursor)
        {
            Cursor.lockState = CursorLockMode.Locked;
            Cursor.visible   = false;
        }
    }
Esempio n. 4
0
    IEnumerator doAction(GameObject human)
    {
        HumanMovement move = human.GetComponent <HumanMovement>();

        move.SetSpeed(0);

        transform.position = new Vector2(human.transform.position.x, human.transform.position.y + offsetY);


        yield return(new WaitForSeconds(1f));

        move.SetSpeed(move.normalSpeed);
        Destroy(gameObject);
    }
Esempio n. 5
0
    private void Update()
    {
        Vector3 playerPosition = player.transform.position;

        tempPosition = Vector3.zero;

        if (playerPosition.x <= transform.position.x - boxCollider.size.x / 2)
        {
            tempPosition += new Vector3(boxCollider.size.x, 0, 0);
            count        += 1;
        }
        else if (playerPosition.x >= transform.position.x + boxCollider.size.x / 2)
        {
            tempPosition += new Vector3(-boxCollider.size.x, 0, 0);
            count        += 1;
        }


        if (playerPosition.z <= transform.position.z - boxCollider.size.z / 2)
        {
            tempPosition += new Vector3(0, 0, boxCollider.size.z);
            count        += 1;
        }
        else if (playerPosition.z >= transform.position.z + boxCollider.size.z / 2)
        {
            tempPosition += new Vector3(0, 0, -boxCollider.size.z);
            count        += 1;
        }

        if (tempPosition != Vector3.zero)
        {
            HumanMovement cMove = player.GetComponent <HumanMovement>();
            cMove.Locked = true;
            player.transform.position += tempPosition;
        }

        if (count > 4)
        {
            dt.TriggerDialogue();
            count = 0;
        }

        tempPosition = Vector3.zero;
    }
Esempio n. 6
0
    void AttractHumans()
    {
        List <HumanProperties> allHumans = InfectionManager.Instance.getAllHumans();

        foreach (var human in allHumans)
        {
            if (
                human.status == HealthStatusEnum.healthy && interactHealthy ||      //check if healty
                human.status == HealthStatusEnum.infected && interactInfected       //check if infected
                )
            {
                //check if human is in range
                if (Vector2.Distance(transform.position, human.transform.position) <= range)
                {
                    HumanMovement move = human.GetComponent <HumanMovement>();
                    move.setTarget(transform);
                }
            }
        }
    }
    private void ChangeHumanGrabbed(bool grabbed)
    {
        if (targetObject == null)
        {
            return;
        }

        HumanMovement humanMovement = targetObject.GetComponent <HumanMovement>();

        if (humanMovement != null)
        {
            humanMovement.isGrabbed = grabbed;
        }

        HumanDeath humanDeath = targetObject.GetComponent <HumanDeath>();

        if (humanDeath)
        {
            humanDeath.attacker = gameObject;
            //StartCoroutine(ResetHumanGrabbed(humanDeath));
        }
    }
Esempio n. 8
0
    public override void Start()
    {
        base.Start();

        movement      = GetComponent <HumanMovement>();
        movement.anim = anim;

        gnomes = FindObjectsOfType <Gnome>();


        patrolState            = new PatrolState();
        patrolState.human      = this;
        noticingState          = new NoticingState();
        noticingState.human    = this;
        chaseState             = new ChaseState();
        chaseState.human       = this;
        searchState            = new SearchState();
        searchState.human      = this;
        alwaysChaseState       = new AlwaysChaseState();
        alwaysChaseState.human = this;

        stateMachine = new FSM(patrolState);
    }
Esempio n. 9
0
 private void Awake()
 {
     Instance = this;
 }
 void Start()
 {
     humanMovement = GetComponent <HumanMovement>();
     shootingTime  = 0;
     whichWeapon   = Random.Range(0, bulletPrefab.Length);
 }
Esempio n. 11
0
 void Start()
 {
     mMovement     = GetComponent <HumanMovement>();
     mPlayer       = GetComponent <Entity_Player>();
     mPlayerCamera = GetComponentInChildren <PlayerCamera>();
 }
Esempio n. 12
0
 private void Awake()
 {
     boxCollider         = GetComponent <BoxCollider2D>();
     humanMovement       = GetComponent <HumanMovement>();
     onCollisionListener = this;
 }