Пример #1
0
    void Start()
    {
        playerScript = GameObject.Find("Player");
        boardScript  = GameObject.Find("BoardManager");
        numHarvested = 0;
        ripeTimer    = 0;
        ChangeMaxHarvest();
        type     = Type.Grass;
        bushType = BushType.PurpleBush;
        TurnGrass();
        ResetAlarms();

        iconInstance = Instantiate(icons, new Vector2(transform.position.x, transform.position.y), Quaternion.identity) as GameObject;
        iconInstance.transform.parent = gameObject.transform;
        iconInstance.name             = "icon[" + transform.position.x + "][" + transform.position.y + "]";
    }
Пример #2
0
    public void OnMouseDown()
    {
        switch (type)
        {
        case Type.Grass:
        {
            if (playerScript.GetComponent <Player>().tool == playerScript.GetComponent <Player>().hoe)
            {
                TurnTilled();
            }
            break;
        }

        case Type.Tilled:
        {
            if (playerScript.GetComponent <Player>().tool == playerScript.GetComponent <Player>().plantSeed)
            {
                TurnPlanted();
                // this make sure its right bush type
                if (playerScript.GetComponent <Player>().seed == playerScript.GetComponent <Player>().redSeed)
                {
                    playerScript.GetComponent <Player>().hoorays -= boardScript.GetComponent <BoardManager>().redPrice;
                    bushType = BushType.RedBush;
                }
                else if (playerScript.GetComponent <Player>().seed == playerScript.GetComponent <Player>().blueSeed)
                {
                    playerScript.GetComponent <Player>().hoorays -= boardScript.GetComponent <BoardManager>().bluePrice;
                    bushType = BushType.BlueBush;
                }
                else if (playerScript.GetComponent <Player>().seed == playerScript.GetComponent <Player>().greenSeed)
                {
                    playerScript.GetComponent <Player>().hoorays -= boardScript.GetComponent <BoardManager>().greenPrice;
                    bushType = BushType.GreenBush;
                }
                else if (playerScript.GetComponent <Player>().seed == playerScript.GetComponent <Player>().purpleSeed)
                {
                    playerScript.GetComponent <Player>().hoorays -= boardScript.GetComponent <BoardManager>().purplePrice;
                    bushType = BushType.PurpleBush;
                }
            }
            else if (playerScript.GetComponent <Player>().tool == playerScript.GetComponent <Player>().mulch)
            {
                Mulch();
            }
            break;
        }

        case Type.Planted:
        {
            if (playerScript.GetComponent <Player>().tool == playerScript.GetComponent <Player>().mulch)
            {
                Mulch();
            }
            if (playerScript.GetComponent <Player>().tool == playerScript.GetComponent <Player>().watercan)
            {
                Water();
            }
            break;
        }

        case Type.Growing:
        {
            if (playerScript.GetComponent <Player>().tool == playerScript.GetComponent <Player>().mulch)
            {
                Mulch();
            }
            if (playerScript.GetComponent <Player>().tool == playerScript.GetComponent <Player>().watercan)
            {
                Water();
            }
            break;
        }

        case Type.Bush:
        {
            if (playerScript.GetComponent <Player>().tool == playerScript.GetComponent <Player>().watercan)
            {
                Water();
            }
            break;
        }

        case Type.Bud:
        {
            if (playerScript.GetComponent <Player>().tool == playerScript.GetComponent <Player>().watercan)
            {
                Water();
            }
            break;
        }

        case Type.Flower:
        {
            if (playerScript.GetComponent <Player>().tool == playerScript.GetComponent <Player>().watercan)
            {
                Water();
            }
            break;
        }

        case Type.Ripe:
        {
            if (playerScript.GetComponent <Player>().tool == playerScript.GetComponent <Player>().hand)
            {
                TurnHarvest();
            }
            break;
        }
        }
        // Debug.Log ("Tile" + "[" + x + "][" + y + "] : "  + type + " " + bushType + "\n");
    }