Exemple #1
0
    public void Load(LitJson.JSONNode json)
    {
        id = int.Parse(json["ID"]);

        battleParam = new BasicBattleParam();
        battleParam.Load(json);

        name       = json["Name"];
        asset      = json["Asset"];
        bulletType = (DataConfig.BULLET_TYPE) int.Parse(json ["CannonType"]);
        bodyType   = (DataConfig.BODY_TYPE) int.Parse(json ["BodyType"]);
        quality    = JsonReader.Int(json, "Quality");

        targetSelect = (DataConfig.TARGET_SELECT)JsonReader.Int(json, "targetSelect");
        shootCD      = JsonReader.Float(json, "shootCD");    //5;

        shootRange = JsonReader.Float(json, "shootRange");   //150;
        closeRange = JsonReader.Float(json, "closeRange");   //80;
        fightRange = JsonReader.Float(json, "fightRange");   //40;
//		Assert.assert (shootRange >= closeRange);
        Assert.assert(closeRange >= fightRange);

        stopToFire      = true;                                      //int.Parse (json ["stopToFire"]) != 0;
        canStandTurn    = JsonReader.Int(json, "canStandTurn") != 0;
        firePrepareTime = JsonReader.Float(json, "firePrepareTime"); //1;
        damageRange     = JsonReader.Float(json, "damageRange");
        length          = JsonReader.Float(json, "length");          //7;
        Assert.assert(length <= MapGrid.GRID_SIZE);
        breakTime = JsonReader.Float(json, "breakTime");             //2;
        speed     = float.Parse(json ["Speed"]);

        costCdCash = JsonReader.Float(json, "CdCash");

        fireCount    = int.Parse(json ["FireCount"]);
        fireInterval = float.Parse(json ["FireInterval"]);
//		shootInterval = float.Parse (json ["ShootInterval"]);
//		targetsPerFire = int.Parse (json ["TargetsPerFire"]);
//		targetsSelectType = (DataConfig.TARGETS_SELECT_TYPE)int.Parse (json ["TargetSelectType"]);

        string str_partsId = json["PartsID"];

        partsId = StringHelper.ReadIntArrayFromString(str_partsId);

        cost = new BasicCost();
        cost.Load(json);

        buildingLevel = int.Parse(json ["BuildingLevel"]);

        repairRate = float.Parse(json ["RepairRate"]);

        chipId    = JsonReader.Int(json, "ChipID");
        chipCount = JsonReader.Int(json, "ChipCount");
    }
Exemple #2
0
    // ====================================
    // select strategy


    public RESULT Select(DataConfig.TARGET_SELECT forceSelectType = DataConfig.TARGET_SELECT.UNKNOWN)
    {
        if (forceSelectType == DataConfig.TARGET_SELECT.UNKNOWN)
        {
            forceSelectType = _unit.unit.dataUnit.targetSelect;
        }

        switch (forceSelectType)
        {
        case DataConfig.TARGET_SELECT.CENTER:
            return(Select_center());

            break;

        case DataConfig.TARGET_SELECT.CENTER_RANDOM:
            return(Select_centerRandom());

            break;

        case DataConfig.TARGET_SELECT.CLOSEST:
            return(Select_closest());

            break;

        case DataConfig.TARGET_SELECT.CLOSEST_RANDOM:
            return(Select_closetRandom());

            break;

        case DataConfig.TARGET_SELECT.RANDOM:
            return(Select_random());

            break;

        default:
            return(Select_random());

            break;
        }
    }
Exemple #3
0
    public void RefreshTarget(DataConfig.TARGET_SELECT forceSelectType = DataConfig.TARGET_SELECT.UNKNOWN)
    {
        if (_currentTarget == null)
        {
            _refreshTimestamp = 0;
        }

        long ct = TimeHelper.GetCurrentTimestampScaled();
        long dt = ct - _refreshTimestamp;

        if (ct < REFRESH_INTERVAL * 1000)
        {
            return;
        }
        _refreshTimestamp = ct;


        UnitTargetSelect.RESULT r = Select(forceSelectType);
        if (r != null)
        {
            SwitchTarget(r);
        }
    }