void Start() { _controller3D = transform.GetComponent <PlayerController3D>(); _controller2D = transform.GetComponent <PlayerController2D>(); _characterController = transform.GetComponent <CharacterController>(); Enable3D(); }
public void StartGame(string name) { var obj = GameObject.FindGameObjectWithTag("Player"); if (obj != null) { player = obj.GetComponent <PlayerController3D>(); } else { /* * float posX = 0; * float posZ = 0; * * if (PlayerPrefs.HasKey("PlayerX") && PlayerPrefs.HasKey("PlayerZ")) * { * posX = PlayerPrefs.GetFloat("PlayerX"); * posZ = PlayerPrefs.GetFloat("PlayerZ"); * } */ PlayerData data = SaveSystem.LoadGame(name); obj = Instantiate(PlayerPrefab, new Vector3(0, 0, -20), Quaternion.identity); player = obj.GetComponent <PlayerController3D>(); player.stats.Level = data.Level; player.stats.Name = data.Name; player.stats.Experience = data.Experience; player.stats.health = data.Health; player.SetPosition(new Vector3(data.posX, 0, data.posZ)); } }
// Start is called before the first frame update void Start() { playerController = player.GetComponent <PlayerController3D>(); maxHP = playerController.GetMaxHP(); prevHP = (int)Mathf.Round((float)playerController.GetHP() / maxHP * 10); Debug.Log("Init PrevHP: " + prevHP); }
public bool HandleRaycast(PlayerController3D controller) { if (Input.GetMouseButton(0)) { Pickup(controller.GetComponent <Fighter>()); } return(true); }
public bool HandleRaycast(PlayerController3D controller) { if (Input.GetMouseButtonDown(0)) { ToggleCombatMarker(true); controller.GetComponent <Fighter>().SetTarget(transform.GetComponent <Health>()); } return(true); }
public PlayerData(PlayerController3D controller) { posX = controller.transform.position.x; posY = controller.transform.position.y; posZ = controller.transform.position.z; Name = controller.stats.Name; Level = controller.stats.Level; Experience = controller.stats.Experience; Health = controller.stats.health; }
private void Awake() { if (pController3D == null) { pController3D = this; } else { return; } GetPlayer(); }
public static void SaveGame(PlayerController3D player) { #if UNITY_EDITOR string path = Application.streamingAssetsPath + "/" + player.stats.Name + ".save"; #elif UNITY_ANDROID string path = Application.persistentDataPath + "/" + player.stats.name + ".save"; #endif PlayerData data = new PlayerData(player); BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Create); formatter.Serialize(stream, data); stream.Close(); }
private void Start() { //for hostile penguins, a random insult will be extracted from the insults array if (CompareTag("Enemy")) { insultPlate.SetActive(false); insultText.text = RandomInsultText(); } //initial state _activeState = State.WANDER; //required parameters for the WANDER states //these all start as false and are gradually activated _isWalking = false; _isWandering = false; _isRotLeft = false; _isRotRight = false; _isWandering = false; _target = FindObjectOfType <PlayerController3D>(); }
public void ResetTarget() { target = null; }
public void SetTarget(PlayerController3D t) { target = t; }
void Awake() { instance = this; Subscribe(); }
void Awake() { playerController3D = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController3D>(); }