コード例 #1
0
    private void Update()
    {
        if (m_EggTimer >= 15 && m_CurrentEggState == EggState.RawEgg)
        {
            m_CurrentEggState = EggState.FriedEgg;

            m_MachineLearningManager.m_IsFriedEgg              = true;
            m_MachineLearningManager.m_GameState.m_GamePoints += m_MachineLearningManager.m_IsFriedEggPoints;

            m_CookingAgent.AddReward(m_MachineLearningManager.m_IsFriedEggPoints);
        }
        else if (m_EggTimer >= 20 && m_CurrentEggState == EggState.FriedEgg)
        {
            m_CurrentEggState = EggState.Burnt;

            m_MachineLearningManager.m_IsEggBurnt              = true;
            m_MachineLearningManager.m_GameState.m_GamePoints += m_MachineLearningManager.m_IsBurntPoints;

            m_CookingAgent.AddReward(m_MachineLearningManager.m_IsBurntPoints);

            m_MachineLearningManager.m_GameState.m_IsGameOver = true;
            Debug.Log("End");
            m_CookingAgent.EndEpisode();
        }

        if (m_CurrentEggState == EggState.Burnt)
        {
            m_GameStateUI.text = "You Lose.";
        }
    }
コード例 #2
0
 public void ResetEgg()
 {
     m_EggTimer                   = 0;
     m_CurrentEggState            = EggState.RawEgg;
     this.transform.parent        = m_ParentObject;
     this.transform.localPosition = m_OriginalPositionInKitchen;
 }
コード例 #3
0
        private void SyncState(EggState oldState, EggState newState)
        {
            EnsureInit();
            currentState = newState;

            switch (currentState)
            {
            case EggState.Growing:
                spriteHandler.SetSprite(spriteHandler.Sprites[SMALL_SPRITE]);
                break;

            case EggState.Grown:
                spriteHandler.SetSprite(spriteHandler.Sprites[BIG_SPRITE]);
                break;

            case EggState.Burst:
                StopAllCoroutines();
                StartCoroutine(OpenEgg());
                break;

            case EggState.Squished:
                spriteHandler.SetSprite(spriteHandler.Sprites[SQUISHED_SPRITE]);
                break;
            }
        }
コード例 #4
0
    void ThrowEgg()
    {
        float randomTime = Random.Range(randomRangeMin, randomRangeMax);

        //generate IndexNumbers
        int indexGO     = Random.Range(0, cannonBullets);
        int indexForce  = Random.Range(0, ForceindexRange);
        int indexTorque = Random.Range(0, ForceindexRange);

        //Debug.Log(indexGO);

        //Instantiate Go and call index
        Eggprefab = Instantiate(EggPrefabs[indexGO], transform.position, transform.rotation);
        Eggprefab.GetComponent <Rigidbody>().AddForce(ForceVector[indexForce]);
        Eggprefab.GetComponent <Rigidbody>().AddTorque(TorqueVector[indexTorque]);

        Invoke("ThrowEgg", randomTime);



        //float t = Time.time - startTime;
        //rb.velocity = direction * speed + orthogonal * amplitude * Mathf.Sin (frequency * t);
        //rb.AddForce(new Vector3(forceX,forceY,0));
        //rb.velocity = Vector3.zero;
        //rb.angularVelocity = Vector3.zero;
        //rb.useGravity = true;
    }
コード例 #5
0
        private void UpdatePhase(EggState state)
        {
            currentState = state;

            switch (currentState)
            {
            case EggState.Growing:
                spriteHandler.ChangeSprite(SMALL_SPRITE);
                StopAllCoroutines();
                StartCoroutine(GrowEgg());
                break;

            case EggState.Grown:
                spriteHandler.ChangeSprite(BIG_SPRITE);
                StopAllCoroutines();
                StartCoroutine(HatchEgg());
                break;

            case EggState.Burst:
                spriteHandler.ChangeSprite(HATCHED_SPRITE);
                registerObject.Passable = true;
                break;

            case EggState.Squished:
                spriteHandler.ChangeSprite(SQUISHED_SPRITE);
                break;
            }

            UpdateExamineMessage();
        }
コード例 #6
0
        private void UpdateState(EggState state)
        {
            if (state == currentState)
            {
                UpdateExamineMessage();
                return;
            }

            currentState = state;
            UpdateExamineMessage();
        }
コード例 #7
0
    // Update is called once per frame
    void FixedUpdate()
    {
        // floating egg
        Vector3 currPos = eggrb.position;
        float y = currPos.y;
        float newCurrTime = currTime + (Time.deltaTime) * 3f;
        y += (Mathf.Sin(newCurrTime) - Mathf.Sin(currTime)) / 3f;
        currPos.y = y;
        currTime = newCurrTime;

        if (Input.GetKeyDown(KeyCode.Space) && state == EggState.INACTIVE)
        {
            state = EggState.UP;
        }

        float extraY;
        switch (state) {
            case EggState.INACTIVE:
            default:
                extraY = 0;
                break;
            case EggState.UP:
                tick += Time.deltaTime;
                if (tick > tickMax)
                {
                    tick = tickMax;
                    state = EggState.DOWN;
                    extraY = 1f;
                }
                else
                {
                    extraY = 3 * tick / tickMax;
                }
                break;
            case EggState.DOWN:
                tick -= Time.deltaTime;
                if (tick < 0)
                {
                    tick = 0;
                    state = EggState.INACTIVE;
                    extraY = 0f;
                }
                else
                {
                    extraY = 3 * tick / tickMax;
                }
                break;
        }
        currPos.y -= subt;
        currPos.y += extraY;
        subt = extraY;
        eggrb.position = currPos;
    }
コード例 #8
0
        private void UpdateState(EggState state)
        {
            if (gameObject == null || !gameObject.activeInHierarchy)
            {
                return;
            }

            if (state == currentState)
            {
                UpdateExamineMessage();
                return;
            }

            currentState = state;
            UpdateExamineMessage();
        }
コード例 #9
0
    void Awake()
    {
        EnemyCount++;
        hitCount     = 0;
        sprite       = GetComponent <Renderer>();
        wander       = GetComponent <Wander>();
        waypoint     = GetComponent <WaypointMover>();
        stunnedState = GetComponent <StunnedState>();
        eggState     = GetComponent <EggState>();
        ccwState     = GetComponent <CCWState>();
        cwState      = GetComponent <CWState>();
        chaseState   = GetComponent <ChaseState>();
        enlargeState = GetComponent <EnlargeState>();
        shrinkState  = GetComponent <ShrinkState>();

        gameObject.GetComponent <Animator>().Play("Idle");
        if (waypoint == null)
        {
            waypoint = gameObject.AddComponent <WaypointMover>();
        }

        enemies.Add(this);
    }
コード例 #10
0
ファイル: SimpleEgg.cs プロジェクト: SrBilyon/puzzleGame
    /// <summary>
    /// Push the eggs over if not falling
    /// </summary>
    /// <param name="direction"></param>
    /// <param name="grid"></param>
    public void Toss(BumpDirection direction, Vector2 grid)
    {
        //if (eggState != EggState.Falling && eggState != EggState.Resting)
        //{
            if (direction == BumpDirection.Left)
            {
                //While the slot left of me isn't the edge
                while ((grid.x) > 0)
                {
                    trappedLeft = false; atEdge = false;

                    //Slide if there isn't anything to the left of me
                    if (!IsSomethingLeftOfMe(grid) && !trappedLeft)
                    {
                        //And either there isn't anything under and I'm not at the bottom
                        if (!CheckIfGrounded())
                        {
                            eggState = EggState.Falling;
                            break;
                        }
                        else
                        //If I'm at the bottom of the grid
                        if (CheckIfGrounded())
                        {
                            //eggState = EggState.Resting;
                            PositionToGrid(new Vector2(grid.x - 1, grid.y));
                            break;
                        }

                        //Start sliding me over to the left
                        //PositionToGrid(new Vector2(grid.x - 1, grid.y));
                        break;
                    }
                    else if (IsSomethingLeftOfMe(grid))//If I bumped into something on the left
                    {
                        if (!nLeft.trappedLeft)
                        {
                            nLeft.bumpDirection = BumpDirection.Left;
                            nLeft.eggState = EggState.Bumped;
                            eggState = EggState.Bumped;
                        }
                        else
                        {
                            //eggState = EggState.Resting;
                        }
                        break;
                    }
                }

                //If I'm on the left edge
                if (grid.x == 0)
                {
                    //bumpDirection = BumpDirection.Down;
                    trappedLeft = true;
                    atEdge = true;
                    //eggState = EggState.Resting;
                }
                else
                {
                    trappedLeft = false;
                    atEdge = false;
                }
            }
            else
                if (direction == BumpDirection.Right)
                {
                    //While the slot right of me isn't the edge
                    while ((grid.x) < GameMain.colCount - 1)
                    {
                        trappedRight = false; atEdge = false;

                        //If there isn't anything to the right of me
                        if (!IsSomethingRightOfMe(grid))
                        {
                            //And either there isn't anything under and I'm not at the bottom
                            if (!IsSomethingUnderneath(gridCoord) && grid.y != 0)
                            {
                                eggState = EggState.Falling;
                                break;
                            }
                            //If I'm at the bottom of the grid
                            if (gridCoord.y == 0)
                            {
                                PositionToGrid(new Vector2(grid.x + 1, grid.y));
                                break;
                            }

                            //Start sliding me over to the right
                            PositionToGrid(new Vector2(grid.x + 1, grid.y));
                            break;
                        }
                        else //If I bumped into something on the right
                        {
                            if (!nRight.atEdge)
                            {
                                nRight.bumpDirection = BumpDirection.Right;
                                nRight.eggState = EggState.Bumped;
                            }
                            eggState = EggState.Falling;
                            break;
                        }
                    }
                    //If I'm on the right edge
                    if (grid.x == GameMain.colCount - 1)
                    {
                        bumpDirection = BumpDirection.Down;
                        trappedRight = true;
                        eggState = EggState.Resting;
                        atEdge = true;
                    }
                    else
                    {
                        trappedRight = false;
                        atEdge = false;
                    }
          //      }
        }
    }
コード例 #11
0
 // Use this for initialization
 void Start()
 {
     foreach(Transform t in transform) {
         if(t.name.Equals("egg")) {
             eggrb = t.gameObject.GetComponent<Rigidbody>();
         }
     }
     currTime = 0;
     prayerCount = 0;
     startY = transform.position.y;
     tickMax = 0.5f;
     state = EggState.INACTIVE;
     subt = 0;
 }
コード例 #12
0
 private void Start()
 {
     m_CurrentEggState           = EggState.RawEgg;
     m_OriginalPositionInKitchen = this.transform.localPosition;
 }
コード例 #13
0
ファイル: SimpleEgg.cs プロジェクト: SrBilyon/puzzleGame
    void Start()
    {
        //PositionToGrid(gridCoord);
        eggState = EggState.Waiting;

        if (GameMain.currentEgg == this)
            eggState = EggState.Active;
    }
コード例 #14
0
ファイル: SimpleEgg.cs プロジェクト: SrBilyon/puzzleGame
    /// <summary>
    /// Update the Egg
    /// </summary>
    void Update()
    {
        switch (eggState)
        {
            case EggState.Falling:
                //Gravity Function
                //StartCoroutine("Drop", gridCoord);
                Drop(gridCoord);
                break;

            case EggState.Resting:
                CheckAllNeighbors();
                DestroyMatching(gridCoord);

                BumpNeighbors();
                break;

            case EggState.Bumped:
                Toss(bumpDirection, gridCoord);
                BumpNeighbors();
                Drop(gridCoord);
                break;

            case EggState.Selected:
                if (GameMain.selectedEdge != null)
                {
                    transform.position = GameMain.selectedEdge.transform.position;
                }
                break;

            case EggState.Waiting:
                break;

            case EggState.Active:
                break;
        }

        if (eggState != EggState.Waiting &&  eggState != EggState.Active && eggState != EggState.Selected)
        {
            if (!CheckIfGrounded())
            {
                eggState = EggState.Falling;
            }
            else
            {
                eggState = EggState.Resting;

            }

            CheckAllNeighbors();

        }
    }
コード例 #15
0
ファイル: SimpleEgg.cs プロジェクト: SrBilyon/puzzleGame
    /// <summary>
    /// Drop the egg down like gravity
    /// </summary>
    /// <param name="grid"></param>
    /// <returns></returns>
    /// 
    void Drop(Vector2 grid)
    {
        //eggState = EggState.Falling;

        //Move the cube drown
        while (!CheckIfGrounded())
        {
            //yield return new WaitForSeconds(0.05f);

            //Make sure I'm not in the last row
            if (!CheckIfOnLastRow())
            {
                //I landed on something
                if (CheckIfGrounded())
                {
                    eggState = EggState.Resting;
                    break;
                }
                //Falling
                else if (!CheckIfGrounded())
                {
                    PositionToGrid(new Vector2(gridCoord.x, gridCoord.y - 1));
                }
            }
            else if (CheckIfGrounded())
            {
                eggState = EggState.Resting;

                if (IsSomethingAbove(gridCoord))
                {
                    break;
                }
                else if (!CheckIfGrounded())
                {
                    PositionToGrid(new Vector2(gridCoord.x, gridCoord.y));
                    break;
                }
                break;
            }

            //If I'm on the very top and nothing is under me
            else if (CheckIfOnLastRow())
            {
                if (CheckIfGrounded())
                {
                    PositionToGrid(new Vector2(gridCoord.x, gridCoord.y));
                    bumpDirection = BumpDirection.Down;
                    eggState = EggState.Resting;
                    break;
                }
                PositionToGrid(new Vector2(gridCoord.x, gridCoord.y - 1));
            }
        }
    }
コード例 #16
0
 public void SetTrigger(EggState state)
 {
     _animator.SetTrigger(triggers[state]);
 }
コード例 #17
0
ファイル: SimpleEgg.cs プロジェクト: SrBilyon/puzzleGame
 /// <summary>
 /// Return the egg to the current slot if the egg isn't able to be dropped
 /// </summary>
 public void ReturnToCurrentSlot()
 {
     Debug.LogWarning("There is an egg in the slot. Try again");
     eggState = EggState.Waiting;
     gridCoord = new Vector2(-1, -1);
     GameMain.currentEgg.transform.position = new Vector3(GameMain.currentEggHolder.transform.position.x, GameMain.currentEggHolder.transform.position.y, -3);
 }
コード例 #18
0
ファイル: SimpleEgg.cs プロジェクト: SrBilyon/puzzleGame
    /// <summary>
    /// An event called when the user unselects the mouse buttom
    /// </summary>
    public void OnMouseUp()
    {
        //If this egg is the selected one...
        if (eggState == EggState.Selected)
        {
            //Get the slot that the egg should be dropping into
            var gridInt = GameMain.GetGridSlotIndex(GameMain.currentEggDropCoords);
            gridCoord = GameMain.GetGridCoord(gridInt);

            //Set the grid coord to the position we are wanting to get in
            PositionToGrid(new Vector2(gridCoord.x, gridCoord.y));

            //Check to see if there is an egg in the slot we are trying to place
            //this egg in
            if (EggUtility.IsEggInSlot(gridCoord))
            {
                ReturnToCurrentSlot();
                return;
            }

            //Tag the egg
            tag = "Egg";

            bumpDirection = BumpDirection.Down;

            //Check to see if we are on the left side or the right side
            if (gridCoord.x == 0)
            {
                trappedLeft = true; trappedRight = false;
                bumpDirection = BumpDirection.Right;
                eggState = EggState.Bumped;
            }

            if (gridCoord.x == GameMain.colCount - 1)
            {
                trappedRight = true; trappedLeft = false;
                bumpDirection = BumpDirection.Left;
                eggState = EggState.Bumped;
            }
            else
            {
                trappedRight = false; trappedLeft = false;
                eggState = EggState.Falling;
            }

            //Change the egg to the state of resting
            //if (!IsSomethingUnderneath(gridCoord))

            //else
            //    eggState = EggState.Falling;

            //Replace the current egg with the one in the next egg pool
            GameMain.currentEgg = GameMain.nextEgg;

            //Create a new next egg
            GameMain.nextEgg = Instantiate(EggUtility.CreateNewEgg()) as SimpleEgg;

            //Place all the eggs in the right position
            GameMain.currentEgg.transform.position = new Vector3(GameMain.currentEggHolder.transform.position.x, GameMain.currentEggHolder.transform.position.y, -3);
            GameMain.nextEgg.transform.position = new Vector3(GameMain.nextEggHolder.transform.position.x, GameMain.nextEggHolder.transform.position.y, -3);
        }
    }
コード例 #19
0
ファイル: SimpleEgg.cs プロジェクト: SrBilyon/puzzleGame
    /// <summary>
    /// An event called when the mouse or touch hits this object
    /// </summary>
    public void OnMouseDown()
    {
        //Make sure the egg I'm clicking
        if (GameMain.currentEgg == this)
            eggState = EggState.Active;

        //Be able to select the egg only if it's the selected egg
        if (eggState == EggState.Active)
        {
            eggState = EggState.Selected;
        }
    }