コード例 #1
0
    public void OnClickHome()
    {
        // Save toyx if toyxmanager exists
        GameObject toyxManagerGameObject = GameObject.Find("ToyxManager");

        if (toyxManagerGameObject != null)
        {
            ToyxManager toyxManager = toyxManagerGameObject.GetComponent <ToyxManager>();
            toyxManager.Save(null);
        }

        // Hide content pane
        contentPanel.SetActive(false);

        // Show spinner
        loadingBackground.SetActive(true);

        // Load level
        StartCoroutine(LoadGame("menu"));
    }
コード例 #2
0
    void Update()
    {
        //don't move if we are dead
        if (health <= 0.0f)
        {
            return;
        }


                #if UNITY_ANDROID
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            //save before quit
            if (toyxManager != null)
            {
                toyxManager.Save(null);
            }
            Application.LoadLevel("menu");
        }
                #endif
    }
コード例 #3
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        ToyxManager toyxManager = (ToyxManager)target;

        // Create session button
        if (GUILayout.Button("Create Session"))
        {
            toyxManager.CreateSession(null);
        }

        // Fetch if needed button
        if (GUILayout.Button("Fetch If Needed"))
        {
            toyxManager.FetchIfNeeded(null);
        }

        // Fetch button
        if (GUILayout.Button("Fetch"))
        {
            toyxManager.Fetch(null);
        }

        // Save button
        if (GUILayout.Button("Save"))
        {
            toyxManager.Save(null);
        }

        // SaveEventually button
        if (GUILayout.Button("Save Eventually"))
        {
            toyxManager.SaveEventually();
        }

        // Show Console button
        if (showConsole)
        {
            if (GUILayout.Button("Hide Console"))
            {
                showConsole = false;
            }
        }
        else
        {
            if (GUILayout.Button("Show Console"))
            {
                showConsole = true;
            }
        }

        // Clear console
        if (GUILayout.Button("Clear Console"))
        {
            toyxManager.infoMessage = "";
        }

        // Console
        if (showConsole && toyxManager.infoMessage != null)
        {
            GUILayout.Label(toyxManager.infoMessage);
        }
    }
コード例 #4
0
    void Update()
    {
        ApplyGravity();

        //don't move if we are animating the Appear animation
        AnimatorStateInfo currentStateInfo = animator.GetCurrentAnimatorStateInfo(0);

        if (currentStateInfo.IsName("Appear"))
        {
            return;
        }

        //also don't move if we are dead
        if (health <= 0.0f)
        {
            return;
        }

        //regenerate health
        health += Time.deltaTime * healthRegenerationRate;
        health  = Mathf.Min(health, maxHealth);

        UpdateSmoothedMovementDirection();


        // Calculate actual motion
        Vector3 movement = moveDirection * moveSpeed + new Vector3(0, verticalSpeed, 0);

        movement *= Time.deltaTime;

        // Move the controller
        CharacterController controller = GetComponent <CharacterController>();

        collisionFlags = controller.Move(movement);

        // ANIMATION sector
        if (animator != null)
        {
            if (isMoving)
            {
                //avisar al animador
                animator.SetFloat("speed", 1.0f);
            }
            else
            {
                animator.SetFloat("speed", 0.0f);
            }
        }
        // ANIMATION sector

        // Set rotation to the move direction
        if (IsGrounded())
        {
            transform.rotation = Quaternion.LookRotation(moveDirection);
        }
        else
        {
            Vector3 xzMove = movement;
            xzMove.y = 0;
            if (xzMove.sqrMagnitude > 0.001f)
            {
                transform.rotation = Quaternion.LookRotation(xzMove);
            }
        }

        //update life every frame because it changes constantly
        hud.SetLife((float)health / (float)maxHealth);


        if (AppearAudioSource.enabled && !AmbientAudioSource.enabled)
        {
            //when we start moving, enable ambient sound
            AmbientAudioSource.enabled = true;
        }

                #if UNITY_ANDROID
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            //save before quit
            if (toyxManager != null)
            {
                toyxManager.Save(null);
            }
            Application.LoadLevel("menu");
        }
                #endif
    }