public ProfileModel(ProfilsID _id, Device _device, Key _up, Key _down, Key _left, Key _right, Key _attack, Key _skill1, Key _skill2, Key _skill3, Key _skill4, Key _interaction, Key _changeTorch, Key _submit, Key _pause, Key _cameraRight, Key _cameraLeft) { id = _id; device = _device; up = _up; down = _down; left = _left; right = _right; attack = _attack; skill1 = _skill1; skill2 = _skill2; skill3 = _skill3; skill4 = _skill4; interaction = _interaction; changeTorch = _changeTorch; submit = _submit; pause = _pause; cameraRight = _cameraRight; cameraLeft = _cameraLeft; // Reference keys with their actions keys.Add(PlayerAction.Up, up); keys.Add(PlayerAction.Down, down); keys.Add(PlayerAction.Left, left); keys.Add(PlayerAction.Right, right); keys.Add(PlayerAction.Attack, attack); keys.Add(PlayerAction.Skill1, skill1); keys.Add(PlayerAction.Skill2, skill2); keys.Add(PlayerAction.Skill3, skill3); keys.Add(PlayerAction.Skill4, skill4); keys.Add(PlayerAction.Interaction, interaction); keys.Add(PlayerAction.ChangeTorch, changeTorch); keys.Add(PlayerAction.Submit, submit); keys.Add(PlayerAction.Pause, pause); keys.Add(PlayerAction.CameraLeft, cameraLeft); keys.Add(PlayerAction.CameraRight, cameraRight); }
void Start() { GUI = GameObject.FindGameObjectWithTag("GameUI"); interaction = GUI.GetComponent <Interaction>(); inventory = GUI.GetComponent <Inventory>(); interactable = false; inventoryActive = false; GeneralData.gamePaused = false; // get the last digit of the player name (1 / 2) playerNum = this.transform.name[this.transform.name.Length - 1]; playerNum -= 48; // Set Input system if (playerNum == 1) { input = GeneralData.inputPlayer1; } else if (playerNum == 2) { input = GeneralData.inputPlayer2; } // Load the previous position float[] pos = GeneralData.getPlayerbyNum(playerNum).pos; this.transform.position = new Vector3(pos[0], pos[1], pos[2]); if (PlayerPrefs.GetInt("Input" + playerNum) == -1) { profile = new Profile(playerNum, 0); } else { profile = new Profile(playerNum, PlayerPrefs.GetInt("Input" + playerNum)); } GeneralData.setProfile(playerNum, profile); Light light = GetComponentInChildren <Light>(); cam = GameObject.Find("Main Camera").GetComponent <CameraController>(); spirit = GameObject.FindGameObjectWithTag("Spirit").GetComponent <SpiritController>(); // set skills form DB setSkills(); attack = GetComponent <SkillManager>().getSkill(SkillsID.HeroAttack); reflect = GetComponent <SkillManager>().getSkill(SkillsID.Reflect); animator = GetComponent <Animator>(); movementManager = GetComponent <MovementManager>(); lastMove = Vector3.zero; if (GeneralData.multiplayer) { multiplayer = true; if (playerNum == 1) { secondPlayer.SetActive(true); secondPlayerExperience.SetActive(true); } else if (playerNum == 2) { //secondPlayer = GameObject.Find(this.transform.name.Substring(0, transform.name.Length-1)+"1"); } } audioSource = GetComponent <AudioSource>(); audioSource.volume = PlayerPrefs.GetFloat("SFXVolume"); lastMove = Vector3.zero; // Added by Sidney (set hurt and death reactions) var health = GetComponent <HealthManager>(); health.setHurtCallback(() => { animator.SetTrigger("hurt"); if (hurtSound != null) { audioSource.PlayOneShot(hurtSound); } }); health.setDeathCallback(() => { // Play death animation animator.SetTrigger("death"); // Play death sound if (deathSound != null) { audioSource.PlayOneShot(deathSound); } // End the game //Time.timeScale = 0; Cursor.visible = true; Cursor.lockState = CursorLockMode.None; UnityEngine.SceneManagement.SceneManager.LoadScene("GameOver"); Time.timeScale = 1f; }); }