Beispiel #1
0
    public float Compare(PotController target)
    {
        float score = 0.0f;
        //鍋子液體 70%
        //狀態 1 2 3 各10%
        //比較顏色 R G B
        Vector3 potColorV      = new Vector3(potImg.color.r, potImg.color.g, potImg.color.b);
        Vector3 topicPotColorV = new Vector3(target.color.r, target.color.g, target.color.b);

        float dis         = Mathf.Clamp(Vector3.Distance(potColorV, topicPotColorV), 0, 1);
        float potScore    = 1 - dis;
        float statusScore = 0.0f;

        for (int i = 0; i < _effectNum; i++)
        {
            // TODO: a bug
            if (target._childImg [i].sprite != null && target._childImg [i].sprite.name == _childImg [i].sprite.name)
            {
                statusScore += 1.0f;
            }
        }
        if (statusScore != 0)
        {
            statusScore = statusScore / (float)_effectNum;
        }
        score = potScore * 0.7f + statusScore * 0.3f;

        return(score);
    }
Beispiel #2
0
 // Start is called before the first frame update
 void Start()
 {
     vc = GameObject.Find("Player").GetComponent <VoiceController>();
     pc = GameObject.Find("pot").GetComponent <PotController>();
     gc = GameObject.Find("FireGuide").GetComponent <GudieController>();
     cong.SetActive(false);
     btn1.SetActive(false);
 }
Beispiel #3
0
    void Start()
    {
        mMapController = GameObject.Find("Canvas/MiniMap").GetComponent <MiniMapController>();
        sController    = GameObject.Find("Controller").GetComponent <StageController>();
        mMapController.NowMap();
        pot_ctr = FindObjectOfType <PotController>();

        AttributePot(transform.root.GetComponent <MapInfo>().attribute);
    }
Beispiel #4
0
    protected override void OnSceneLoad()
    {
        base.OnSceneLoad();

        if (!Pot)
        {
            Pot = FindObjectOfType <PotController>();
        }
    }
    public void OnBlackScore(PotController.BlackBlame blackBlame)
    {
        if (scoreA == maxScore && scoreB < maxScore) {
            scoreA++;
            winA = true;
        } else if (scoreA < maxScore && scoreB == maxScore) {
            scoreB++;
            winB = true;
        } else if (scoreA == maxScore && scoreB == maxScore) {
            //
            if (blackBlame.blame == BlackBallController.CollisionBlame.CUE_A) {
                scoreA++;
                winA = true;
            } else if (blackBlame.blame == BlackBallController.CollisionBlame.CUE_B) {
                scoreB++;
                winB = true;
            } else {
                // uderzyło coś poza bilami, a tylko bile zostały - przypadek niemożliwy
                Debug.LogError ("Impossible case");
            }
        } else {
            //nikt jeszcze nie skończył
            if (blackBlame.blame == BlackBallController.CollisionBlame.CUE_A) {
                //gracz A wbił zespośrednio, kara dla niego
                winB = true;
            } else if (blackBlame.blame == BlackBallController.CollisionBlame.CUE_B) {
                //gracz B wbił bezpośrednio, kara dla niego
                winA = true;
            }
        }

        if (winA || winB) {
            Destroy (blackBlame.ball);
        } else {
            blackBlame.ball.GetComponent<BlackBallController> ().resetBall ();
        }

        renderScore ();
        Debug.Log ("black score, blame: " + blackBlame.blame);
    }
Beispiel #6
0
    void Update()
    {
        // Calls a function to update the UI Text.
        TextUpdate();

        // Calls a function to shoot the raycast.
        RayShoot();

        // Calls a function to manage the recipe book.
        RecipeBookManager();

        // Checks if you press the interact key and that you are looking at an object.
        if (Input.GetKeyDown(KeyCode.E) && collision != null)
        {
            // Checks if you are holding an item and if you are drops it.
            if (holding)
            {
                holding = !holding;
            }
            // Checks if the object you are looking at is a PickUp and if it is picks it up.
            else if (collision.tag == "PickUp")
            {
                pickUp  = collision;
                holding = !holding;
                collision.GetComponent <Rigidbody>().velocity = Vector3.zero;
            }
            // Checks if the object you are looking at is a Crate and if it is takes an item from it.
            else if (collision.tag == "Crate")
            {
                pickUp      = Instantiate(collision.GetComponent <CrateObject>().crateObject);
                pickUp.name = pickUp.name.Replace("(Clone)", "");
                holding     = !holding;
            }
            // Checks if the object you are looking at is a Pot and if so takes the meal in its current state from it.
            else if (collision.tag == "Pot")
            {
                PotController controller = collision.GetComponent <PotController>();

                int index = controller.currentRecipe.meal;
                int state = Mathf.FloorToInt(controller.GetCookingTime());

                mealPrefab = meals[index - recipeBook.foodCount];

                pickUp = Instantiate(mealPrefab);
                pickUp.GetComponent <MealBehaviour>().SetMealBehaviour(index, state);
                holding = !holding;

                controller.Clear();
            }
        }
        // Checks if the current key down is Escape and if so returns to menu.
        else if (Input.GetKeyDown(KeyCode.Escape))
        {
            SceneManager.LoadScene(0);
        }

        // Checks if you are holding and object and if so moves the object infront of the player.
        if (holding)
        {
            pickUp.GetComponent <Transform>().position = transform.position + (transform.forward * 5);
        }
        // Otherwise clears the pickUp variable.
        else
        {
            pickUp = null;
        }
    }
Beispiel #7
0
    // Function to handle updating the UI Text.
    private void TextUpdate()
    {
        // Checks if holding an item and if so defaults to showing drop message.
        if (holding)
        {
            text.text = "Press \"E\" to Drop " + pickUp.name;
        }
        else
        {
            // Checks if there is an object being looked at and that it has a tag.
            if (collision != null && collision.tag != "Untagged")
            {
                // Checks through each of the available tags:
                switch (collision.tag)
                {
                // Checks if the tag is PickUp if so shows pickup message.
                case ("PickUp"):
                    if (!holding)
                    {
                        text.text = "Press \"E\" to Pickup " + collision.name;
                    }
                    break;

                // Checks if the tag is Crate if so shows dispense message.
                case ("Crate"):
                    text.text = "Press \"E\" to Dispense " + collision.GetComponent <CrateObject>().crateFood.name;
                    break;

                // Checks if the tag is Pot is so shows a message depending on the state of the pot.
                case ("Pot"):
                    PotController controller = collision.GetComponent <PotController>();
                    // Checks if the pot is currently cooking if so it shows the collect message with meal name and current state.
                    if (controller.Cooking)
                    {
                        string message = "Press \"E\" to Collect ";

                        if (controller.GetCookingTime() <= 1)
                        {
                            message += recipeBook.foodItems[controller.currentRecipe.meal].name + " (Under Cooked)";
                        }
                        else if (controller.GetCookingTime() <= 2)
                        {
                            message += recipeBook.foodItems[controller.currentRecipe.meal].name + " (Cooked)";
                        }
                        else if (controller.GetCookingTime() <= 3)
                        {
                            message += recipeBook.foodItems[controller.currentRecipe.meal].name + " (Over Cooked)";
                        }
                        else
                        {
                            message += "Burnt Food";
                        }

                        text.text = message;
                    }
                    // Otherwise shows the no recipe messsage.
                    else
                    {
                        text.text = "No Recipe Matched! Add Ingredients.";
                    }
                    break;

                // Checks if the tag is ServingTable and shows the table message.
                case ("ServingTable"):
                    text.text = "Drop Item onto Serving Table to Serve.";
                    break;
                }
                // Show the text object.
                textObject.SetActive(true);
            }
            // Hides the text object.
            else
            {
                textObject.SetActive(false);
            }
        }
    }