//void StartChaseTarget() //{ // if (currState == ObjectState.Dead) // return; // //yield return new WaitForSeconds(Random.Range(0, 3)); // if (IsCloseEnough(targetPosition, 0.1f)) // currState = ObjectState.Idle; // if (currState != ObjectState.Chasing) { // targetPosition = new Vector3(Random.Range(initialPosition.x - 0.5f, initialPosition.x + 0.5f), // initialPosition.y, // Random.Range(initialPosition.z - 0.5f, initialPosition.z + 0.5f)); // Debug.Log(targetPosition); // } // currState = ObjectState.Chasing; // Vector3 inputAxes = new Vector3(targetPosition.x, 0, targetPosition.y); // //anim.SetFloat(speedHash, inputAxes.magnitude); // Update the animator parameter for speed based on the joystick. // SetLookDirection(inputAxes); // Set the cat to look in the correct direction // // Move the cat, the animator will handle triggering the correct animations. // transform.localPosition += (transform.forward * inputAxes.magnitude * Time.deltaTime * speed); //} //void SetLookDirection(Vector3 inputAxes) //{ // // Get the camera's y rotation, then rotate inputAxes by the rotation to get up/down/left/right according to the camera // Quaternion yRotation = Quaternion.Euler(0, Camera.main.transform.rotation.eulerAngles.y, 0); // Vector3 lookDirection = (yRotation * inputAxes).normalized; // transform.rotation = Quaternion.LookRotation(lookDirection); //} public void GetHit(ARPet attacker, int damage) { //this.attacker = PlayerPetHandler.Instance.petControl; //TODO: battle logic in the future; Kill(); }
private float attackDelay; //Duration of the Attack on the Animal (before he can attack again) override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { animal = animator.GetComponent <ARPet>(); animal.isAttacking = true; //Set is Attacking to true so it cannot be interrupted the current attack animation isOn = isOff = false; //Reset the ON/OFF parameters (to be used on the Range of the animation attackDelay = animal.attackDelay; //Get the Attack Delay startAttackTime = Time.time; //Store the time when the Attack started }
public void BuildPet(PetData petData) { if (pet == null) { pet = Instantiate(petPrefab); petControl = pet.GetComponentInChildren <ARPet>(); petControl.petMaster = petMaster; petConstructor = pet.GetComponentInChildren <ARPetConstructor>(); SetPosition(); } petConstructor.UpdatePetGenes(petData); }