Example #1
0
    public void UpdateUnit(Unit unit)   //returns true if succeeds, false otherwise
    //if (unit.speciesName != speciesName) { return; } //cant modify another species

    {
        if (!unit.CompareTag("Hostile"))
        {
            unit.UpdateHeadSize(headSize);
            unit.UpdateLegSize(legSize);
            unit.UpdateBellySize(bellySize);
            unit.UpdateEarSize(earSize);
            unit.UpdateTailSize(tailSize);
            unit.UpdateArmSize(armSize);
            unit.UpdateFurColor(color);
        }

        if (unit.CompareTag("Preview"))
        {
            return;
        }

        unit.genetiumSource    = genetiumSource;
        unit.foodSource        = foodSource;
        unit.speed             = speed;
        unit.interactionRadius = UnitHelperFunctions.Interpolate(legSize, new float[, ] {
            { 0.2f, 0.5f }, { 0.6f, 0.6f }
        });                                                                                                          //todo: rethink this

        //unit.areaCenter = areaCenter;


        //unit.areaRadius = AreaRadiusFromSize();
        unit.gameObject.tag = tag;
        unit.swimspeed      = swimspeed;

        if (tag == "Pet")
        {
            unit.enemyTag = "Hostile";
        }
        else if (tag == "Hostile")
        {
            unit.enemyTag = "Pet";
        }
        else
        {
            throw new System.Exception("Wrong tag for unit");
        }
        UnitActions.ResetSelectionGraphicPosition(unit);
        return;
    }