WeiWeiXinNet/Games/game6/land.js

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

goog.provide('farming.Land');
goog.require('lime.Sprite');

/**
 * Land elements
 * 
 * @param {} gameObj
 */
farming.Land = function(gameObj, playerObj) {
    goog.base(this);
    this.setAnchorPoint(0, 0);
    this.setSize(gameObj.tile_size,gameObj.tile_size);
    this.setFill('images/bare_land.png');
    
    this.state = this.EMPTY;
    
    //user input
    var land = this;
    goog.events.listen(this,['mousedown', 'touchstart'], function(e) {
        e.event.stopPropagation();        
        if(land.state == land.EMPTY && playerObj.money >= gameObj.costPlowing) {
            //plow land
            land.setFill('images/plowed.png')
            land.state = land.PLOWED;
            
            //update player money
            playerObj.money -= gameObj.costPlowing;
            gameObj.updateMoney();
        }
        else if(land.state == land.PLOWED && playerObj.money >= gameObj.crops[playerObj.currentCrop].cost) {
            //plant
            land.setFill('images/growing.png');
            land.state = land.GROWING;
            
            //store crop and left time for it to be ready and to die
            land.crop = playerObj.currentCrop;
            land.ripeTime = gameObj.crops[playerObj.currentCrop].time_to_ripe * 1000;
            land.deathTime = gameObj.crops[playerObj.currentCrop].time_to_death * 1000;
            
            //update player money
            playerObj.money -= gameObj.crops[playerObj.currentCrop].cost;
            gameObj.updateMoney();
        }
        else if(land.state == land.READY ) {
            //harvest
            land.setFill('images/bare_land.png');
            land.state = land.EMPTY;
            
            //update player money
            playerObj.money += gameObj.crops[land.crop].revenue;
            gameObj.updateMoney();
        }        
    });
    
    //growing plants
    dt = 1000;
    lime.scheduleManager.scheduleWithDelay(function() {
        if(this.state == this.GROWING) {            
            if(this.ripeTime <= 0) {
                this.state = this.READY;

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。