Example #1
0
        public void CheckState(PlayerMovementController mc)
        {
            // increment the update count.

            update_count_jump++;

            // enter default state if right criteria are met.

            if (mc.rigid_body.velocity.y <= 0)
            {
                mc.ChangePlayerState(PlayerState.player_default);
                return;
            }

            // enter default state if grounded.

            if (update_count_jump >= PlayerConstants.UPDATE_COUNT_JUMP_RECOVERY_MIN &&
                (mc.is_raycast_grounded || mc.is_spherecast_grounded))
            {
                mc.ChangePlayerState(PlayerState.player_default);
                return;
            }

            // enter dive state.

            if (mc.is_raised_interact)
            {
                mc.ChangePlayerState(PlayerState.player_dive);
                return;
            }
        }
Example #2
0
        public void BeginState(PlayerMovementController mc)
        {
            // reset the update count.

            update_count_jump = 0;

            // if coming from the water jump state,
            // don't add any additional force.

            if (mc.player_state_previous == PlayerState.player_water_jump)
            {
                return;
            }

            // enter jump state.
            // reset jump power.

            mc.jump_persist_energy = PlayerConstants.JUMP_PERSIST_ENERGY_MAX;

            // add jumping force.

            mc.rigid_body.velocity = new Vector3
                                         (mc.rigid_body.velocity.x, 0, mc.rigid_body.velocity.z);

            mc.rigid_body.AddForce(Vector3.up * PlayerConstants.JUMP_FORCE_MULTIPLIER, ForceMode.VelocityChange);

            // player sound.

            mc.audio_source.clip = mc.master.audio_controller.a_player_jump;
            mc.audio_source.Play();
        }
Example #3
0
 void Start()
 {
     // Might not work, interface might need to be a component
     inputActions = GetComponent <PlayerMovementController> ();
     scanner      = GetComponent <BattleInputScanner>();
     initMotionInputs();
 }
    private void Start()
    {
        movementController = GetComponent <PlayerMovementController>();
        weaponController   = GetComponentInChildren <PlayerWeaponController>();

        base.Init(new LoadingState(gameObject));
    }
 void Awake()
 {
     anim = GetComponent<Animator> ();
     movementController = GetComponent<PlayerMovementController> ();
     particles = transform.GetComponentInChildren<ParticleSystem> ();
     CurrentHealth = StartHealth;
 }
Example #6
0
    void Update()
    {
        Vector3 positionBeforeRotation = targetTransform.transform.position;

        int rotate = 0;

        //if (Input.GetKey(KeyCode.Q)) {
        //    rotate = -degreesRotation;
        //} else if (Input.GetKey(KeyCode.E)) {
        //    rotate = degreesRotation;
        //}

        targetTransform.transform.RotateAround(PlayerMovementController.GetPlayerPosition(), Vector3.up, rotate * Time.deltaTime);
        Vector3 deltaRotation = targetTransform.transform.position - positionBeforeRotation;

        rotationOffset = rotationOffset + deltaRotation;


        /* currentOffset is applied to position instead of rotation in FixedUpdate until Unity resolves its Japes */

        Vector3 offset = Input.GetKey(KeyCode.Space) ? FollowMouse() : Vector3.zero;

        currentOffset = Vector3.Lerp(currentOffset, player.transform.rotation * offset, moveSmoothing);

        /**/

        targetTransform.transform.position = PlayerMovementController.GetPlayerPosition() + positionOffset + rotationOffset + currentOffset;// + offset; // uncomment for fun times
        transform.position = Vector3.Lerp(transform.position, targetTransform.transform.position, turnSmoothing * Time.deltaTime);
    }
Example #7
0
    public IEnumerator rumble(PlayerMovementController p, float strength, float length)
    {
        p.player.SetVibration(p.playerId, strength);
        yield return(new WaitForSeconds(length));

        p.player.SetVibration(p.playerId, 0);
    }
Example #8
0
    private void Awake()
    {
        playerMovementController = GetComponent <PlayerMovementController>();
        shooting = GetComponent <Shooting>();

        if (photonView.IsMine)
        {
            playerControlsUIInstance = Instantiate(playerControlsUI);

            playerControlsUIInstance.transform.Find("Fire Button Right").GetComponent <Button>().onClick.AddListener(() => shooting.Fire());
            playerControlsUIInstance.transform.Find("Fire Button Left").GetComponent <Button>().onClick.AddListener(() => shooting.Fire());
            playerControlsUIInstance.transform.Find("Info").GetComponent <TextMeshProUGUI>().text = "Player Alive: " + PhotonNetwork.CurrentRoom.PlayerCount.ToString();

            playerMovementController.joystick        = playerControlsUIInstance.transform.Find("Fixed Joystick").GetComponent <Joystick>();
            playerMovementController.fixedTouchField = playerControlsUIInstance.transform.Find("Rotation Touch Field").GetComponent <FixedTouchField>();


            fpsCamera.enabled = true;
        }
        else
        {
            fpsCamera.enabled = false;
            playerMovementController.enabled = false;
            GetComponent <RigidbodyFirstPersonController>().enabled = false;
        }
    }
Example #9
0
    void Awake()
    {
        // Get Components
        controls = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerMovementController>();

        colorscript = GetComponentInParent <ColorScript>();
    }
    private void UpdatePosition()
    {
        Vector3 movementVec = CurrentMovementState.CalculateMovement(this);

        movementVec += CurrentJumpState.CalculateMovement(this);
        PlayerMovementController.Move(movementVec);
    }
Example #11
0
    // Use this for initialization
    void Start()
    {
        if (m_player == null)
        {
            m_player = GameObject.FindGameObjectWithTag("Player");
        }

        if (m_cam == null)
        {
            m_cam = Camera.main.gameObject;
        }

        if (m_gameManager == null)
        {
            m_gameManager = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameManager>();
        }

        m_boardRB     = GetComponent <Rigidbody>();
        m_playerRB    = m_player.GetComponent <Rigidbody>();
        m_playerState = m_player.GetComponent <PlayerStateInfo>();
        m_playerMover = m_player.GetComponent <PlayerMovementController>();

        m_boardMeshFilter = GetComponentInChildren <MeshFilter>();
        m_boardMesh       = m_boardMeshFilter.mesh;

        m_hoverSoundSource = m_hoverEffects.GetComponent <AudioSource>();
    }
 // Use this for initialization
 void Start()
 {
     state            = gameObject.GetComponent <PlayerStateManager>();
     pmc              = gameObject.GetComponent <PlayerMovementController>();
     nextShotTime     = 0;
     nextUppercutTime = 0;
 }
    void Awake()
    {
        animator           = this.gameObject.GetComponent <Animator>();
        movementController = this.gameObject.GetComponent <PlayerMovementController>();

        GameController.getInstance().suscribeToGame(this);
    }
Example #14
0
 public CombatState(PlayerMovementController controller, PlayerCombatController combatController, float time)
 {
     _controller       = controller;
     _combatController = combatController;
     _timeToExitState  = time;
     _exitWhenFinished = true;
 }
Example #15
0
    public override void Awake()
    {
        base.Awake();
        playerMovementController = gameObject.GetComponentInParent <PlayerMovementController>();
        playerController         = GetComponent <PlayerController>();

        alignment = AlignmentType.Player;

        GameObject   gameManager  = GameObject.FindGameObjectWithTag("GameController");
        PrafabHolder prafabHolder = gameManager.GetComponent <PrafabHolder>();

        GameObject MageFireBall = prafabHolder.GetSkill("MageFireBall");

        AddSkill(MageFireBall);

        //GameObject BlizardSkill = prafabHolder.GetSkill("Blizard");
        //AddSkill(BlizardSkill);

        //GameObject FireSpraySkill = prafabHolder.GetSkill("FireSpray");
        //AddSkill(FireSpraySkill);

        //GameObject LightningStrick = prafabHolder.GetSkill("LightningStrick");
        //AddSkill(LightningStrick);

        //GameObject AttackSpeedUp = prafabHolder.GetSkill("AttackSpeedUp");
        //AddSkill(AttackSpeedUp);

        //GameObject AttackSpeedBuff1 = Instantiate(prafabHolder.GetBuff("attackSpeed"));
        //AddBuff(AttackSpeedBuff1, GetComponent<Role>());
        //GameObject AttackSpeedBuff2 = Instantiate(prafabHolder.GetBuff("attackSpeed"));
        //AddBuff(AttackSpeedBuff2, GetComponent<Role>());
    }
Example #16
0
        public override void Init()
        {
            movementController    = GetComponent <PlayerMovementController>();
            actionController      = GetComponent <PlayerActionController>();
            rotationController    = GetComponent <PlayerRotationController>();
            animationController   = GetComponent <PlayerAnimationController>();
            inventoryController   = GetComponent <PlayerInventoryController>();
            weaponController      = GetComponent <PlayerWeaponController>();
            healthController      = GetComponent <HealthController>();
            reloadController      = GetComponent <PlayerReloadController>();
            interactionController = GetComponent <InteractionSearcherController>();
            executionController   = GetComponent <PlayerExecutionController>();
            limbsController       = GetComponentInChildren <LimbsController>();
            hitboxController      = GetComponentInChildren <HitboxController>();
            abilityController     = GetComponent <AbilityController>();

            tickPlayer.value = true;

            movementController.Init();
            actionController.Init();
            rotationController.Init();
            animationController.Init();
            weaponController.Init();
            inventoryController.Init();
            healthController.Init();
            reloadController.Init();
            interactionController.Init();
            executionController.Init();
            limbsController.Init();
            hitboxController.Init();
            abilityController.Init();
        }
Example #17
0
 public void UpdateState(PlayerMovementController mc)
 {
     UpdateStateMovement(mc);
     UpdateStateLateralMovement(mc);
     UpdateStateSlide(mc);
     UpdateStateSpeed(mc);
 }
 void Awake()
 {
     playerController              = GetComponent <PlayerController>();
     moveController                = GetComponent <PlayerMovementController>();
     reticleSpriteRenderer         = aimReticle.GetComponentInChildren <SpriteRenderer>();
     reticleSpriteRenderer.enabled = false;
 }
Example #19
0
        public void CheckState(PlayerMovementController mc)
        {
            update_count_slide++;

            // exit if entering water.
            if (mc.is_partial_submerged)
            {
                mc.ChangePlayerState(PlayerEnums.PlayerState.player_water_default);
                return;
            }

            // exit if slide resistance recovered.
            if (mc.slide_resistance >= SLIDE_RESISTANCE_MAX)
            {
                mc.ChangePlayerState(PlayerEnums.PlayerState.player_default);
                return;
            }

            // exit if fully in air.
            if (!mc.is_spherecast_grounded && !mc.is_raycast_grounded)
            {
                mc.ChangePlayerState(PlayerEnums.PlayerState.player_default);
                return;
            }

            // exit if slow enough to jump.
            if (mc.is_raised_positive &&
                mc.is_spherecast_grounded &&
                mc.rigid_body.velocity.magnitude < SLIDE_SPEED_RECOVERY_MAX)
            {
                mc.ChangePlayerState(PlayerEnums.PlayerState.player_jump);
                return;
            }
        }
Example #20
0
 public void UpdateStateSpeed(PlayerMovementController mc)
 {
     if (mc.rigid_body.velocity.magnitude > MAX_SPEED_SLIDE)
     {
         mc.rigid_body.velocity = Vector3.ClampMagnitude(mc.rigid_body.velocity, MAX_SPEED_GROUNDED);
     }
 }
Example #21
0
    void LevelLoaded(Scene scene, LoadSceneMode bop)
    {
//		Debug.Log(scene.name);
        if (scene.name == "_FINAL_menu")
        {
            //if (GameMaster.me.managers.transform.childCount == 8) {
            //GameMaster.me.managers.transform.GetChild(7).transform.parent = null;
            //}
            //Destroy(GameMaster.me.managers);
        }
        else
        {
            BulletManager.me.spawnList.Clear();
            GameMaster.me.findUI();
            GameMaster.me.updateUI();
            GameMaster.me.findSpawnPoints();
            player1         = GameMaster.me.player1;
            player2         = GameMaster.me.player2;
            scanlines       = Camera.main.GetComponent <ScanlinesEffect>();
            globalTimescale = 1f;

            GameMaster.me.StartCoroutine(GameMaster.me.Countdown(3));
//			Debug.Log(music);

            if (!musicMix)
            {
                musicMix = music.outputAudioMixerGroup.audioMixer;
            }
        }
//		Debug.Log(musicMix);
    }
Example #22
0
 internal SnakeCell(PlayerMovementController playerMovementController, GridCell pos)
 {
     this.pos   = pos;
     gameObject = Instantiate(playerMovementController.playerController.snakeCellPrefab);
     gameObject.transform.parent = playerMovementController.playerController.transform;
     playerMovementController.playerController.gridController.placeInCell(gameObject, pos);
 }
Example #23
0
 // Start is called before the first frame update
 void Start()
 {
     playerMovementController = GetComponent <PlayerMovementController>();
     playerBehaviour          = GetComponent <PlayerBehaviour>();
     rb         = GetComponent <Rigidbody2D>();
     dashedTime = startDashedTime;
 }
Example #24
0
    private void Start()
    {
        _collider = GetComponent <Collider>();
        _playerMovementController = GetComponent <PlayerMovementController>();

        transform.position = PlayerSpawningController.GetSpawningPoint(GetComponent <PlayerMovementController>().PlayerId);
    }
Example #25
0
 private void Awake()
 {
     ballController      = GetComponent <PlayerBallController>();
     collisionController = GetComponent <PlayerCollisionController>();
     movementController  = GetComponent <PlayerMovementController>();
     healthController    = GetComponent <PlayerHealthController>();
 }
    public PlayerMovementState(GameObject player) : base(player)
    {
        stateName = PlayerStates.PlayerControl;

        movementController = player.GetComponent <PlayerMovementController>();
        weaponController   = player.GetComponentInChildren <PlayerWeaponController>();
    }
Example #27
0
 public void TakeAction(PlayerMovementController movementController, Inventory inventory)
 {
     // Check for key
     if (doorKey > KeyType.UNLOCKED)
     {
         Debug.Log("Door is locked! Key type: " + doorKey);
         if (inventory.HasKey(doorKey))
         {
             // Unlock the door, change the door state
             // TODO:  Play an unlock sfx
             doorKey = KeyType.UNLOCKED;
             SetOpenState(!isOpen);
         }
         else
         {
             Debug.Log("No key!  Attempting to display message");
             DialogueTrigger dialogue = gameObject.GetComponent <DialogueTrigger>();
             dialogue.TriggerDialogue(movementController);
         }
     }
     else
     {
         // No lock, change the door state
         SetOpenState(!isOpen);
     }
 }
Example #28
0
 // Use this for initialization
 void Start()
 {
     //sprite = GetComponentInChildren<SpriteRenderer> ();
     defaultColor = sprite.color;
     player       = GetComponent <PlayerMovementController>();
     //player = sprite.gameObject.GetComponent<PlayerMovementController>();
 }
Example #29
0
    void OnCollisionStay2D(Collision2D coll)
    {
        if (coll.gameObject.tag == "Player")
        {
            PlayerMovementController player = coll.gameObject.GetComponent <PlayerMovementController> ();
//			Debug.Log(decayed);
            if (!player.invuln)
            {
                //			player.health -= dmg;
                if (player.health == 1)
                {
                    SoundController.me.PlaySoundAtNormalPitch(lastHit, 1f);
                }
                else
                {
                    SoundController.me.PlaySoundAtNormalPitch(playerHit, 1f, transform.position.x);
                    //Debug.Log("???");
                }
                player.respawn();
                GameMaster.me.addColorDrift();
                GameObject flash = Instantiate(DamageFlash, transform.position, Quaternion.identity);
                Camera.main.GetComponent <Screenshake>().SetScreenshake(0.35f, .25f, player);
                Destroy(this.gameObject);
                Destroy(flash, .020f);
            }
            else
            {
                if (coll.contacts.Length > 0)
                {
                    vel = Geo.ReflectVect(prevVel.normalized, coll.contacts [0].normal) * (prevVel.magnitude * 0.65f);
                }
            }
        }
    }
        public void CheckState(PlayerMovementController mc)
        {
            update_count_water_default++;

            // exit to water dive if pressing interact.

            if (mc.is_raised_interact)
            {
                mc.ChangePlayerState(PlayerEnums.PlayerState.player_water_dive);
                return;
            }

            // exit to water jump if pressing jump
            // and grounded, or descending in water.

            if
            (
                mc.is_raised_positive &&
                (mc.is_spherecast_grounded || mc.rigid_body.velocity.y <= MINIMUM_WATER_JUMP_Y_SPEED)
            )
            {
                mc.ChangePlayerState(PlayerEnums.PlayerState.player_water_jump);
                return;
            }

            if (!mc.is_partial_submerged)
            {
                mc.ChangePlayerState(PlayerEnums.PlayerState.player_default);
                return;
            }
        }
Example #31
0
 public void UpdateStateSpeed(PlayerMovementController mc)
 {
     if (mc.rigid_body.velocity.magnitude > MAX_SPEED_WATER)
     {
         mc.rigid_body.velocity = mc.rigid_body.velocity.normalized * MAX_SPEED_WATER;
     }
 }
    void Start()
    {
        anim = GetComponent<Animator>();
        playerController = GetComponent<PlayerMovementController>();
        characterStats = GetComponent<CharacterStats>();
        colliderr = GetComponent<CapsuleCollider>();

        characterControlInterface = GetComponent<CharacterControlInterface>();
    }
    void OnObjectLeft( FieldObject obj )
    {
        if( obj.collider.tag == "Player" )
        {
            controllerScript = obj.collider.GetComponent<PlayerMovementController>();

            if( null == controllerScript )
            {
                Debug.LogError( "Could not find 'PlayerMovementController' component attached to object tagged 'Player'" );
                return;
            }

            controllerScript.localAxesLocked = false;
        }
    }
    protected void Awake()
    {
        _suspicionMultiplier = new TweakableFloat("AnimalSuspicionMultiplier", 0.0f, 1.0f, 0.5f);
        _animator = GetComponent<Animator>();

        GameObject[] players = GameObject.FindGameObjectsWithTag("Player");
        if (players.Length != 1) {
            Debug.LogError("Weird number of players found: " + players.Length);
        }
        _player = players[0].GetComponent<PlayerMovementController>();

        IndicatorView[] indicatorViews = transform.GetComponentsInChildren<IndicatorView>();
        if (indicatorViews.Length != 1) {
            Debug.LogError("Weird number of indicator views found: " + indicatorViews.Length);
        }
        _indicatorView = indicatorViews[0];
        (transform.Find("Indicator").gameObject as GameObject).SetActive(false);

        SetUpStateMachine();
    }
 void Awake()
 {
     player = GetComponent<PlayerMovementController>();
 }
Example #36
0
    void Start()
    {
        rbody = GetComponent<Rigidbody2D> ();
        mcon = GetComponent <PlayerMovementController> ();
        if (asrc == null) {
            asrc = GetComponent <AudioSource> ();
        }

        textBox = GameObject.FindGameObjectsWithTag ("TextBox") [0];
        textBox_text = GameObject.FindGameObjectsWithTag ("TextBox_Text") [0];

        textBox.SetActive (false);

        actionPressed = false;
        shouldClose = false;
    }
    void Start()
    {
        // Initalize required components
        animator = GetComponent<Animator>();
        movementController = GetComponent<PlayerMovementController>();

        //initalize the needed scripts script
        wpnManager = GetComponent <WeaponManager>();
        playerHealth = GetComponent <PlayerHealthbarController>();

        chargedRing.fillAmount = 0f;
    }
Example #38
0
 /// <summary>
 /// Processing performed by Unity when an instance is created.
 /// Initializes some attributes.
 /// </summary>
 void Start()
 {
     animator = GetComponent<Animator> ();
     animator.SetInteger ("AnimState", 1);
     controller = GetComponent<PlayerMovementController>();
     controller.onPlayerDirectionChanging += OnDirectionChange;
     controller.playerAssociated = this;
     setAnimation (controller.CurrentDirection.animationCode);
 }
 void Awake()
 {
     _moveControl = GetComponent<PlayerMovementController>();
 }