void Start() { spellOwned = new bool[spells.Length]; spellCount = new int[spells.Length]; spellButtons = new GameObject[spells.Length]; //rakenna loitsumenun valintanapit for (int i = 0; i < spells.Length; i++) { Spell spell = spells[i]; storedGestures.Add(GestureIO.ReadGestureFromXML(spell.gestureXml.text)); GameObject spellButtonObject = Instantiate(spellMenuButtonPrefab); spellButtons[i] = spellButtonObject; spellButtonObject.transform.SetParent(spellMenuButtons.transform, false); spellButtonObject.GetComponent <Image>().sprite = spell.icon; int index = i; //delegaatin muuttujan pitää olla samassa scopessa kuin delegaatti spellButtonObject.GetComponent <Button>().onClick.AddListener(delegate { StartSpellGestureDrawMode(index); }); } //lataa loitsujen tilanne tallennuksesta GameData.Spells spellData = GameDataManager.Instance.GameData.spells; GameData.Player playerData = GameDataManager.Instance.GameData.player; if (playerData.firstCheckPointReached) { Debug.Log("PlayerController - First Checkpoint Reached"); Debug.Log(spellData.count[0]); Array.Copy(spellData.owned, spellOwned, spells.Length); Array.Copy(spellData.count, spellCount, spells.Length); for (int i = 0; i < spells.Length; i++) { setSpellState(i, spellOwned[i], spellCount[i]); } } else { for (int i = 0; i < spells.Length; i++) { setSpellState(i, false, 0); } setSpellState(0, true, 1); //parannusloitsu on käytössä heti pelin alussa } EnableInput = true; //loitsumenu avataan tutoriaalin suorittamisen jälkeen SpellMenuEnabled = playerData.firstCheckPointReached; defaultDeltaTime = Time.fixedUnscaledDeltaTime; //Time.fixedDeltaTime; defaultMaximumDeltaTime = 1f; //Time.maximumDeltaTime; SetSpellMenuSlowDown(false); playerControls = GameObject.Find("Player").GetComponent <PlayerControls>(); }
// Use this for initialization void Start() { //haetaan kaikki tarvittavat komponentit rb = GetComponent <Rigidbody>(); healthSystem = GetComponent <HealthSystem>(); healthSystem.dieHandler = OnDie; keeper = GetComponent <PathKeeper>(); cameraTarget = GameObject.Find("CameraTarget"); movement = GetComponent <GroundMovement>(); movement.OnHitGround = OnHitGround; anim = transform.Find("PlayerModel").GetComponent <Animator>(); damageBlinker = GetComponent <MaterialBlinker>(); footStepHandler = transform.Find("PlayerModel").GetComponent <FootstepHandler>(); footStepHandler.FootStepHandler = Footstep; //animaatiot anim.SetFloat("RunBlend", 0f); animBaseLayer = anim.GetLayerIndex("BaseLayer"); animFallLayer = anim.GetLayerIndex("FallLayer"); animHurtLayer = anim.GetLayerIndex("HurtLayer"); animJumpLayer = anim.GetLayerIndex("JumpLayer"); animLandingLayer = anim.GetLayerIndex("LandingLayer"); anim.GetBehaviour <AttackLayerScript>().OnSlashEndHandler = OnSlashEnd; swordHitbox.SetActive(false); //lataa pelaajan tilanne tallennuksesta GameData.Player playerData = GameDataManager.Instance.GameData.player; if (playerData.firstCheckPointReached) { //paikka, suunta ja polku transform.position = playerData.position.toVector3(); transform.rotation = playerData.rotation.toQuaternion(); keeper.currentSpline = GameObject.Find(playerData.pathName).GetComponent <BezierSpline>(); //health healthSystem.currentHealth = playerData.currentHealth; healthSystem.maxHealth = playerData.maxHealth; } //siirrä kamera pelaajan paikalle cmDefaultCamera = GameObject.FindGameObjectWithTag("CMDefaultCamera"); mainCamera = GameObject.FindGameObjectWithTag("MainCamera"); if (cmDefaultCamera != null) { cmDefaultCamera.SetActive(false); mainCamera.SetActive(false); cmDefaultCamera.transform.position = transform.position; mainCamera.transform.position = transform.position; StartCoroutine(ActivateCameras()); } }